mirror of
https://github.com/sudosylabs/vnidrop.git
synced 2026-08-05 10:29:58 +02:00
Adds background notifications for the "the thing you were waiting for is
done" moments, alongside the existing incoming-approval-request one:
- a receive finished downloading (receive -> done)
- a receive failed / was interrupted (receive -> failed)
- a share you own failed (send -> failed)
- a receiver finished downloading your share (receiver status completed)
A new TransferNotificationCoordinator observes core state + signals and
publishes these; the decision of which moments notify is a pure function
(plannedTransferNotifications / plannedReceiverNotifications), unit-tested
independently. The first state snapshot only primes existing history as seen
so launch doesn't spam.
Notification permission is now the single source of truth. The in-app
notifications toggle and its decoupled UserDefaults preference are gone;
the Settings section shows an "Allow notifications" button that requests the
OS permission (or deep-links to Settings once decided), and notifications
gate purely on `permission == .granted`.
macOS delivery fixes:
- add a UNUserNotificationCenterDelegate so banners present even while the
app is active (the app window is usually open on macOS)
- present-when-active on macOS, suppress-when-foregrounded on iOS
- reserve the notification id before awaiting publish: the CombineLatest
fired several times and re-added the same identifier, which macOS
coalesces into a silent update with no banner
- LocalNotificationService seeds its permission at init so gating can't
race a not-yet-refreshed .notDetermined
Eight localized title/body strings added (apple-only); the shared
notifications_description copy is generalized from "receive requests" to
"transfer activity".
49 lines
1.7 KiB
Swift
49 lines
1.7 KiB
Swift
import Foundation
|
|
import Combine
|
|
|
|
/// Object graph wiring the repositories and coordinators together, ported from
|
|
/// `AppGraph.kt`. Owned by the app root for the process lifetime.
|
|
@MainActor
|
|
final class AppGraph: ObservableObject {
|
|
let dependencies: AppDependencies
|
|
let coreRepository: CoreRepository
|
|
let visibility = AppVisibility()
|
|
let messages = UiMessageController()
|
|
let preferencesRepository: AppPreferencesRepository
|
|
let filePreviewRepository: FilePreviewRepository
|
|
let approvalCoordinator: ApprovalCoordinator
|
|
let transferNotificationCoordinator: TransferNotificationCoordinator
|
|
|
|
init(dependencies: AppDependencies, coreRepository: CoreRepository? = nil) {
|
|
self.dependencies = dependencies
|
|
let coreRepository = coreRepository ?? CoreRepository()
|
|
self.coreRepository = coreRepository
|
|
self.filePreviewRepository = FilePreviewRepository(appDataDir: dependencies.environment.defaultCoreDataDir)
|
|
self.preferencesRepository = AppPreferencesRepository(
|
|
fallback: AppPreferencesDefaults(
|
|
username: dependencies.environment.defaultUsername,
|
|
receiveFolder: dependencies.fileSystemService.defaultReceiveFolder(),
|
|
themeMode: .system,
|
|
diagnosticsEnabled: false
|
|
)
|
|
)
|
|
self.approvalCoordinator = ApprovalCoordinator(
|
|
repository: coreRepository,
|
|
notifications: dependencies.notificationService,
|
|
visibility: visibility,
|
|
messages: messages
|
|
)
|
|
self.transferNotificationCoordinator = TransferNotificationCoordinator(
|
|
repository: coreRepository,
|
|
notifications: dependencies.notificationService,
|
|
visibility: visibility,
|
|
messages: messages
|
|
)
|
|
AppLogger.info("lifecycle", "graph created", ["platform": dependencies.environment.name])
|
|
}
|
|
|
|
func close() {
|
|
coreRepository.shutdown()
|
|
}
|
|
}
|