mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-03 13:30:14 +01:00
Create importFeedsIfNeeded shared AppDelegate method.
This commit is contained in:
parent
44a9a52705
commit
89a967106d
@ -160,22 +160,13 @@ import Sparkle
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
AppDefaults.shared.registerDefaults()
|
AppDefaults.shared.registerDefaults()
|
||||||
let isFirstRun = AppDefaults.shared.isFirstRun
|
if AppDefaults.shared.isFirstRun {
|
||||||
if isFirstRun {
|
|
||||||
os_log(.debug, "Is first run.")
|
os_log(.debug, "Is first run.")
|
||||||
}
|
}
|
||||||
|
|
||||||
FaviconGenerator.faviconTemplateImage = AppAssets.faviconTemplateImage
|
FaviconGenerator.faviconTemplateImage = AppAssets.faviconTemplateImage
|
||||||
|
|
||||||
let localAccount = AccountManager.shared.defaultAccount
|
importFeedsIfNeeded()
|
||||||
|
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateSortMenuItems()
|
updateSortMenuItems()
|
||||||
updateGroupByFeedMenuItem()
|
updateGroupByFeedMenuItem()
|
||||||
|
|
||||||
@ -184,7 +175,7 @@ import Sparkle
|
|||||||
mainWindowController.restoreStateFromUserDefaults()
|
mainWindowController.restoreStateFromUserDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
if isFirstRun {
|
if AppDefaults.shared.isFirstRun {
|
||||||
mainWindowController?.window?.center()
|
mainWindowController?.window?.center()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import Images
|
import Images
|
||||||
import ParserObjC
|
import ParserObjC
|
||||||
|
import Account
|
||||||
|
|
||||||
extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
||||||
|
|
||||||
@ -40,6 +41,27 @@ extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
|||||||
queueUpdateDockBadge()
|
queueUpdateDockBadge()
|
||||||
#elseif os(iOS)
|
#elseif os(iOS)
|
||||||
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
|
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
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,20 +64,16 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
|
|||||||
}
|
}
|
||||||
|
|
||||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||||
|
|
||||||
AppDefaults.registerDefaults()
|
AppDefaults.registerDefaults()
|
||||||
|
if AppDefaults.shared.isFirstRun {
|
||||||
let isFirstRun = AppDefaults.shared.isFirstRun
|
os_log(.debug, "Is first run.")
|
||||||
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
|
FaviconGenerator.faviconTemplateImage = AppAssets.faviconTemplateImage
|
||||||
|
|
||||||
|
importFeedsIfNeeded()
|
||||||
|
|
||||||
registerBackgroundTasks()
|
registerBackgroundTasks()
|
||||||
CacheCleaner.purgeIfNecessary()
|
CacheCleaner.purgeIfNecessary()
|
||||||
initializeDownloaders()
|
initializeDownloaders()
|
||||||
|
Loading…
Reference in New Issue
Block a user