Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion app/src/main/kotlin/com/wisp/app/repo/BlossomRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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?) {
Expand Down