fix: crash when muting threads

Fixes a crash when the user mutes a thread. UserDefaults didn't know how
to serialize a NoteId for storage, so we'll convert it to the hex id
first.

Changelog-Fixed: Crash when muting threads
Signed-off-by: Bryan Montz <bryanmontz@me.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Bryan Montz
2023-08-04 07:13:31 -05:00
committed by William Casarin
parent 14ba33674b
commit cddb88b890

View File

@@ -24,7 +24,8 @@ func saveMutedThreads(pubkey: Pubkey, currentValue: [NoteId], value: [NoteId]) -
let uniqueMutedThreads = Array(Set(value))
if uniqueMutedThreads != currentValue {
UserDefaults.standard.set(uniqueMutedThreads, forKey: getMutedThreadsKey(pubkey: pubkey))
let ids = uniqueMutedThreads.map { note_id in return note_id.hex() }
UserDefaults.standard.set(ids, forKey: getMutedThreadsKey(pubkey: pubkey))
return true
}