Remove live activities

This commit is contained in:
Balazs Perlaki-Horvath 2025-04-20 11:34:07 +02:00
parent a415a669e8
commit 1a5caface9
2 changed files with 3 additions and 64 deletions

View File

@ -17,7 +17,6 @@
import SwiftUI import SwiftUI
import Combine import Combine
import UserNotifications import UserNotifications
import BackgroundTasks
import os import os
@main @main
@ -29,23 +28,14 @@ struct Kiwix: App {
@StateObject private var navigation = NavigationViewModel() @StateObject private var navigation = NavigationViewModel()
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate
private let fileMonitor: DirectoryMonitor private let fileMonitor: DirectoryMonitor
private let activityService: ActivityService?
init() { init() {
fileMonitor = DirectoryMonitor(url: URL.documentDirectory) { LibraryOperations.scanDirectory($0) } fileMonitor = DirectoryMonitor(url: URL.documentDirectory) { LibraryOperations.scanDirectory($0) }
// MARK: - live activities
switch AppType.current {
case .kiwix:
activityService = ActivityService.shared()
case .custom:
activityService = nil
}
UNUserNotificationCenter.current().delegate = appDelegate UNUserNotificationCenter.current().delegate = appDelegate
// MARK: - migrations // MARK: - migrations
if !ProcessInfo.processInfo.arguments.contains("testing") { if !ProcessInfo.processInfo.arguments.contains("testing") {
_ = MigrationService().migrateAll() _ = MigrationService().migrateAll()
} }
} }
var body: some Scene { var body: some Scene {
@ -69,7 +59,8 @@ struct Kiwix: App {
library.start(isUserInitiated: false) library.start(isUserInitiated: false)
} }
case .background: case .background:
reScheduleBackgroundDownloadTask() break
// reScheduleBackgroundDownloadTask()
@unknown default: @unknown default:
break break
} }
@ -78,14 +69,7 @@ struct Kiwix: App {
if url.isFileURL { if url.isFileURL {
NotificationCenter.openFiles([url], context: .file) NotificationCenter.openFiles([url], context: .file)
} else if url.isZIMURL { } else if url.isZIMURL {
switch url { NotificationCenter.openURL(url)
case DownloadActivityAttributes.downloadsDeepLink:
if FeatureFlags.hasLibrary {
navigation.showDownloads.send()
}
default:
NotificationCenter.openURL(url)
}
} }
} }
.task { .task {
@ -97,7 +81,6 @@ struct Kiwix: App {
LibraryOperations.scanDirectory(URL.documentDirectory) LibraryOperations.scanDirectory(URL.documentDirectory)
LibraryOperations.applyFileBackupSetting() LibraryOperations.applyFileBackupSetting()
DownloadService.shared.restartHeartbeatIfNeeded() DownloadService.shared.restartHeartbeatIfNeeded()
activityService?.start()
case let .custom(zimFileURL): case let .custom(zimFileURL):
await LibraryOperations.open(url: zimFileURL) await LibraryOperations.open(url: zimFileURL)
ZimMigration.forCustomApps() ZimMigration.forCustomApps()
@ -118,33 +101,6 @@ struct Kiwix: App {
PageZoomCommands() PageZoomCommands()
} }
} }
.backgroundTask(.appRefresh(BackgroundDownloads.identifier)) { _ in
await reScheduleBackgroundDownloadTask()
await ActivityService.shared().forceUpdate()
}
}
func reScheduleBackgroundDownloadTask() {
guard case .kiwix = AppType.current else { return }
do {
let date = BackgroundDownloads.nextDate()
let request = BGAppRefreshTaskRequest(identifier: BackgroundDownloads.identifier)
request.earliestBeginDate = date
os_log(
"BackgroundDownloads task re-scheduled for: %s",
log: Log.DownloadService,
type: .debug,
date.formatted()
)
try BGTaskScheduler.shared.submit(request)
} catch {
os_log(
"BackgroundDownloads re-schedule failed: %s",
log: Log.DownloadService,
type: .error,
error.localizedDescription
)
}
} }
private class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate { private class AppDelegate: NSObject, UIApplicationDelegate, UNUserNotificationCenterDelegate {

View File

@ -121,10 +121,6 @@ targets:
- path: Kiwix/SplashScreenKiwix.storyboard - path: Kiwix/SplashScreenKiwix.storyboard
destinationFilters: destinationFilters:
- iOS - iOS
dependencies:
- target: Widgets
destinationFilters:
- iOS
UnitTests: UnitTests:
type: bundle.unit-test type: bundle.unit-test
supportedDestinations: [iOS, macOS] supportedDestinations: [iOS, macOS]
@ -143,19 +139,6 @@ targets:
- path: Tests - path: Tests
dependencies: dependencies:
- target: Kiwix - target: Kiwix
Widgets:
type: app-extension
supportedDestinations: [iOS]
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: self.Kiwix.ioswidgets
INFOPLIST_FILE: Widgets/Info.plist
sources:
- path: Common
- path: Widgets
dependencies:
- framework: SwiftUI.framework
- framework: WidgetKit.framework
schemes: schemes:
Kiwix: Kiwix: