Create importFeedsIfNeeded shared AppDelegate method.

This commit is contained in:
Brent Simmons
2024-07-07 16:59:54 -07:00
parent 44a9a52705
commit 89a967106d
3 changed files with 31 additions and 22 deletions

View File

@@ -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
}
}