|
|
|
@ -118,15 +118,25 @@ class DataStore: ObservableObject { |
|
|
|
} else if let eventsCollection: StoredCollection<Event> = notification.object as? StoredCollection<Event> { |
|
|
|
} else if let eventsCollection: StoredCollection<Event> = notification.object as? StoredCollection<Event> { |
|
|
|
self._fixMissingEventCreatorIfNecessary(eventsCollection) |
|
|
|
self._fixMissingEventCreatorIfNecessary(eventsCollection) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if Store.main.collectionsAllLoaded() { |
|
|
|
|
|
|
|
Patcher.applyAllWhenApplicable() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fileprivate func _fixMissingClubCreatorIfNecessary(_ clubsCollection: StoredCollection<Club>) { |
|
|
|
fileprivate func _fixMissingClubCreatorIfNecessary(_ clubsCollection: StoredCollection<Club>) { |
|
|
|
for club in clubsCollection { |
|
|
|
do { |
|
|
|
if let userId = StoreCenter.main.userId, club.creator == nil { |
|
|
|
for club in clubsCollection { |
|
|
|
club.creator = userId |
|
|
|
if let userId = StoreCenter.main.userId, club.creator == nil { |
|
|
|
self.userStorage.item()?.addClub(club) |
|
|
|
club.creator = userId |
|
|
|
clubsCollection.writeChangeAndInsertOnServer(instance: club) |
|
|
|
self.userStorage.item()?.addClub(club) |
|
|
|
|
|
|
|
try self.userStorage.update() |
|
|
|
|
|
|
|
clubsCollection.writeChangeAndInsertOnServer(instance: club) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} catch { |
|
|
|
|
|
|
|
Logger.error(error) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|