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:
William Casarin
2024-02-26 11:31:56 -08:00
44 changed files with 1076 additions and 333 deletions

View File

@@ -325,6 +325,10 @@ extension NdbNote {
References<ReplaceableParam>(tags: self.tags)
}
public var referenced_mute_items: References<MuteItem> {
References<MuteItem>(tags: self.tags)
}
public var references: References<RefId> {
References<RefId>(tags: self.tags)
}
@@ -342,6 +346,14 @@ extension NdbNote {
return content
}
func maybe_get_content(_ keypair: Keypair) -> String? {
if known_kind == .dm {
return decrypted(keypair: keypair)
}
return content
}
func blocks(_ keypair: Keypair) -> Blocks {
return get_blocks(keypair: keypair)
}

View File

@@ -130,6 +130,22 @@ struct NdbTagElem: Sequence, Hashable, Equatable {
return id.id
}
func u64() -> UInt64? {
switch self.data() {
case .id:
return nil
case .str(let str):
var end_ptr = UnsafeMutablePointer<CChar>(nil as OpaquePointer?)
let res = strtoull(str.str, &end_ptr, 10)
if end_ptr?.pointee == 0 {
return res
} else {
return nil
}
}
}
func string() -> String {
switch self.data() {
case .id(let id):