Ariver
2026-06-07 9f15087ff92afad0508a24d8803e8e8775359d09
Apptag/AppDefaults.swift
@@ -2,16 +2,17 @@
enum AppDefaults {
    static let schemaVersionKey = "initialDefaultsSchemaVersion"
    static let currentSchemaVersion = 2
    static let currentSchemaVersion = 3
    static let tagFontSize: Double = 22
    static let iconSize: Double = 80
    static let iconSize: Double = 64
    static let tagPosition = "right"
    static let displayMode = "coloredGridContainer"
    static let hideAppNames = true
    static let showDockIcon = true
    static let launchAtLogin = true
    static let showUncommonAppBubbles = false
    static let useAppKitTagNavigation = true
    static func register() {
        UserDefaults.standard.register(defaults: [
@@ -22,34 +23,33 @@
            "hideAppNames": hideAppNames,
            "showDockIcon": showDockIcon,
            "launchAtLogin": launchAtLogin,
            "showUncommonAppBubbles": showUncommonAppBubbles
            "showUncommonAppBubbles": showUncommonAppBubbles,
            "useAppKitTagNavigation": useAppKitTagNavigation,
            "skipTagRemovalDropConfirm": false,
            "skipUncategorizedDropConfirm": false,
            LauncherHotkeyRegistrationStore.mainStateKey: LauncherHotkeyRegistrationState.active.rawValue,
            LauncherHotkeyRegistrationStore.quickSearchStateKey: LauncherHotkeyRegistrationState.active.rawValue
        ])
        migrateShortcutDefaultsIfNeeded()
        removeShortcutCustomizationDefaults()
    }
    static func hasStoredValue(for key: String) -> Bool {
        let domain = Bundle.main.bundleIdentifier ?? "com.apptag.launcher"
        let domain = Bundle.main.bundleIdentifier ?? AppIdentity.bundleIdentifier
        return UserDefaults.standard.persistentDomain(forName: domain)?[key] != nil
    }
    private static func migrateShortcutDefaultsIfNeeded() {
    private static func removeShortcutCustomizationDefaults() {
        let defaults = UserDefaults.standard
        guard defaults.integer(forKey: schemaVersionKey) < currentSchemaVersion else { return }
        defaults.set(LauncherHotkey.defaultMain.serialized, forKey: LauncherHotkeyKind.main.storageKey)
        defaults.removeObject(forKey: LauncherHotkeyKind.main.pendingStorageKey)
        defaults.removeObject(forKey: LauncherHotkeyKind.main.statusKey)
        defaults.removeObject(forKey: LauncherHotkeyKind.main.conflictMessageKey)
        let quickSearchKey = LauncherHotkeyKind.quickSearch.storageKey
        let storedQuickSearch = defaults.string(forKey: quickSearchKey) ?? ""
        if storedQuickSearch.isEmpty {
            defaults.set(LauncherHotkey.defaultQuickSearch.serialized, forKey: quickSearchKey)
            defaults.removeObject(forKey: LauncherHotkeyKind.quickSearch.pendingStorageKey)
            defaults.removeObject(forKey: LauncherHotkeyKind.quickSearch.statusKey)
            defaults.removeObject(forKey: LauncherHotkeyKind.quickSearch.conflictMessageKey)
        }
        [
            "mainHotkey",
            "quickSearchHotkey",
            "mainHotkeyPending",
            "quickSearchHotkeyPending",
            "mainHotkeyStatus",
            "quickSearchHotkeyStatus",
            "mainHotkeyConflictMessage",
            "quickSearchHotkeyConflictMessage"
        ].forEach { defaults.removeObject(forKey: $0) }
        defaults.set(currentSchemaVersion, forKey: schemaVersionKey)
    }
}