This commit fixes a crash that occurred when clicking "follow all" during onboarding. This fix works by making `Contacts` and `PostBox` isolated into a specific Swift Actor, and updating direct and indirect usages accordingly. Changelog-Fixed: Fixed a crash that occurred when clicking "follow all" during onboarding. Closes: https://github.com/damus-io/damus/issues/3422 Co-authored-by: alltheseas <64376233+alltheseas@users.noreply.github.com> Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
47 lines
1.2 KiB
Swift
47 lines
1.2 KiB
Swift
//
|
||
// NotificationExtensionState.swift
|
||
// DamusNotificationService
|
||
//
|
||
// Created by Daniel D’Aquino on 2023-11-27.
|
||
//
|
||
|
||
import Foundation
|
||
|
||
@MainActor
|
||
struct NotificationExtensionState: HeadlessDamusState {
|
||
let ndb: Ndb
|
||
let settings: UserSettingsStore
|
||
let contacts: Contacts
|
||
let mutelist_manager: MutelistManager
|
||
let keypair: Keypair
|
||
let profiles: Profiles
|
||
let zaps: Zaps
|
||
let lnurls: LNUrls
|
||
|
||
init?() {
|
||
guard let ndb = Ndb(owns_db_file: false) else { return nil }
|
||
self.ndb = ndb
|
||
|
||
guard let keypair = get_saved_keypair() else { return nil }
|
||
|
||
// dumb stuff needed for property wrappers
|
||
UserSettingsStore.pubkey = keypair.pubkey
|
||
self.settings = UserSettingsStore()
|
||
|
||
self.contacts = Contacts(our_pubkey: keypair.pubkey)
|
||
self.mutelist_manager = MutelistManager(user_keypair: keypair)
|
||
self.keypair = keypair
|
||
self.profiles = Profiles(ndb: ndb)
|
||
self.zaps = Zaps(our_pubkey: keypair.pubkey)
|
||
self.lnurls = LNUrls()
|
||
}
|
||
|
||
@discardableResult
|
||
func add_zap(zap: Zapping) -> Bool {
|
||
// store generic zap mapping
|
||
self.zaps.add_zap(zap: zap)
|
||
|
||
return true
|
||
}
|
||
}
|