@forcecalendar/core 2.1.17 → 2.1.18
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/core/events/EventStore.js +18 -6
- package/package.json +1 -1
|
@@ -1010,7 +1010,7 @@ export class EventStore {
|
|
|
1010
1010
|
*/
|
|
1011
1011
|
addEvents(events) {
|
|
1012
1012
|
return this.optimizer.measure('addEvents', () => {
|
|
1013
|
-
this.startBatch();
|
|
1013
|
+
this.startBatch(true);
|
|
1014
1014
|
const results = [];
|
|
1015
1015
|
const errors = [];
|
|
1016
1016
|
|
|
@@ -1022,7 +1022,11 @@ export class EventStore {
|
|
|
1022
1022
|
}
|
|
1023
1023
|
}
|
|
1024
1024
|
|
|
1025
|
-
|
|
1025
|
+
if (errors.length > 0 && results.length === 0) {
|
|
1026
|
+
this.rollbackBatch();
|
|
1027
|
+
} else {
|
|
1028
|
+
this.commitBatch();
|
|
1029
|
+
}
|
|
1026
1030
|
|
|
1027
1031
|
if (errors.length > 0) {
|
|
1028
1032
|
console.warn(`Failed to add ${errors.length} events:`, errors);
|
|
@@ -1039,7 +1043,7 @@ export class EventStore {
|
|
|
1039
1043
|
*/
|
|
1040
1044
|
updateEvents(updates) {
|
|
1041
1045
|
return this.optimizer.measure('updateEvents', () => {
|
|
1042
|
-
this.startBatch();
|
|
1046
|
+
this.startBatch(true);
|
|
1043
1047
|
const results = [];
|
|
1044
1048
|
const errors = [];
|
|
1045
1049
|
|
|
@@ -1051,7 +1055,11 @@ export class EventStore {
|
|
|
1051
1055
|
}
|
|
1052
1056
|
}
|
|
1053
1057
|
|
|
1054
|
-
|
|
1058
|
+
if (errors.length > 0 && results.length === 0) {
|
|
1059
|
+
this.rollbackBatch();
|
|
1060
|
+
} else {
|
|
1061
|
+
this.commitBatch();
|
|
1062
|
+
}
|
|
1055
1063
|
|
|
1056
1064
|
if (errors.length > 0) {
|
|
1057
1065
|
console.warn(`Failed to update ${errors.length} events:`, errors);
|
|
@@ -1068,7 +1076,7 @@ export class EventStore {
|
|
|
1068
1076
|
*/
|
|
1069
1077
|
removeEvents(eventIds) {
|
|
1070
1078
|
return this.optimizer.measure('removeEvents', () => {
|
|
1071
|
-
this.startBatch();
|
|
1079
|
+
this.startBatch(true);
|
|
1072
1080
|
let removed = 0;
|
|
1073
1081
|
|
|
1074
1082
|
for (const id of eventIds) {
|
|
@@ -1077,7 +1085,11 @@ export class EventStore {
|
|
|
1077
1085
|
}
|
|
1078
1086
|
}
|
|
1079
1087
|
|
|
1080
|
-
|
|
1088
|
+
if (removed === 0 && eventIds.length > 0) {
|
|
1089
|
+
this.rollbackBatch();
|
|
1090
|
+
} else {
|
|
1091
|
+
this.commitBatch();
|
|
1092
|
+
}
|
|
1081
1093
|
return removed;
|
|
1082
1094
|
});
|
|
1083
1095
|
}
|