mute: migrate Lists.swift to use new MuteItem

This patch depends on: Adding new structs/enums for new mute list

- Rewrites Lists.swift to use new mute list option
    - This leads to a lot of changes for changing the type from RefId to the new MuteItem
- Update & relay new mute list in AddMuteItemView.swift (fixing previous patch TODO)
- Renames `list` to `list_deprecated`
    - We need to keep this since existing users might have an old mute list

Related: https://github.com/damus-io/damus/issues/1718
Related: https://github.com/damus-io/damus/issues/856
Lighting Address: fishcharlie@strike.me

Signed-off-by: Charlie Fish <contact@charlie.fish>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Charlie Fish
2024-01-17 18:17:38 -07:00
committed by William Casarin
parent 6d2c382469
commit f36646116e
11 changed files with 91 additions and 82 deletions

View File

@@ -798,3 +798,15 @@ func to_reaction_emoji(ev: NostrEvent) -> String? {
}
}
extension NostrEvent {
/// The mutelist for a given event
///
/// If the event is not a mutelist it will return `nil`.
var mute_list: Set<MuteItem>? {
if (self.kind == NostrKind.list_deprecated.rawValue && self.referenced_params.contains(where: { p in p.param.matches_str("mute") })) || self.kind == NostrKind.mute_list.rawValue {
return Set(self.referenced_mute_items)
} else {
return nil
}
}
}

View File

@@ -17,7 +17,8 @@ enum NostrKind: UInt32, Codable {
case boost = 6
case like = 7
case chat = 42
case list = 30000
case mute_list = 10000
case list_deprecated = 30000
case longform = 30023
case zap = 9735
case zap_request = 9734