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)
56 lines
2.1 KiB
Swift
56 lines
2.1 KiB
Swift
//
|
||
// MockDamusState.swift
|
||
// damusTests
|
||
//
|
||
// Created by Daniel D’Aquino on 2023-10-13.
|
||
//
|
||
|
||
import Foundation
|
||
@testable import damus
|
||
|
||
// Generates a test damus state with configurable mock parameters
|
||
func generate_test_damus_state(
|
||
mock_profile_info: [Pubkey: Profile]?
|
||
) -> DamusState {
|
||
// Create a unique temporary directory
|
||
let ndb = Ndb.test
|
||
let our_pubkey = test_pubkey
|
||
let pool = RelayPool(ndb: ndb)
|
||
let settings = UserSettingsStore()
|
||
|
||
let profiles: Profiles = {
|
||
guard let mock_profile_info, let profiles: Profiles = MockProfiles(mocked_profiles: mock_profile_info, ndb: ndb) else {
|
||
return Profiles.init(ndb: ndb)
|
||
}
|
||
return profiles
|
||
}()
|
||
|
||
let mutelist_manager = MutelistManager()
|
||
let damus = DamusState(pool: pool,
|
||
keypair: test_keypair,
|
||
likes: .init(our_pubkey: our_pubkey),
|
||
boosts: .init(our_pubkey: our_pubkey),
|
||
contacts: .init(our_pubkey: our_pubkey), mutelist_manager: mutelist_manager,
|
||
profiles: profiles,
|
||
dms: .init(our_pubkey: our_pubkey),
|
||
previews: .init(),
|
||
zaps: .init(our_pubkey: our_pubkey),
|
||
lnurls: .init(),
|
||
settings: settings,
|
||
relay_filters: .init(our_pubkey: our_pubkey),
|
||
relay_model_cache: .init(),
|
||
drafts: .init(),
|
||
events: .init(ndb: ndb),
|
||
bookmarks: .init(pubkey: our_pubkey),
|
||
postbox: .init(pool: pool),
|
||
bootstrap_relays: .init(),
|
||
replies: .init(our_pubkey: our_pubkey),
|
||
wallet: .init(settings: settings),
|
||
nav: .init(),
|
||
music: .init(onChange: {_ in }),
|
||
video: .init(),
|
||
ndb: ndb)
|
||
|
||
return damus
|
||
}
|