mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 03:18:23 +00:00
Reload things after migration
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user