Skip to content

Commit

Permalink
Removed setMetadata worker function in favour of setBulkMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
JaffaKetchup committed Jul 20, 2024
1 parent 2bb3db6 commit 9102680
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 32 deletions.
7 changes: 5 additions & 2 deletions lib/src/backend/impls/objectbox/backend/internal.dart
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,11 @@ class _ObjectBoxBackendImpl implements FMTCObjectBoxBackendInternal {
required String value,
}) =>
_sendCmdOneShot(
type: _CmdType.setMetadata,
args: {'storeName': storeName, 'key': key, 'value': value},
type: _CmdType.setBulkMetadata,
args: {
'storeName': storeName,
'kvs': {key: value},
},
);

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ enum _CmdType {
removeOldestTilesAboveLimit,
removeTilesOlderThan,
readMetadata,
setMetadata,
setBulkMetadata,
removeMetadata,
resetMetadata,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,35 +659,6 @@ Future<void> _worker(
);

query.close();
case _CmdType.setMetadata:
final storeName = cmd.args['storeName']! as String;
final key = cmd.args['key']! as String;
final value = cmd.args['value']! as String;

final stores = root.box<ObjectBoxStore>();

final query =
stores.query(ObjectBoxStore_.name.equals(storeName)).build();

root.runInTransaction(
TxMode.write,
() {
final store = query.findUnique() ??
(throw StoreNotExists(storeName: storeName));
query.close();

stores.put(
store
..metadataJson = jsonEncode(
(jsonDecode(store.metadataJson) as Map<String, dynamic>)
..[key] = value,
),
mode: PutMode.update,
);
},
);

sendRes(id: cmd.id);
case _CmdType.setBulkMetadata:
final storeName = cmd.args['storeName']! as String;
final kvs = cmd.args['kvs']! as Map<String, String>;
Expand Down

0 comments on commit 9102680

Please sign in to comment.