2024-04-16 07:21:17 +02:00
|
|
|
//
|
|
|
|
// AppDelegate+Shared.swift
|
|
|
|
// NetNewsWire
|
|
|
|
//
|
|
|
|
// Created by Brent Simmons on 4/15/24.
|
|
|
|
// Copyright © 2024 Ranchero Software. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
import Images
|
2024-07-08 01:59:54 +02:00
|
|
|
import Account
|
2024-09-25 07:31:21 +02:00
|
|
|
import Parser
|
2024-04-16 07:21:17 +02:00
|
|
|
|
|
|
|
extension AppDelegate: FaviconDownloaderDelegate, FeedIconDownloaderDelegate {
|
|
|
|
|
|
|
|
var appIconImage: IconImage? {
|
|
|
|
IconImage.appIcon
|
|
|
|
}
|
|
|
|
|
2024-09-25 07:31:21 +02:00
|
|
|
func downloadMetadata(_ url: String) async throws -> HTMLMetadata? {
|
2024-04-16 07:21:17 +02:00
|
|
|
|
2024-05-03 21:05:53 +02:00
|
|
|
await HTMLMetadataDownloader.downloadMetadata(for: url)
|
2024-04-16 07:21:17 +02:00
|
|
|
}
|
2024-07-01 03:14:01 +02:00
|
|
|
|
|
|
|
func initializeDownloaders() {
|
|
|
|
|
|
|
|
FaviconDownloader.shared.delegate = self
|
|
|
|
FeedIconDownloader.shared.delegate = self
|
|
|
|
}
|
2024-07-03 06:43:52 +02:00
|
|
|
|
|
|
|
func handleUnreadCountDidChange() {
|
|
|
|
|
|
|
|
AppNotification.postAppUnreadCountDidChange(from: self, unreadCount: unreadCount)
|
|
|
|
postUnreadCountDidChangeNotification()
|
|
|
|
updateBadge()
|
|
|
|
}
|
|
|
|
|
|
|
|
func updateBadge() {
|
|
|
|
|
|
|
|
#if os(macOS)
|
|
|
|
queueUpdateDockBadge()
|
|
|
|
#elseif os(iOS)
|
|
|
|
UNUserNotificationCenter.current().setBadgeCount(unreadCount)
|
2024-07-08 01:59:54 +02:00
|
|
|
#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)
|
2024-07-03 06:43:52 +02:00
|
|
|
#endif
|
|
|
|
}
|
2024-04-16 07:21:17 +02:00
|
|
|
}
|