Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit caf86a5

Browse files
authored
Always update shortcuts on app launch (#2248)
1 parent b2d5b5f commit caf86a5

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Classes/Systems/AppRouter/AppController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ final class AppController: LoginSplashViewControllerDelegate, GitHubSessionListe
3030
}
3131
splitViewController = controller
3232

33+
resetShortcuts()
3334
if let focused = sessionManager.focusedUserSession {
3435
resetViewControllers(userSession: focused)
3536
resetWatchSync(userSession: focused)
@@ -83,6 +84,10 @@ final class AppController: LoginSplashViewControllerDelegate, GitHubSessionListe
8384
watchAppSync?.start()
8485
}
8586

87+
private func resetShortcuts() {
88+
ShortcutHandler.configure(sessionUsernames: sessionManager.userSessions.compactMap { $0.username })
89+
}
90+
8691
private func resetViewControllers(userSession: GitHubUserSession) {
8792
let appClient = GithubClient(userSession: userSession)
8893
self.appClient = appClient
@@ -140,7 +145,7 @@ final class AppController: LoginSplashViewControllerDelegate, GitHubSessionListe
140145
splitViewController.presentedViewController?.dismiss(animated: trueUnlessReduceMotionEnabled)
141146
}
142147

143-
ShortcutHandler.configure(sessionUsernames: manager.userSessions.compactMap { $0.username })
148+
resetShortcuts()
144149
if let watch = watchAppSync {
145150
watch.sync(userSession: userSession)
146151
} else {

Classes/Systems/ShortcutHandler.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ struct ShortcutHandler {
4545
}
4646

4747
private static func generateItems(sessionUsernames: [String]) -> [UIApplicationShortcutItem] {
48+
guard sessionUsernames.count > 0 else { return [] }
49+
4850
var items = [
4951
UIApplicationShortcutItem.from(
5052
route: SearchShortcutRoute(),

0 commit comments

Comments
 (0)