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 9f332a148f
commit 0f05123ef8
11 changed files with 91 additions and 82 deletions

View File

@@ -157,8 +157,11 @@ class HomeModel {
case .metadata:
// profile metadata processing is handled by nostrdb
break
case .list:
case .list_deprecated:
handle_list_event(ev)
case .mute_list:
// @TODO: this will be implemented in a future patch
break
case .boost:
handle_boost_event(sub_id: sub_id, ev)
case .like:
@@ -461,7 +464,7 @@ class HomeModel {
var our_contacts_filter = NostrFilter(kinds: [.contacts, .metadata])
our_contacts_filter.authors = [damus_state.pubkey]
var our_blocklist_filter = NostrFilter(kinds: [.list])
var our_blocklist_filter = NostrFilter(kinds: [.list_deprecated])
our_blocklist_filter.parameter = ["mute"]
our_blocklist_filter.authors = [damus_state.pubkey]

View File

@@ -145,6 +145,13 @@ enum MuteItem: Hashable, Equatable {
}
}
// - MARK: TagConvertible
extension MuteItem: TagConvertible {
static func from_tag(tag: TagSequence) -> MuteItem? {
return MuteItem(tag.strings())
}
}
extension Collection where Element == MuteItem {
/// Check if an event is muted given a collection of ``MutedItem``.
///