Recude task-nestedness (IOS-192)

This commit is contained in:
Nathan Mattes 2024-02-20 12:04:44 +01:00
parent 22b9e912f6
commit 897fc0d348
1 changed files with 66 additions and 73 deletions

View File

@ -51,8 +51,8 @@ final public class SceneCoordinator {
.receive(on: DispatchQueue.main)
.sink(receiveValue: {
[weak self] pushNotification in
guard let self = self else { return }
Task {
guard let self else { return }
Task { @MainActor in
guard let currentActiveAuthenticationBox = self.authContext?.mastodonAuthenticationBox else { return }
let accessToken = pushNotification.accessToken // use raw accessToken value without normalize
if currentActiveAuthenticationBox.userAuthorization.accessToken == accessToken {
@ -75,10 +75,6 @@ final public class SceneCoordinator {
// redirect to notifications tab
self.switchToTabBar(tab: .notifications)
// Delay in next run loop
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
// Note:
// show (push) on phone and pad
let from: UIViewController? = {
@ -103,7 +99,6 @@ final public class SceneCoordinator {
switch type {
case .follow:
Task {
let account = try await appContext.apiService.notification(
notificationID: notificationID,
authenticationBox: authContext.mastodonAuthenticationBox
@ -123,7 +118,6 @@ final public class SceneCoordinator {
from: from,
transition: .show
)
}
case .followRequest:
// do nothing
break
@ -143,7 +137,6 @@ final public class SceneCoordinator {
assertionFailure()
break
}
} // end DispatchQueue.main.async
} catch {
assertionFailure(error.localizedDescription)