Merge improved mute functionality from Charlie
This merge adds a bunch of new features from charlie's work on the new mutelist changes: - Muted words - Mute performance optimizations - New mute list UI I needed to make a few changes to fix the tests in this merge. Otherwise it seems to work ok! Thank to Charlie for getting all of this working after many rounds of review! * branch `mute` of https://github.com/damus-io/damus: mute: fix bug with duplicate Indefinite items in MuteDurationMenu mute: fix mute hashtag from search view if no existing mutelist mute: integrate new MutelistManager mute: adding MutelistManager.swift mute: add maybe_get_content function to NdbNote mute: fix bug where mutes can't be added without existing mutelist mute: fix issue with not being able to change mute duration mute: don't mutate string when adding hashtag mute: implement fast MuteItem decoder tags: add u64 decoding function mute: migrating muted_threads to new mute list mute: adding ability to mute hashtag from SearchView mute: updating UI to support new mute list mute: adding filtering support for MuteItem events mute: receiving New Mute List Type mute: migrate Lists.swift to use new MuteItem mute: add new UI views for new mute list mute: adding new structs/enums for new mute list Changelog-Added: Add ability to mute words, add new mutelist interface (Charlie)
This commit is contained in:
@@ -804,3 +804,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -119,7 +119,7 @@ enum RefId: TagConvertible, TagKeys, Equatable, Hashable {
|
||||
case event(NoteId)
|
||||
case pubkey(Pubkey)
|
||||
case quote(QuoteId)
|
||||
case hashtag(TagElem)
|
||||
case hashtag(Hashtag)
|
||||
case param(TagElem)
|
||||
case naddr(NAddr)
|
||||
|
||||
@@ -155,7 +155,7 @@ enum RefId: TagConvertible, TagKeys, Equatable, Hashable {
|
||||
case .event(let noteId): return noteId.hex()
|
||||
case .pubkey(let pubkey): return pubkey.hex()
|
||||
case .quote(let quote): return quote.hex()
|
||||
case .hashtag(let string): return string.string()
|
||||
case .hashtag(let string): return string.hashtag
|
||||
case .param(let string): return string.string()
|
||||
case .naddr(let naddr):
|
||||
return naddr.kind.description + ":" + naddr.author.hex() + ":" + naddr.identifier
|
||||
@@ -176,7 +176,7 @@ enum RefId: TagConvertible, TagKeys, Equatable, Hashable {
|
||||
case .e: return t1.id().map({ .event(NoteId($0)) })
|
||||
case .p: return t1.id().map({ .pubkey(Pubkey($0)) })
|
||||
case .q: return t1.id().map({ .quote(QuoteId($0)) })
|
||||
case .t: return .hashtag(t1)
|
||||
case .t: return .hashtag(Hashtag(hashtag: t1.string()))
|
||||
case .d: return .param(t1)
|
||||
case .a: return .naddr(NAddr(identifier: "", author: Pubkey(Data()), relays: [], kind: 0))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user