Ensure that currentActiveUser is updated by the time activateUser() returns.
contributes to iOS-319
This commit is contained in:
parent
082f5e6ce3
commit
7b0fe1a70b
@ -28,25 +28,15 @@ public class AuthenticationServiceProvider: ObservableObject {
|
|||||||
$mastodonAuthenticationBoxes
|
$mastodonAuthenticationBoxes
|
||||||
.throttle(for: 3, scheduler: DispatchQueue.main, latest: true)
|
.throttle(for: 3, scheduler: DispatchQueue.main, latest: true)
|
||||||
.sink { [weak self] boxes in
|
.sink { [weak self] boxes in
|
||||||
let nowActive = boxes.first
|
guard let nowActive = boxes.first else { return }
|
||||||
guard nowActive?.authentication != self?.currentActiveUser.value?.authentication else { return }
|
|
||||||
self?.currentActiveUser.send(nowActive)
|
|
||||||
guard let nowActive = nowActive else { return }
|
|
||||||
Task { [weak self] in
|
Task { [weak self] in
|
||||||
try await self?.fetchFollowedBlockedUserIds(nowActive)
|
try await self?.fetchFollowedBlockedUserIds(nowActive)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.store(in: &disposeBag)
|
.store(in: &disposeBag)
|
||||||
|
|
||||||
|
|
||||||
// TODO: verify credentials for active authentication
|
// TODO: verify credentials for active authentication
|
||||||
|
|
||||||
$authentications
|
|
||||||
.map { authentications -> [MastodonAuthenticationBox] in
|
|
||||||
return self.authenticationBoxes(authentications)
|
|
||||||
}
|
|
||||||
.assign(to: &$mastodonAuthenticationBoxes)
|
|
||||||
|
|
||||||
Task {
|
Task {
|
||||||
if authenticationMigrationRequired {
|
if authenticationMigrationRequired {
|
||||||
migrateLegacyAuthentications(
|
migrateLegacyAuthentications(
|
||||||
@ -64,8 +54,14 @@ public class AuthenticationServiceProvider: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Published private var authentications: [MastodonAuthentication] = [] {
|
private var authentications: [MastodonAuthentication] = [] {
|
||||||
didSet {
|
didSet {
|
||||||
|
let boxes = authenticationBoxes(authentications)
|
||||||
|
let nowActive = boxes.first
|
||||||
|
if nowActive?.authentication != self.currentActiveUser.value?.authentication {
|
||||||
|
self.currentActiveUser.send(nowActive)
|
||||||
|
}
|
||||||
|
mastodonAuthenticationBoxes = boxes
|
||||||
persist(authentications)
|
persist(authentications)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user