Skip to content

Commit

Permalink
Merge pull request #4563 from wikimedia/fix-on-this-day-widget
Browse files Browse the repository at this point in the history
Add asynchronous setup call to fix the on this day widget
  • Loading branch information
staykids authored Jul 11, 2023
2 parents 5ad929e + 7ae8a39 commit d4cbf58
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions WMF Framework/Widget/WidgetController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ public final class WidgetController: NSObject {
isCreatingDataStore = true
backgroundActivity = ProcessInfo.processInfo.beginActivity(options: [.background, .suddenTerminationDisabled, .automaticTerminationDisabled], reason: "Wikipedia Extension - " + UUID().uuidString)
let dataStore = MWKDataStore()
dataStore.performLibraryUpdates {
DispatchQueue.main.async {
self._dataStore = dataStore
self.isCreatingDataStore = false
self.completions.forEach { $0(dataStore) }
self.completions.removeAll()
dataStore.finishSetup {
dataStore.performLibraryUpdates {
DispatchQueue.main.async {
self._dataStore = dataStore
self.isCreatingDataStore = false
self.completions.forEach { $0(dataStore) }
self.completions.removeAll()
}
}
}
}
Expand Down

0 comments on commit d4cbf58

Please sign in to comment.