File tree Expand file tree Collapse file tree
android/app/src/main/kotlin/com/logseq/app/runtime Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -373,8 +373,24 @@ internal class LogseqRuntime(
373373 )
374374 val resolution = executor.execute(effect)
375375 if (effect.kind == " save-settings" && resolution.succeeded) {
376- runCatching { JSONObject (effect.text) }.getOrNull()?.let {
377- appearance = it.optString(" appearance" , " system" )
376+ val storage = platformEffects.loadStorageState()
377+ appearance = storage.settings.appearance
378+ if (storage.baseUrl != storageBaseUrl) {
379+ graphCatalogAutoRefresh?.stopPeriodic()
380+ hasOpenGraph = false
381+ graphEventsJob?.cancel()
382+ pendingSyncJob?.cancel()
383+ graphEventsJob?.join()
384+ pendingSyncJob?.join()
385+ graphEventsJob = null
386+ graphEventsGraphId = null
387+ pendingSyncJob = null
388+ pendingSyncRequested = false
389+ selectedGraphId = " "
390+ appliedServerT = - 1L
391+ storageBaseUrl = storage.baseUrl
392+ platformEffects.persistSelectedGraphId(" " )
393+ runCoreRestore(hasAuthenticatedSession, storage.copy(selectedGraphId = " " ))
378394 }
379395 }
380396 if (effect.kind == " sign-in" && resolution.succeeded) {
Original file line number Diff line number Diff line change @@ -104,6 +104,22 @@ final class LGGraphLifecycle {
104104 }
105105 }
106106
107+ func reconfigureAPI( ) async throws {
108+ let token = authentication. state == . signedIn
109+ ? try await authentication. apiToken ( ) : " "
110+ await syncCoordinator. cancelBackground ( )
111+ await syncCoordinator. stopForeground ( )
112+ let defaults = UserDefaults . standard
113+ defaults. set ( " " , forKey: " logseq.selectedGraphId " )
114+ defaults. removeObject ( forKey: " logseq.uiSession " )
115+ await store. openAndWait ( path: databasePath)
116+ await store. configureAndSelectGraph (
117+ baseURL: LogseqSettingsPolicy . storedBaseURL ( in: defaults) ,
118+ token: token,
119+ selectedGraphID: nil
120+ )
121+ }
122+
107123 func connectStoredGraph( ) async -> Bool {
108124 let defaults = UserDefaults . standard
109125 let baseURL = LogseqSettingsPolicy . storedBaseURL ( in: defaults)
Original file line number Diff line number Diff line change @@ -197,6 +197,7 @@ public struct LogseqRootView : View {
197197 let platformHandler = LGPlatformEffectHandler (
198198 saveSettings: { settings in
199199 let defaults = UserDefaults . standard
200+ let previousBaseURL = LogseqSettingsPolicy . storedBaseURL ( in: defaults)
200201 defaults. set ( settings. appearance, forKey: " logseq.appearance " )
201202 defaults. set (
202203 LogseqSettingsPolicy . normalizedLanguageID ( settings. language) ,
@@ -212,6 +213,9 @@ public struct LogseqRootView : View {
212213 forKey: " logseq.mobile.sidebarTabs "
213214 )
214215 defaults. set ( settings. baseURL, forKey: " logseq.baseURL " )
216+ if LogseqSettingsPolicy . storedBaseURL ( in: defaults) != previousBaseURL {
217+ try await graphLifecycle. reconfigureAPI ( )
218+ }
215219 } ,
216220 persistComposerDraft: { draft in
217221 UserDefaults . standard. set ( draft, forKey: " logseq.composerDraft " )
You can’t perform that action at this time.
0 commit comments