Skip to content

Commit ce83a11

Browse files
authored
fix(swift): wait for api key helper update operation (#3340)
1 parent 5761ef5 commit ce83a11

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

clients/algoliasearch-client-swift/Sources/Search/Extra/SearchClientExtension.swift

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,23 @@ public extension SearchClient {
126126
try await self.getApiKey(key: key, requestOptions: requestOptions)
127127
},
128128
validate: { response in
129-
if apiKey.description != nil, apiKey.description != response.description {
129+
if apiKey.description != response.description {
130130
return false
131131
}
132132

133-
if apiKey.queryParameters != nil, apiKey.queryParameters != response.queryParameters {
133+
if apiKey.queryParameters != response.queryParameters {
134134
return false
135135
}
136136

137-
if apiKey.maxHitsPerQuery != nil, apiKey.maxHitsPerQuery != response.maxHitsPerQuery {
137+
if apiKey.maxHitsPerQuery != response.maxHitsPerQuery {
138138
return false
139139
}
140140

141-
if apiKey.maxQueriesPerIPPerHour != nil,
142-
apiKey.maxQueriesPerIPPerHour != response.maxQueriesPerIPPerHour {
141+
if apiKey.maxQueriesPerIPPerHour != response.maxQueriesPerIPPerHour {
143142
return false
144143
}
145144

146-
if apiKey.validity != nil, apiKey.validity != response.validity {
145+
if apiKey.validity != response.validity {
147146
return false
148147
}
149148

@@ -153,20 +152,16 @@ public extension SearchClient {
153152
return false
154153
}
155154

156-
if let apiKeyIndexes = apiKey.indexes {
157-
let expectedIndexes = apiKeyIndexes.sorted { $0 > $1 }
158-
let responseIndexes = response.indexes?.sorted { $0 > $1 }
159-
if expectedIndexes != responseIndexes {
160-
return false
161-
}
155+
let expectedIndexes = apiKey.indexes?.sorted { $0 > $1 }
156+
let responseIndexes = response.indexes?.sorted { $0 > $1 }
157+
if expectedIndexes != responseIndexes {
158+
return false
162159
}
163160

164-
if let apiKeyReferers = apiKey.referers {
165-
let expectedReferers = apiKeyReferers.sorted { $0 > $1 }
166-
let responseReferers = response.referers?.sorted { $0 > $1 }
167-
if expectedReferers != responseReferers {
168-
return false
169-
}
161+
let expectedReferers = apiKey.referers?.sorted { $0 > $1 }
162+
let responseReferers = response.referers?.sorted { $0 > $1 }
163+
if expectedReferers != responseReferers {
164+
return false
170165
}
171166

172167
return true

0 commit comments

Comments
 (0)