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

Always update shortcuts on app launch #2248

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Classes/Systems/AppRouter/AppController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class AppController: LoginSplashViewControllerDelegate, GitHubSessionListe
}
splitViewController = controller

resetShortcuts()
if let focused = sessionManager.focusedUserSession {
resetViewControllers(userSession: focused)
resetWatchSync(userSession: focused)
Expand Down Expand Up @@ -83,6 +84,10 @@ final class AppController: LoginSplashViewControllerDelegate, GitHubSessionListe
watchAppSync?.start()
}

private func resetShortcuts() {
ShortcutHandler.configure(sessionUsernames: sessionManager.userSessions.compactMap { $0.username })
}

private func resetViewControllers(userSession: GitHubUserSession) {
let appClient = GithubClient(userSession: userSession)
self.appClient = appClient
Expand Down Expand Up @@ -140,7 +145,7 @@ final class AppController: LoginSplashViewControllerDelegate, GitHubSessionListe
splitViewController.presentedViewController?.dismiss(animated: trueUnlessReduceMotionEnabled)
}

ShortcutHandler.configure(sessionUsernames: manager.userSessions.compactMap { $0.username })
resetShortcuts()
if let watch = watchAppSync {
watch.sync(userSession: userSession)
} else {
Expand Down
2 changes: 2 additions & 0 deletions Classes/Systems/ShortcutHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct ShortcutHandler {
}

private static func generateItems(sessionUsernames: [String]) -> [UIApplicationShortcutItem] {
guard sessionUsernames.count > 0 else { return [] }

var items = [
UIApplicationShortcutItem.from(
route: SearchShortcutRoute(),
Expand Down