Fix ObjectBox connections DB to properly handle adds which shouldn't replace

merge-requests/67/merge
Hank Grabowski 2023-01-31 16:41:40 -05:00
rodzic 525b27c73e
commit 5b85fe27e3
1 zmienionych plików z 8 dodań i 5 usunięć

Wyświetl plik

@ -24,15 +24,18 @@ class ObjectBoxConnectionsRepo implements IConnectionsRepo {
@override
bool addAllConnections(Iterable<Connection> newConnections) {
memCache.addAllConnections(newConnections);
final result = box.putMany(newConnections.toList());
return result.length == newConnections.length;
var allNew = true;
for (final c in newConnections) {
allNew &= addConnection(c);
}
return allNew;
}
@override
bool addConnection(Connection connection) {
memCache.addConnection(connection);
box.putAsync(connection);
if (memCache.addConnection(connection)) {
box.putAsync(connection);
}
return true;
}