Fix club not being added to the user after setting the creator

multistore
Laurent 1 year ago
parent 5bf7785300
commit 6d36f7b21e
  1. 1
      PadelClub/Data/DataStore.swift
  2. 6
      PadelClub/Data/User.swift

@ -141,6 +141,7 @@ class DataStore: ObservableObject {
for club in clubsCollection {
if let userId = Store.main.userId, club.creator == nil {
club.creator = userId
self.userStorage.item()?.addClub(club)
clubsCollection.writeChangeAndInsertOnServer(instance: club)
}
}

@ -102,6 +102,12 @@ class User: ModelObject, UserBase, Storable {
}
}
func addClub(_ club: Club) {
if !self.clubs.contains(where: { $0.id == club.id }) {
self.clubs.append(club.id)
}
}
enum CodingKeys: String, CodingKey {
case _id = "id"
case _username = "username"

Loading…
Cancel
Save