Files
omnivore/apple/OmnivoreKit/Sources/App/Views/RootView/RootViewModel.swift
2023-10-06 17:19:50 +08:00

58 lines
1.5 KiB
Swift

import Foundation
import Models
import Services
import SwiftUI
import Utils
import Views
#if os(iOS)
let isMacApp = false
#elseif os(macOS)
let isMacApp = true
#endif
public final class RootViewModel: ObservableObject {
let services = Services()
@Published public var showNewFeaturePrimer = false
@AppStorage(UserDefaultKey.shouldShowNewFeaturePrimer.rawValue) var shouldShowNewFeaturePrimer = false
public init() {
registerFonts()
if let viewer = services.dataService.currentViewer {
EventTracker.registerUser(userID: viewer.unwrappedUserID)
}
services.dataService.cleanupDeletedItems(in: services.dataService.viewContext)
#if DEBUG
if CommandLine.arguments.contains("--uitesting") {
services.authenticator.logout(dataService: services.dataService)
}
#endif
}
#if os(iOS)
func handlePushNotificationPrimerAcceptance() {
// UNUserNotificationCenter.current().requestAuth()
}
#endif
}
public struct IntercomProvider {
public init(
registerIntercomUser: @escaping (String) -> Void,
unregisterIntercomUser: @escaping () -> Void,
showIntercomMessenger: @escaping () -> Void
) {
self.registerIntercomUser = registerIntercomUser
self.unregisterIntercomUser = unregisterIntercomUser
self.showIntercomMessenger = showIntercomMessenger
}
public let registerIntercomUser: (String) -> Void
public let unregisterIntercomUser: () -> Void
public let showIntercomMessenger: () -> Void
}