diff --git a/Sources/CohesionKit/EntityStore.swift b/Sources/CohesionKit/EntityStore.swift index 4342961..f6398c0 100644 --- a/Sources/CohesionKit/EntityStore.swift +++ b/Sources/CohesionKit/EntityStore.swift @@ -200,7 +200,7 @@ public class EntityStore { return node } - private func storeAlias(content: T, key: AliasKey, modifiedAt: Stamp?) { + private func storeAlias(content: T?, key: AliasKey, modifiedAt: Stamp?) { let aliasNode = refAliases[safe: key, onChange: registry.enqueueChange(for:)] let aliasContainer = AliasContainer(key: key, content: content) @@ -350,14 +350,9 @@ extension EntityStore { /// Removes an alias from the storage public func removeAlias(named: AliasKey) { transaction { - if let alias = refAliases[named] { - do { - try alias.updateEntity(AliasContainer(key: named, content: nil), modifiedAt: nil) - logger?.didUnregisterAlias(named) - } - catch { - - } + if refAliases[named] != nil { + storeAlias(content: nil, key: named, modifiedAt: nil) + logger?.didUnregisterAlias(named) } } } @@ -365,14 +360,9 @@ extension EntityStore { /// Removes an alias from the storage public func removeAlias(named: AliasKey) { transaction { - if let alias = refAliases[named] { - do { - try alias.updateEntity(AliasContainer(key: named, content: nil), modifiedAt: nil) - logger?.didUnregisterAlias(named) - } - catch { - - } + if refAliases[named] != nil { + storeAlias(content: nil, key: named, modifiedAt: nil) + logger?.didUnregisterAlias(named) } }