mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-22 07:34:09 +01:00
Create importFeedsIfNeeded shared AppDelegate method.
This commit is contained in:
parent
44a9a52705
commit
89a967106d
@ -160,22 +160,13 @@ import Sparkle
|
||||
#endif
|
||||
|
||||
AppDefaults.shared.registerDefaults()
|
||||
let isFirstRun = AppDefaults.shared.isFirstRun
|
||||
if isFirstRun {
|
||||
if AppDefaults.shared.isFirstRun {
|
||||
os_log(.debug, "Is first run.")
|
||||
}
|
||||
|
||||
FaviconGenerator.faviconTemplateImage = AppAssets.faviconTemplateImage
|
||||
|
||||
let localAccount = AccountManager.shared.defaultAccount
|
||||
|
||||
if isFirstRun && !AccountManager.shared.anyAccountHasAtLeastOneFeed() {
|
||||
// Import feeds. Either old NNW 3 feeds or the default feeds.
|
||||
if !NNW3ImportController.importSubscriptionsIfFileExists(account: localAccount) {
|
||||
DefaultFeedsImporter.importDefaultFeeds(account: localAccount)
|
||||
}
|
||||
}
|
||||
|
||||
importFeedsIfNeeded()
|
||||
updateSortMenuItems()
|
||||
updateGroupByFeedMenuItem()
|
||||
|
||||
@ -184,7 +175,7 @@ import Sparkle
|
||||
mainWindowController.restoreStateFromUserDefaults()
|
||||
}
|
||||
|
||||
if isFirstRun {
|
||||
if AppDefaults.shared.isFirstRun {
|
||||
mainWindowController?.window?.center()
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
import Foundation
|
||||
import Images
|
||||
import ParserObjC
|
||||
import Account
|
||||
|
||||
extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
||||
|
||||
@ -40,6 +41,27 @@ extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
||||
queueUpdateDockBadge()
|
||||
#elseif os(iOS)
|
||||
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
|
||||
#endif
|
||||
}
|
||||
|
||||
func importFeedsIfNeeded() {
|
||||
|
||||
guard AppDefaults.shared.isFirstRun else {
|
||||
return
|
||||
}
|
||||
guard !AccountManager.shared.anyAccountHasAtLeastOneFeed() else {
|
||||
return
|
||||
}
|
||||
|
||||
let localAccount = AccountManager.shared.defaultAccount
|
||||
|
||||
#if os(macOS)
|
||||
// Import feeds. Either old NNW 3 feeds or the default feeds.
|
||||
if !NNW3ImportController.importSubscriptionsIfFileExists(account: localAccount) {
|
||||
DefaultFeedsImporter.importDefaultFeeds(account: localAccount)
|
||||
}
|
||||
#elseif os(iOS)
|
||||
DefaultFeedsImporter.importDefaultFeeds(account: localAccount)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -64,20 +64,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
||||
}
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
|
||||
AppDefaults.registerDefaults()
|
||||
if AppDefaults.shared.isFirstRun {
|
||||
os_log(.debug, "Is first run.")
|
||||
}
|
||||
|
||||
let isFirstRun = AppDefaults.shared.isFirstRun
|
||||
if isFirstRun {
|
||||
os_log("Is first run.", log: log, type: .info)
|
||||
}
|
||||
|
||||
if isFirstRun && !AccountManager.shared.anyAccountHasAtLeastOneFeed() {
|
||||
let localAccount = AccountManager.shared.defaultAccount
|
||||
DefaultFeedsImporter.importDefaultFeeds(account: localAccount)
|
||||
}
|
||||
|
||||
FaviconGenerator.faviconTemplateImage = AppAssets.faviconTemplateImage
|
||||
|
||||
importFeedsIfNeeded()
|
||||
|
||||
registerBackgroundTasks()
|
||||
CacheCleaner.purgeIfNecessary()
|
||||
initializeDownloaders()
|
||||
|
Loading…
Reference in New Issue
Block a user