@xh/hoist 75.0.0-SNAPSHOT.1754329446115 → 75.0.0-SNAPSHOT.1754335298677
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -1
- package/build/types/data/Store.d.ts +1 -0
- package/data/Store.ts +35 -7
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
state. Additionally enhanced `Store.modifyRecords` to return a `StoreChangeLog` of updates.
|
|
28
28
|
|
|
29
29
|
### 🐞 Bug Fixes
|
|
30
|
-
* Fixed
|
|
30
|
+
* Fixed bugs where `Store.modifyRecords`, `Store.revertRecords` and `Store.revert` were not properly
|
|
31
|
+
handling changes to `SummaryRecords`.
|
|
31
32
|
|
|
32
33
|
### 🐞 Bug Fixes
|
|
33
34
|
|
package/data/Store.ts
CHANGED
|
@@ -24,7 +24,8 @@ import {
|
|
|
24
24
|
remove as lodashRemove,
|
|
25
25
|
uniq,
|
|
26
26
|
first,
|
|
27
|
-
some
|
|
27
|
+
some,
|
|
28
|
+
partition
|
|
28
29
|
} from 'lodash';
|
|
29
30
|
import {Field, FieldSpec} from './Field';
|
|
30
31
|
import {parseFilter} from './filter/Utils';
|
|
@@ -590,7 +591,8 @@ export class Store extends HoistBase {
|
|
|
590
591
|
data: updatedData,
|
|
591
592
|
parent: currentRec.parent,
|
|
592
593
|
store: currentRec.store,
|
|
593
|
-
committedData: currentRec.committedData
|
|
594
|
+
committedData: currentRec.committedData,
|
|
595
|
+
isSummary: currentRec.isSummary
|
|
594
596
|
});
|
|
595
597
|
|
|
596
598
|
if (!equal(currentRec.data, updatedRec.data)) {
|
|
@@ -643,13 +645,20 @@ export class Store extends HoistBase {
|
|
|
643
645
|
records = castArray(records);
|
|
644
646
|
if (isEmpty(records)) return;
|
|
645
647
|
|
|
646
|
-
const recs = records.map(it => (it instanceof StoreRecord ? it : this.getOrThrow(it)))
|
|
648
|
+
const recs = records.map(it => (it instanceof StoreRecord ? it : this.getOrThrow(it))),
|
|
649
|
+
[summaryRecsToRevert, recsToRevert] = partition(recs, 'isSummary');
|
|
647
650
|
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
+
if (!isEmpty(summaryRecsToRevert)) {
|
|
652
|
+
this.revertSummaryRecords(summaryRecsToRevert);
|
|
653
|
+
}
|
|
651
654
|
|
|
652
|
-
|
|
655
|
+
if (!isEmpty(recsToRevert)) {
|
|
656
|
+
this._current = this._current
|
|
657
|
+
.withTransaction({update: recsToRevert.map(r => this.getCommittedOrThrow(r.id))})
|
|
658
|
+
.normalize(this._committed);
|
|
659
|
+
|
|
660
|
+
this.rebuildFiltered();
|
|
661
|
+
}
|
|
653
662
|
}
|
|
654
663
|
|
|
655
664
|
/**
|
|
@@ -662,6 +671,7 @@ export class Store extends HoistBase {
|
|
|
662
671
|
@action
|
|
663
672
|
revert() {
|
|
664
673
|
this._current = this._committed;
|
|
674
|
+
if (this.summaryRecords) this.revertSummaryRecords(this.summaryRecords);
|
|
665
675
|
this.rebuildFiltered();
|
|
666
676
|
}
|
|
667
677
|
|
|
@@ -1119,6 +1129,24 @@ export class Store extends HoistBase {
|
|
|
1119
1129
|
'idSpec should be either a name of a field, or a function to generate an id.'
|
|
1120
1130
|
);
|
|
1121
1131
|
}
|
|
1132
|
+
|
|
1133
|
+
@action
|
|
1134
|
+
private revertSummaryRecords(records: StoreRecord[]) {
|
|
1135
|
+
this.summaryRecords = this.summaryRecords.map(summaryRec => {
|
|
1136
|
+
const recToRevert = records.find(it => it.id === summaryRec.id);
|
|
1137
|
+
if (!recToRevert) return summaryRec;
|
|
1138
|
+
|
|
1139
|
+
const ret = new StoreRecord({
|
|
1140
|
+
id: recToRevert.id,
|
|
1141
|
+
raw: recToRevert.raw,
|
|
1142
|
+
data: {...recToRevert.committedData},
|
|
1143
|
+
store: this,
|
|
1144
|
+
isSummary: true
|
|
1145
|
+
});
|
|
1146
|
+
ret.finalize();
|
|
1147
|
+
return ret;
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1122
1150
|
}
|
|
1123
1151
|
|
|
1124
1152
|
//---------------------------------------------------------------------
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xh/hoist",
|
|
3
|
-
"version": "75.0.0-SNAPSHOT.
|
|
3
|
+
"version": "75.0.0-SNAPSHOT.1754335298677",
|
|
4
4
|
"description": "Hoist add-on for building and deploying React Applications.",
|
|
5
5
|
"repository": "github:xh/hoist-react",
|
|
6
6
|
"homepage": "https://xh.io",
|