commit f1dc023e18a0358ff27a0b09fe93307e3edd2e38
parent 4a332c7ffaa939e0178b06c27170c1e98ac68791
Author: William Casarin <jb55@jb55.com>
Date:   Sun, 14 Jul 2024 20:14:32 -0700
fix crash when adding duplicate mute items
Changelog-Fixed: Fix crash when adding duplicate mute items
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 4 insertions(+), 0 deletions(-)
diff --git a/damus/Models/MutelistManager.swift b/damus/Models/MutelistManager.swift
@@ -111,12 +111,16 @@ class MutelistManager {
     private func add_mute_item(_ item: MuteItem) {
         switch item {
         case .user(_, _):
+            guard !users.contains(item) else { return }
             users.insert(item)
         case .hashtag(_, _):
+            guard !hashtags.contains(item) else { return }
             hashtags.insert(item)
         case .word(_, _):
+            guard !words.contains(item) else { return }
             words.insert(item)
         case .thread(_, _):
+            guard !threads.contains(item) else { return }
             threads.insert(item)
         }
     }