diff --git a/app/src/main/kotlin/com/wisp/app/repo/BlossomRepository.kt b/app/src/main/kotlin/com/wisp/app/repo/BlossomRepository.kt index 0be4e58a..8bff2fac 100644 --- a/app/src/main/kotlin/com/wisp/app/repo/BlossomRepository.kt +++ b/app/src/main/kotlin/com/wisp/app/repo/BlossomRepository.kt @@ -53,9 +53,12 @@ class BlossomRepository(private val context: Context, pubkeyHex: String? = null) _servers.value = list } + // In-memory reset only. `prefs` is shared with KeyRepository + // (`wisp_prefs_{pubkey}`), so `prefs.edit().clear()` would also wipe + // `local_relay`, `relays`, `dm_relays`, etc. `reload(newPubkey)` below + // repoints to the new account's file. fun clear() { _servers.value = listOf(Blossom.DEFAULT_SERVER) - prefs.edit().clear().apply() } fun reload(pubkeyHex: String?) { diff --git a/app/src/main/kotlin/com/wisp/app/repo/CustomEmojiRepository.kt b/app/src/main/kotlin/com/wisp/app/repo/CustomEmojiRepository.kt index 2b8c0b8e..4e51fa97 100644 --- a/app/src/main/kotlin/com/wisp/app/repo/CustomEmojiRepository.kt +++ b/app/src/main/kotlin/com/wisp/app/repo/CustomEmojiRepository.kt @@ -153,6 +153,9 @@ class CustomEmojiRepository(private val context: Context, pubkeyHex: String? = n _sortedUnicodeEmojis.value = all.sortedByDescending { freq[it] ?: 0 } } + // Resets in-memory state only; does NOT touch disk. On account switch the + // repo is called before the pubkey swap, so wiping `prefs` here would + // destroy the outgoing account's per-pubkey file. fun clear() { _userEmojiList.value = null _ownSets.value = emptyList() @@ -162,7 +165,6 @@ class CustomEmojiRepository(private val context: Context, pubkeyHex: String? = n _unicodeEmojis.value = emptyList() _emojiFrequency.value = emptyMap() _sortedUnicodeEmojis.value = emptyList() - prefs.edit().clear().apply() } fun reload(pubkeyHex: String?) {