[weak self]
This commit is contained in:
parent
aca43090f8
commit
ade441af74
@ -69,24 +69,24 @@ class AccountsPreferencesModel: ObservableObject {
|
|||||||
init() {
|
init() {
|
||||||
sortedAccounts = AccountManager.shared.sortedAccounts
|
sortedAccounts = AccountManager.shared.sortedAccounts
|
||||||
|
|
||||||
NotificationCenter.default.publisher(for: .UserDidAddAccount).sink(receiveValue: { _ in
|
NotificationCenter.default.publisher(for: .UserDidAddAccount).sink(receiveValue: { [weak self] _ in
|
||||||
self.sortedAccounts = AccountManager.shared.sortedAccounts
|
self?.sortedAccounts = AccountManager.shared.sortedAccounts
|
||||||
}).store(in: ¬ificationSubscriptions)
|
}).store(in: ¬ificationSubscriptions)
|
||||||
|
|
||||||
NotificationCenter.default.publisher(for: .UserDidDeleteAccount).sink(receiveValue: { _ in
|
NotificationCenter.default.publisher(for: .UserDidDeleteAccount).sink(receiveValue: { [weak self] _ in
|
||||||
self.selectedConfiguredAccountID = nil
|
self?.selectedConfiguredAccountID = nil
|
||||||
self.sortedAccounts = AccountManager.shared.sortedAccounts
|
self?.sortedAccounts = AccountManager.shared.sortedAccounts
|
||||||
self.selectedConfiguredAccountID = AccountManager.shared.defaultAccount.accountID
|
self?.selectedConfiguredAccountID = AccountManager.shared.defaultAccount.accountID
|
||||||
}).store(in: ¬ificationSubscriptions)
|
}).store(in: ¬ificationSubscriptions)
|
||||||
|
|
||||||
NotificationCenter.default.publisher(for: .AccountStateDidChange).sink(receiveValue: { notification in
|
NotificationCenter.default.publisher(for: .AccountStateDidChange).sink(receiveValue: { [weak self] notification in
|
||||||
guard let account = notification.object as? Account else {
|
guard let account = notification.object as? Account else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if account.accountID == self.account?.accountID {
|
if account.accountID == self?.account?.accountID {
|
||||||
self.account = account
|
self?.account = account
|
||||||
self.accountIsActive = account.isActive
|
self?.accountIsActive = account.isActive
|
||||||
self.accountName = account.name ?? ""
|
self?.accountName = account.name ?? ""
|
||||||
}
|
}
|
||||||
}).store(in: ¬ificationSubscriptions)
|
}).store(in: ¬ificationSubscriptions)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user