mirror of
https://github.com/yattee/yattee.git
synced 2025-11-22 22:51:21 +00:00
Fix tab selection timing to wait for account sign-in
Tab selection was being set immediately during app configuration, before the user account had completed sign-in. This caused tabs that require authentication (like Subscriptions and Playlists) to not be properly selected on startup since they weren't visible yet. Changes: - Add notification system for account configuration completion - Post notification after all account types finish configuration: * Accounts with existing tokens * Accounts requiring sign-in (after network request completes) * Anonymous/public accounts * Error cases (missing credentials, network failures) - Set up observer before account configuration to ensure notification is received - Set tab selection only when account is fully configured
This commit is contained in:
@@ -152,6 +152,10 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
FeedModel.shared.onAccountChange()
|
||||
SubscribedChannelsModel.shared.onAccountChange()
|
||||
PlaylistsModel.shared.onAccountChange()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +164,9 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
guard !account.anonymous,
|
||||
(account.token?.isEmpty ?? true) || force
|
||||
else {
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -172,6 +179,9 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
title: "Account Error",
|
||||
message: "Remove and add your account again in Settings."
|
||||
)
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -212,6 +222,8 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
}
|
||||
|
||||
self.configure()
|
||||
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,6 +174,9 @@ final class PeerTubeAPI: Service, ObservableObject, VideosAPI {
|
||||
guard !account.anonymous,
|
||||
(account.token?.isEmpty ?? true) || force
|
||||
else {
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -186,6 +189,9 @@ final class PeerTubeAPI: Service, ObservableObject, VideosAPI {
|
||||
title: "Account Error",
|
||||
message: "Remove and add your account again in Settings."
|
||||
)
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -194,6 +200,7 @@ final class PeerTubeAPI: Service, ObservableObject, VideosAPI {
|
||||
title: "Account Error",
|
||||
message: message ?? "\(response?.response?.statusCode ?? -1) - \(response?.error?.errorDescription ?? "unknown")\nIf this issue persists, try removing and adding your account again in Settings."
|
||||
)
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
|
||||
AF
|
||||
@@ -226,6 +233,8 @@ final class PeerTubeAPI: Service, ObservableObject, VideosAPI {
|
||||
}
|
||||
|
||||
self.configure()
|
||||
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +135,10 @@ final class PipedAPI: Service, ObservableObject, VideosAPI {
|
||||
FeedModel.shared.onAccountChange()
|
||||
SubscribedChannelsModel.shared.onAccountChange()
|
||||
PlaylistsModel.shared.onAccountChange()
|
||||
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,6 +153,9 @@ final class PipedAPI: Service, ObservableObject, VideosAPI {
|
||||
let username,
|
||||
let password
|
||||
else {
|
||||
DispatchQueue.main.async {
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -184,11 +191,14 @@ final class PipedAPI: Service, ObservableObject, VideosAPI {
|
||||
|
||||
self.configure()
|
||||
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
|
||||
case let .failure(error):
|
||||
NavigationModel.shared.presentAlert(
|
||||
title: "Account Error",
|
||||
message: error.localizedDescription
|
||||
)
|
||||
NotificationCenter.default.post(name: .accountConfigurationComplete, object: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user