parent
6d36f7b21e
commit
5e7f0eec86
@ -0,0 +1,52 @@ |
||||
// |
||||
// Patcher.swift |
||||
// PadelClub |
||||
// |
||||
// Created by Laurent Morvillier on 21/06/2024. |
||||
// |
||||
|
||||
import Foundation |
||||
import LeStorage |
||||
|
||||
enum Patch: String, CaseIterable { |
||||
case alexisLeDu |
||||
|
||||
var id: String { |
||||
return "padelclub.app.patch.\(self.rawValue)" |
||||
} |
||||
} |
||||
|
||||
class Patcher { |
||||
|
||||
static func applyIfNeeded() { |
||||
for patch in Patch.allCases { |
||||
if UserDefaults.standard.value(forKey: patch.id) == nil { |
||||
self._applyPatch(patch) |
||||
UserDefaults.standard.setValue(true, forKey: patch.id) |
||||
} |
||||
} |
||||
} |
||||
|
||||
fileprivate static func _applyPatch(_ patch: Patch) { |
||||
switch patch { |
||||
case .alexisLeDu: self._patchAlexisLeDu() |
||||
} |
||||
} |
||||
|
||||
fileprivate static func _patchAlexisLeDu() { |
||||
guard Store.main.userId == "94f45ed2-8938-4c32-a4b6-e4525073dd33" else { return } |
||||
|
||||
Logger.log(">>> Start patch...") |
||||
|
||||
let clubs = DataStore.shared.clubs |
||||
|
||||
clubs.resetApiCalls() |
||||
|
||||
for club in clubs.filter({ $0.creator == "d5060b89-e979-4c19-bf78-e459a6ed5318"}) { |
||||
club.creator = Store.main.userId |
||||
clubs.writeChangeAndInsertOnServer(instance: club) |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
||||
Loading…
Reference in new issue