commit cddb88b8901e8d0bf23e31540bdc1322833422dc
parent 14ba33674b914db5afc515d33a4e5310382e894d
Author: Bryan Montz <bryanmontz@me.com>
Date: Fri, 4 Aug 2023 07:13:31 -0500
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>
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/damus/Models/MutedThreadsManager.swift b/damus/Models/MutedThreadsManager.swift
@@ -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
}