Use KeychainService.resolveDeviceID() for consistent device ID resolution across Dashboard and Snapshots views. Previously, DashboardView used Keychain-stored device ID while AppSettings defaulted to UIDevice.identifierForVendor, causing snapshots created on Dashboard to be filtered out of the Snapshots list. Now the current device is automatically selected on app init, and snapshots appear immediately after creation. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@@ -5,6 +5,7 @@ import UIKit |
||
| 5 | 5 |
final class AppSettings {
|
| 6 | 6 |
private static let selectedTypeIDsKey = "hp_selectedTypeIDs" |
| 7 | 7 |
private static let selectedDeviceIDsKey = "hp_selectedDeviceIDs" |
| 8 |
+ static let adaptiveTimeoutsEnabledKey = "hp_adaptiveTimeoutsEnabled" |
|
| 8 | 9 |
|
| 9 | 10 |
var selectedTypeIDs: Set<String> {
|
| 10 | 11 |
didSet { persistTypes() }
|
@@ -14,6 +15,12 @@ final class AppSettings {
|
||
| 14 | 15 |
didSet { persistDevices() }
|
| 15 | 16 |
} |
| 16 | 17 |
|
| 18 |
+ var adaptiveTimeoutsEnabled: Bool {
|
|
| 19 |
+ didSet {
|
|
| 20 |
+ UserDefaults.standard.set(adaptiveTimeoutsEnabled, forKey: Self.adaptiveTimeoutsEnabledKey) |
|
| 21 |
+ } |
|
| 22 |
+ } |
|
| 23 |
+ |
|
| 17 | 24 |
init() {
|
| 18 | 25 |
if let data = UserDefaults.standard.data(forKey: Self.selectedTypeIDsKey), |
| 19 | 26 |
let ids = try? JSONDecoder().decode([String].self, from: data) {
|
@@ -26,8 +33,14 @@ final class AppSettings {
|
||
| 26 | 33 |
let ids = try? JSONDecoder().decode([String].self, from: data) {
|
| 27 | 34 |
selectedDeviceIDs = Set(ids) |
| 28 | 35 |
} else {
|
| 29 |
- let currentID = UIDevice.current.identifierForVendor?.uuidString ?? "" |
|
| 30 |
- selectedDeviceIDs = currentID.isEmpty ? [] : [currentID] |
|
| 36 |
+ let currentID = KeychainService.resolveDeviceID(swiftDataStoreIsEmpty: false).id |
|
| 37 |
+ selectedDeviceIDs = [currentID] |
|
| 38 |
+ } |
|
| 39 |
+ |
|
| 40 |
+ if UserDefaults.standard.object(forKey: Self.adaptiveTimeoutsEnabledKey) == nil {
|
|
| 41 |
+ adaptiveTimeoutsEnabled = true |
|
| 42 |
+ } else {
|
|
| 43 |
+ adaptiveTimeoutsEnabled = UserDefaults.standard.bool(forKey: Self.adaptiveTimeoutsEnabledKey) |
|
| 31 | 44 |
} |
| 32 | 45 |
} |
| 33 | 46 |
|