From d96be97cf68f4fbe2352f78d414b3709a63803c1 Mon Sep 17 00:00:00 2001 From: shannon Date: Tue, 19 Nov 2024 10:31:18 -0500 Subject: [PATCH] Only publish new active user if it has changed, and only fetch info for current user. contributes to iOS-319 --- .../MastodonCore/AuthenticationServiceProvider.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/MastodonSDK/Sources/MastodonCore/AuthenticationServiceProvider.swift b/MastodonSDK/Sources/MastodonCore/AuthenticationServiceProvider.swift index 78095de70..86430d807 100644 --- a/MastodonSDK/Sources/MastodonCore/AuthenticationServiceProvider.swift +++ b/MastodonSDK/Sources/MastodonCore/AuthenticationServiceProvider.swift @@ -28,12 +28,12 @@ public class AuthenticationServiceProvider: ObservableObject { $mastodonAuthenticationBoxes .throttle(for: 3, scheduler: DispatchQueue.main, latest: true) .sink { [weak self] boxes in - self?.currentActiveUser.send(boxes.first) + let nowActive = boxes.first + guard nowActive?.authentication != self?.currentActiveUser.value?.authentication else { return } + self?.currentActiveUser.send(nowActive) + guard let nowActive = nowActive else { return } Task { [weak self] in - for authBox in boxes { - do { try await self?.fetchFollowedBlockedUserIds(authBox) } - catch {} - } + try await self?.fetchFollowedBlockedUserIds(nowActive) } } .store(in: &disposeBag)