Reload things after migration

This commit is contained in:
greenart7c3
2025-05-12 20:43:35 -03:00
parent f91d7c25a8
commit 33411aa22a
2 changed files with 16 additions and 1 deletions
@@ -135,7 +135,6 @@ class Amber : Application() {
}
runMigrations()
startService()
}
fun runMigrations() {
@@ -154,6 +153,8 @@ class Amber : Application() {
}
LocalPreferences.migrateTorSettings(this@Amber)
settings = LocalPreferences.loadSettingsFromEncryptedStorage()
LocalPreferences.reloadApp()
startService()
}
}
@@ -194,6 +194,20 @@ object LocalPreferences {
}
}
suspend fun reloadApp() {
val context = Amber.instance
val job = context.applicationIOScope.launch {
currentAccount = null
savedAccounts = null
accountCache.evictAll()
allSavedAccounts(context).forEach {
loadFromEncryptedStorage(context, it.npub)
}
context.settings = loadSettingsFromEncryptedStorage(context)
}
job.join()
}
fun loadSettingsFromEncryptedStorage(context: Context = Amber.instance): AmberSettings {
checkNotInMainThread()
sharedPrefs(context).apply {