Fix empty collection not being loaded

sync
Laurent 1 year ago
parent bb7d00df97
commit 298dc6357f
  1. 12
      LeStorage/StoredCollection.swift

@ -154,11 +154,15 @@ public class StoredCollection<T: Storable>: RandomAccessCollection, SomeCollecti
if self.asynchronousIO {
DispatchQueue.main.async {
self._setItems(decoded)
self._setAsLoaded()
}
} else {
self._setItems(decoded)
self._setAsLoaded()
}
}
} else {
self._setAsLoaded()
}
// else if self.synchronized {
// Task {
// do {
@ -171,10 +175,14 @@ public class StoredCollection<T: Storable>: RandomAccessCollection, SomeCollecti
}
fileprivate func _setAsLoaded() {
self.hasLoadedLocally = true
NotificationCenter.default.post(name: NSNotification.Name.CollectionDidLoad, object: self)
}
fileprivate func _setItems(_ items: [T]) {
self.items = items
self._updateIndexIfNecessary()
NotificationCenter.default.post(name: NSNotification.Name.CollectionDidLoad, object: self)
}
/// Updates the whole index with the items array

Loading…
Cancel
Save