sync3
Laurent 6 months ago
parent 7ce71a4921
commit d70c649fc2
  1. 11
      LeStorage/StoreCenter.swift

@ -20,7 +20,7 @@ public class StoreCenter {
fileprivate var _stores: [String: Store] = [:] fileprivate var _stores: [String: Store] = [:]
/// Returns a default Store instance /// Returns a default Store instance
lazy var mainStore: Store = { Store(storeCenter: self) }() public lazy var mainStore: Store = { Store(storeCenter: self) }()
/// A KeychainStore object used to store the user's token /// A KeychainStore object used to store the user's token
var tokenKeychain: KeychainService? = nil var tokenKeychain: KeychainService? = nil
@ -706,12 +706,13 @@ public class StoreCenter {
fileprivate func _syncRevoke(_ revokeArrays: [ObjectIdentifierArray]) { fileprivate func _syncRevoke(_ revokeArrays: [ObjectIdentifierArray]) {
Task {
for revokeArray in revokeArrays { for revokeArray in revokeArrays {
for revoked in revokeArray.items { for revoked in revokeArray.items {
self.synchronizationRevoke(id: revoked.modelId, type: revokeArray.type, storeId: revoked.storeId) await self.synchronizationRevoke(id: revoked.modelId, type: revokeArray.type, storeId: revoked.storeId)
}
} }
} }
} }
/// Returns a Type object for a class name /// Returns a Type object for a class name
@ -772,11 +773,10 @@ public class StoreCenter {
} }
/// Revokes a data that has been shared with the user /// Revokes a data that has been shared with the user
@MainActor
func synchronizationRevoke<T: SyncedStorable>(id: String, type: T.Type, storeId: String?) { func synchronizationRevoke<T: SyncedStorable>(id: String, type: T.Type, storeId: String?) {
DispatchQueue.main.async {
do { do {
// let type = try self.classFromName(model)
if self._instanceShared(id: id, type: type) { if self._instanceShared(id: id, type: type) {
let count = self.mainStore.referenceCount(type: type, id: id) let count = self.mainStore.referenceCount(type: type, id: id)
if count == 0 { if count == 0 {
@ -787,7 +787,6 @@ public class StoreCenter {
Logger.error(error) Logger.error(error)
} }
} }
}
/// Returns whether an instance has been shared with the user /// Returns whether an instance has been shared with the user
fileprivate func _instanceShared<T: SyncedStorable>(id: String, type: T.Type) -> Bool { fileprivate func _instanceShared<T: SyncedStorable>(id: String, type: T.Type) -> Bool {

Loading…
Cancel
Save