@@ -66,7 +66,7 @@ final class AnonymousAccountStorage {
66
66
// meaning the one that was created earliest. The design of this class is to eventually resolve out
67
67
// to the earliest account across multiple devices.
68
68
if !AIProxyStorage. ukvsSync ( ) {
69
- if ll ( . error) { aiproxyLogger . error ( " Could not synchronize NSUbiquitousKeyValueStore. Please ensure you enabled the key/value store in Target > Signing & Capabilities > iCloud > Key-Value storage? " ) }
69
+ logIf ( . error) ? . error ( " Could not synchronize NSUbiquitousKeyValueStore. Please ensure you enabled the key/value store in Target > Signing & Capabilities > iCloud > Key-Value storage? " )
70
70
}
71
71
if let ukvsAccountData = AIProxyStorage . ukvsAccountData ( ) {
72
72
let ukvsAccount = try AnonymousAccount . deserialize ( from: ukvsAccountData)
@@ -78,7 +78,7 @@ final class AnonymousAccountStorage {
78
78
localAccount = ukvsAccount
79
79
self . localAccountChain. append ( ukvsAccount)
80
80
if try await AIProxyStorage . updateLocalAccountChainInKeychain ( self . localAccountChain) != noErr {
81
- if ll ( . warning) { aiproxyLogger . warning ( " Could not update the local account chain " ) }
81
+ logIf ( . warning) ? . warning ( " Could not update the local account chain " )
82
82
}
83
83
} else {
84
84
try AIProxyStorage . updateUKVS ( localAccount)
@@ -108,17 +108,17 @@ final class AnonymousAccountStorage {
108
108
localAccount = remoteAccount
109
109
self . localAccountChain. append ( remoteAccount)
110
110
if try await AIProxyStorage . updateLocalAccountChainInKeychain ( self . localAccountChain) != noErr {
111
- if ll ( . warning) { aiproxyLogger . warning ( " Could not update the local account chain " ) }
111
+ logIf ( . warning) ? . warning ( " Could not update the local account chain " )
112
112
}
113
113
try AIProxyStorage . updateUKVS ( localAccount)
114
114
} else {
115
115
if try await AIProxyStorage . updateRemoteAccountInKeychain ( localAccount) != noErr {
116
- if ll ( . warning) { aiproxyLogger . warning ( " Could not update the remote account " ) }
116
+ logIf ( . warning) ? . warning ( " Could not update the remote account " )
117
117
}
118
118
}
119
119
}
120
120
} else {
121
- if ll ( . warning) { aiproxyLogger . warning ( " Keychain cloud sync claims that there is a duplicate item, but we can't fetch it. " ) }
121
+ logIf ( . warning) ? . warning ( " Keychain cloud sync claims that there is a duplicate item, but we can't fetch it. " )
122
122
}
123
123
}
124
124
@@ -129,8 +129,8 @@ final class AnonymousAccountStorage {
129
129
name: NSUbiquitousKeyValueStore . didChangeExternallyNotification,
130
130
object: NSUbiquitousKeyValueStore . default)
131
131
132
- if ll ( . debug) { aiproxyLogger . debug ( " Local account chain is \( localAccountChain) " ) }
133
- if ll ( . debug) { aiproxyLogger . debug ( " Anonymous account identifier is \( self . resolvedAccount? . uuid ?? " unknown " ) " ) }
132
+ logIf ( . debug) ? . debug ( " Local account chain is \( localAccountChain) " )
133
+ logIf ( . debug) ? . debug ( " Anonymous account identifier is \( self . resolvedAccount? . uuid ?? " unknown " ) " )
134
134
135
135
return localAccount. uuid
136
136
}
@@ -154,10 +154,10 @@ final class AnonymousAccountStorage {
154
154
}
155
155
156
156
switch changeReason. intValue {
157
- case NSUbiquitousKeyValueStoreServerChange: if ll ( . info) { aiproxyLogger . info ( " AIProxy account changed due to remote server change " ) }
158
- case NSUbiquitousKeyValueStoreInitialSyncChange: if ll ( . info) { aiproxyLogger . info ( " AIProxy account changed due to initial sync change " ) }
159
- case NSUbiquitousKeyValueStoreQuotaViolationChange: if ll ( . info) { aiproxyLogger . info ( " AIProxy account changed due to quota violation " ) }
160
- case NSUbiquitousKeyValueStoreAccountChange: if ll ( . info) { aiproxyLogger . info ( " AIProxy account changed due to icloud account change " ) }
157
+ case NSUbiquitousKeyValueStoreServerChange: logIf ( . info) ? . info ( " AIProxy account changed due to remote server change " )
158
+ case NSUbiquitousKeyValueStoreInitialSyncChange: logIf ( . info) ? . info ( " AIProxy account changed due to initial sync change " )
159
+ case NSUbiquitousKeyValueStoreQuotaViolationChange: logIf ( . info) ? . info ( " AIProxy account changed due to quota violation " )
160
+ case NSUbiquitousKeyValueStoreAccountChange: logIf ( . info) ? . info ( " AIProxy account changed due to icloud account change " )
161
161
default :
162
162
return
163
163
}
@@ -172,12 +172,12 @@ final class AnonymousAccountStorage {
172
172
}
173
173
174
174
guard ukvsAccount != resolvedAccount else {
175
- if ll ( . info) { aiproxyLogger . info ( " UKVS remote sync is already up to date " ) }
175
+ logIf ( . info) ? . info ( " UKVS remote sync is already up to date " )
176
176
return
177
177
}
178
178
179
179
if ukvsAccount. timestamp <= resolvedAccount. timestamp {
180
- if ll ( . info) { aiproxyLogger . info ( " UKVS account is older than our existing resolved account. Switching to the older account. " ) }
180
+ logIf ( . info) ? . info ( " UKVS account is older than our existing resolved account. Switching to the older account. " )
181
181
self . resolvedAccount = ukvsAccount
182
182
self . localAccountChain. append ( ukvsAccount)
183
183
DispatchQueue . main. async {
@@ -187,16 +187,16 @@ final class AnonymousAccountStorage {
187
187
Task . detached {
188
188
let updateLocal = try ? await AIProxyStorage . updateLocalAccountChainInKeychain ( self . localAccountChain)
189
189
if updateLocal == nil || updateLocal! != noErr {
190
- if ll ( . warning) { aiproxyLogger . warning ( " Could not update the local account chain " ) }
190
+ logIf ( . warning) ? . warning ( " Could not update the local account chain " )
191
191
}
192
192
193
193
let updateRemote = try ? await AIProxyStorage . updateRemoteAccountInKeychain ( ukvsAccount)
194
194
if updateRemote == nil || updateRemote! != noErr {
195
- if ll ( . warning) { aiproxyLogger . warning ( " Could not update the remote account " ) }
195
+ logIf ( . warning) ? . warning ( " Could not update the remote account " )
196
196
}
197
197
}
198
198
} else {
199
- if ll ( . info) { aiproxyLogger . info ( " UKVS account is newer than our existing resolved account. Updating UKVS to use the older account. " ) }
199
+ logIf ( . info) ? . info ( " UKVS account is newer than our existing resolved account. Updating UKVS to use the older account. " )
200
200
try ? AIProxyStorage . updateUKVS ( resolvedAccount)
201
201
}
202
202
}
0 commit comments