Skip to content

Commit

Permalink
fix: Fixed a bug that data remained.
Browse files Browse the repository at this point in the history
  • Loading branch information
mathrunet committed Apr 21, 2024
1 parent 725b19e commit 66dafd3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,19 @@ class FirestoreModelSearchConverter extends FirestoreModelFieldValueConverter {
ModelFieldValueSource.user.name;
final val = value.getAsList<String>(ModelSearch.kListKey);
final targetKey = "#$key";
final keys = original
.getAsMap(targetKey)
.getAsMap(ModelToken.kListKey)
.map<String, dynamic>(
(key, value) => MapEntry(key, FieldValue.delete()),
);
for (final key in val) {
keys[key] = true;
}
return {
targetKey: {
kTypeFieldKey: ModelSearch.typeString,
ModelSearch.kListKey: val.toMap((item) => MapEntry(item, true)),
ModelSearch.kListKey: keys,
_kTargetKey: key,
},
if (fromUser) key: val,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ class FirestoreModelTokenConverter extends FirestoreModelFieldValueConverter {
ModelFieldValueSource.user.name;
final val = value.getAsList<String>(ModelToken.kListKey);
final targetKey = "#$key";
final keys = original
.getAsMap(targetKey)
.getAsMap(ModelToken.kListKey)
.map<String, dynamic>(
(key, value) => MapEntry(key, FieldValue.delete()),
);
for (final key in val) {
keys[key] = true;
}

return {
targetKey: {
kTypeFieldKey: ModelToken.typeString,
ModelToken.kListKey: val.toMap((item) => MapEntry(item, true)),
ModelToken.kListKey: keys,
_kTargetKey: key,
},
if (fromUser) key: val,
Expand Down
2 changes: 1 addition & 1 deletion packages/katana_model_firestore/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ packages:
path: "../katana_model"
relative: true
source: path
version: "2.26.6"
version: "2.26.7"
katana_test:
dependency: "direct dev"
description:
Expand Down

0 comments on commit 66dafd3

Please sign in to comment.