Skip to content

Commit 499a67c

Browse files
authored
Call update even if the settings fetch fails (#390)
1 parent 55127ac commit 499a67c

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Sources/Segment/Settings.swift

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -163,26 +163,28 @@ extension Analytics {
163163
}
164164
self.store.dispatch(action: System.ToggleRunningAction(running: true))
165165
}
166-
166+
167167
return
168168
}
169169
#endif
170-
170+
171171
let writeKey = self.configuration.values.writeKey
172172
let httpClient = HTTPClient(analytics: self)
173-
173+
174174
// stop things; queue in case our settings have changed.
175175
store.dispatch(action: System.ToggleRunningAction(running: false))
176176
httpClient.settingsFor(writeKey: writeKey) { (success, settings) in
177-
if success {
178-
if let s = settings {
179-
// put the new settings in the state store.
180-
// this will cause them to be cached.
181-
self.store.dispatch(action: System.UpdateSettingsAction(settings: s))
182-
// let plugins know we just received some settings..
183-
self.update(settings: s)
184-
}
177+
if success, let s = settings {
178+
// put the new settings in the state store.
179+
// this will cause them to be cached.
180+
self.store.dispatch(action: System.UpdateSettingsAction(settings: s))
181+
}
182+
183+
// let plugins know our current settings..
184+
if let state: System = self.store.currentState(), let s = state.settings {
185+
self.update(settings: s)
185186
}
187+
186188
// we're good to go back to a running state.
187189
self.store.dispatch(action: System.ToggleRunningAction(running: true))
188190
}

0 commit comments

Comments
 (0)