diff --git a/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt b/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt index e6efdb6..c5d4cfd 100644 --- a/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt +++ b/app/src/main/kotlin/app/dapk/st/graph/AppModule.kt @@ -77,17 +77,21 @@ internal class AppModule(context: Application, logger: MatrixLogger) { preferences = SharedPreferencesDelegate(context.applicationContext, fileName = "dapk-user-preferences", coroutineDispatchers), errorTracker = trackingModule.errorTracker, credentialPreferences = SharedPreferencesDelegate(context.applicationContext, fileName = "dapk-credentials-preferences", coroutineDispatchers), - databaseDropper = { includeCryptoAccount -> + databaseDropper = { deleteCrypto -> val cursor = driver.executeQuery( identifier = null, - sql = "SELECT name FROM sqlite_master WHERE type = 'table' ${if (includeCryptoAccount) "" else "AND name != 'dbCryptoAccount'"}", + sql = "SELECT name FROM sqlite_master WHERE type = 'table'", parameters = 0 ) cursor.use { while (cursor.next()) { cursor.getString(0)?.let { - log(AppLogTag.ERROR_NON_FATAL, "Deleting $it") - driver.execute(null, "DELETE FROM $it", 0) + if (!deleteCrypto && it.startsWith("dbCrypto")) { + // skip + } else { + log(AppLogTag.ERROR_NON_FATAL, "Deleting $it") + driver.execute(null, "DELETE FROM $it", 0) + } } } } diff --git a/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsItemFactory.kt b/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsItemFactory.kt index 4068ff4..dd2457f 100644 --- a/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsItemFactory.kt +++ b/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsItemFactory.kt @@ -8,6 +8,8 @@ internal class SettingsItemFactory(private val buildMeta: BuildMeta) { SettingItem.Header("General"), SettingItem.Text(SettingItem.Id.Encryption, "Encryption"), SettingItem.Text(SettingItem.Id.EventLog, "Event log"), + SettingItem.Header("Data"), + SettingItem.Text(SettingItem.Id.ClearCache, "Clear cache"), SettingItem.Header("Account"), SettingItem.Text(SettingItem.Id.SignOut, "Sign out"), SettingItem.Header("About"), diff --git a/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsViewModel.kt b/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsViewModel.kt index f8dc927..c7063f1 100644 --- a/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsViewModel.kt +++ b/features/settings/src/main/kotlin/app/dapk/st/settings/SettingsViewModel.kt @@ -3,9 +3,7 @@ package app.dapk.st.settings import android.content.ContentResolver import android.net.Uri import androidx.lifecycle.viewModelScope -import app.dapk.st.core.AppLogTag import app.dapk.st.core.Lce -import app.dapk.st.core.log import app.dapk.st.design.components.SpiderPage import app.dapk.st.domain.StoreCleaner import app.dapk.st.matrix.crypto.CryptoService @@ -37,7 +35,6 @@ internal class SettingsViewModel( val root = Page.Root(Lce.Content(settingsItemFactory.root())) val rootPage = SpiderPage(Page.Routes.root, "Settings", null, root) updateState { copy(page = rootPage) } - println("state updated") } } @@ -49,7 +46,6 @@ internal class SettingsViewModel( when (item.id) { SignOut -> { viewModelScope.launch { - log(AppLogTag.ERROR_NON_FATAL, "Sign out triggered") cacheCleaner.cleanCache(removeCredentials = true) _events.emit(SignedOut) }