1
0
mirror of https://github.com/mastodon/mastodon-ios.git synced 2025-02-03 02:37:37 +01:00

Recude task-nestedness (IOS-192)

This commit is contained in:
Nathan Mattes 2024-02-20 12:04:44 +01:00
parent 22b9e912f6
commit 897fc0d348

View File

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