@onehat/data 1.11.5 → 1.11.6
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/package.json +1 -1
- package/src/Repository/Offline.js +30 -30
package/package.json
CHANGED
|
@@ -169,17 +169,16 @@ class OfflineRepository extends MemoryRepository {
|
|
|
169
169
|
// Attempt to add
|
|
170
170
|
super._doAdd(entity);
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
.
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
});
|
|
172
|
+
let storageResult;
|
|
173
|
+
try {
|
|
174
|
+
storageResult = await this._storageSetValue(entity.id, entity.getOriginalData());
|
|
175
|
+
this._addToIndex(entity.id);
|
|
176
|
+
} catch (e) {
|
|
177
|
+
// Revert to clone
|
|
178
|
+
delete this._keyedEntities[entity.id];
|
|
179
|
+
entity.destroy();
|
|
180
|
+
this._keyedEntities[clone.id] = clone;
|
|
181
|
+
}
|
|
183
182
|
|
|
184
183
|
return storageResult;
|
|
185
184
|
}
|
|
@@ -206,15 +205,16 @@ class OfflineRepository extends MemoryRepository {
|
|
|
206
205
|
|
|
207
206
|
// Attempt to edit
|
|
208
207
|
super._doEdit(entity);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
|
|
209
|
+
let storageResult;
|
|
210
|
+
try {
|
|
211
|
+
storageResult = await this._storageSetValue(entity.id, entity.getOriginalData());
|
|
212
|
+
} catch (e) {
|
|
213
|
+
// Revert to clone
|
|
214
|
+
entity.isPersisted = clone.isPersisted;
|
|
215
|
+
entity._originalData = clone._originalData;
|
|
216
|
+
entity._originalDataParsed = clone._originalDataParsed;
|
|
217
|
+
}
|
|
218
218
|
|
|
219
219
|
return storageResult;
|
|
220
220
|
}
|
|
@@ -228,16 +228,16 @@ class OfflineRepository extends MemoryRepository {
|
|
|
228
228
|
|
|
229
229
|
// Attempt to delete
|
|
230
230
|
super._doDelete(entity);
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
storageResult
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
let storageResult;
|
|
234
|
+
try {
|
|
235
|
+
storageResult = await this._storageDeleteValue(entity.id);
|
|
236
|
+
this._deleteFromIndex(entity.id);
|
|
237
|
+
} catch (e) {
|
|
238
|
+
// Revert to clone
|
|
239
|
+
this._keyedEntities[clone.id] = clone;
|
|
240
|
+
}
|
|
241
241
|
|
|
242
242
|
return storageResult;
|
|
243
243
|
}
|