Skip to content

Commit e55e794

Browse files
author
pjechris
authored
[entity] fix use storeAlias to nullify (#69)
1 parent 055a2d2 commit e55e794

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

Sources/CohesionKit/EntityStore.swift

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ public class EntityStore {
200200
return node
201201
}
202202

203-
private func storeAlias<T>(content: T, key: AliasKey<T>, modifiedAt: Stamp?) {
203+
private func storeAlias<T>(content: T?, key: AliasKey<T>, modifiedAt: Stamp?) {
204204
let aliasNode = refAliases[safe: key, onChange: registry.enqueueChange(for:)]
205205
let aliasContainer = AliasContainer(key: key, content: content)
206206

@@ -350,29 +350,19 @@ extension EntityStore {
350350
/// Removes an alias from the storage
351351
public func removeAlias<T>(named: AliasKey<T>) {
352352
transaction {
353-
if let alias = refAliases[named] {
354-
do {
355-
try alias.updateEntity(AliasContainer(key: named, content: nil), modifiedAt: nil)
356-
logger?.didUnregisterAlias(named)
357-
}
358-
catch {
359-
360-
}
353+
if refAliases[named] != nil {
354+
storeAlias(content: nil, key: named, modifiedAt: nil)
355+
logger?.didUnregisterAlias(named)
361356
}
362357
}
363358
}
364359

365360
/// Removes an alias from the storage
366361
public func removeAlias<C: Collection>(named: AliasKey<C>) {
367362
transaction {
368-
if let alias = refAliases[named] {
369-
do {
370-
try alias.updateEntity(AliasContainer(key: named, content: nil), modifiedAt: nil)
371-
logger?.didUnregisterAlias(named)
372-
}
373-
catch {
374-
375-
}
363+
if refAliases[named] != nil {
364+
storeAlias(content: nil, key: named, modifiedAt: nil)
365+
logger?.didUnregisterAlias(named)
376366
}
377367
}
378368

0 commit comments

Comments
 (0)