Commit 1f0cf764 authored by Chaitanya Pandit's avatar Chaitanya Pandit
Browse files

Bugfix: App was trying to connect to pod even after selecting local option

parent d54d9f57
......@@ -43,7 +43,7 @@ class AppController: ObservableObject {
let statePublisher = PassthroughSubject<AppState, Never>()
func updateState() {
guard databaseController.databasePool != nil, (try? ItemRecord.getOwnerAndDBKey()) != nil else {
guard databaseController.databasePool != nil, databaseController.isDatabaseSetup else {
state = .setup
statePublisher.send(state)
try? syncController.sync()
......@@ -73,7 +73,6 @@ class AppController: ObservableObject {
}
self?.databaseController.setupDatabase {
try? Authentication.createOwnerAndDBKey()
try? self?.databaseController.importRequiredData()
if (useDemoData) {
try? self?.databaseController.setupWithDemoData()
......
......@@ -287,6 +287,10 @@ extension DatabaseController {
extension DatabaseController {
var isDatabaseSetup: Bool {
return hasImportedSchema && hasImportedDefaultData
}
/// Check if the database has been setup
var hasImportedDemoData: Bool {
(try? read { db in
......
......@@ -59,6 +59,7 @@ class SyncController {
func sync(completion: ((Error?) -> Void)? = nil) throws {
guard (try? ItemRecord.getOwnerAndDBKey()) != nil else {
// Local mode or not setup
throw StringError(description: "Not Setup")
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment