mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
removed check for duplicate edits, they actually make sense in a repeated undo/redo scenario
This commit is contained in:
parent
d202078da3
commit
d8c69da02a
@ -18,7 +18,7 @@ define(["esri/graphic"], function(Graphic)
|
||||
UPDATE: "update",
|
||||
DELETE:"delete",
|
||||
|
||||
ERROR_DUPLICATE_EDIT: "Attempt to insert duplicated edit",
|
||||
// ERROR_DUPLICATE_EDIT: "Attempt to insert duplicated edit",
|
||||
ERROR_LOCALSTORAGE_FULL: "LocalStorage capacity exceeded",
|
||||
|
||||
isSupported: function()
|
||||
@ -43,20 +43,9 @@ define(["esri/graphic"], function(Graphic)
|
||||
}
|
||||
|
||||
var edits = this._retrieveEditsQueue();
|
||||
if( this._isEditDuplicated(edit,edits) )
|
||||
{
|
||||
// I still think that we shouldn't be concerned with duplicates:
|
||||
// they just shouldn't exist, and if they do, then it is a bug in upper level code
|
||||
console.log("duplicated", edit);
|
||||
console.log("current store is", edits);
|
||||
return { success:false, error: this.ERROR_DUPLICATE_EDIT}; // fail
|
||||
}
|
||||
else
|
||||
{
|
||||
edits.push(edit);
|
||||
var success = this._storeEditsQueue(edits);
|
||||
return { success: success, error: success? undefined : this.ERROR_LOCALSTORAGE_FULL };
|
||||
}
|
||||
edits.push(edit);
|
||||
var success = this._storeEditsQueue(edits);
|
||||
return { success: success, error: success? undefined : this.ERROR_LOCALSTORAGE_FULL };
|
||||
},
|
||||
|
||||
peekFirstEdit: function()
|
||||
|
||||
@ -281,38 +281,31 @@ describe("Public Interface", function()
|
||||
});
|
||||
});
|
||||
|
||||
describe("Duplicate edit detection", function()
|
||||
{
|
||||
it("reset edits queue", function()
|
||||
{
|
||||
g_editsStore.resetEditsQueue();
|
||||
expect(g_editsStore.pendingEditsCount()).toBe(0);
|
||||
});
|
||||
|
||||
it("try to add duplicate edits to edits queue", function()
|
||||
{
|
||||
var result;
|
||||
result = g_editsStore.pushEdit(g_editsStore.ADD, 6, g_test.pointFeature);
|
||||
expect(g_editsStore.pendingEditsCount()).toBe(1);
|
||||
expect(result.success).toBeTruthy();
|
||||
expect(result.error).toBeUndefined();
|
||||
result = g_editsStore.pushEdit(g_editsStore.UPDATE, 3, g_test.polygonFeature);
|
||||
expect(result.success).toBeTruthy();
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(g_editsStore.pendingEditsCount()).toBe(2);
|
||||
|
||||
result = g_editsStore.pushEdit(g_editsStore.ADD, 6, g_test.pointFeature);
|
||||
expect(g_editsStore.pendingEditsCount()).toBe(2);
|
||||
expect(result.success).toBeFalsy();
|
||||
expect(result.error).toEqual(g_editsStore.ERROR_DUPLICATE_EDIT);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Local Storage size", function()
|
||||
{
|
||||
var usedBytes, totalBytes;
|
||||
|
||||
it("reset edits queue", function()
|
||||
{
|
||||
g_editsStore.resetEditsQueue();
|
||||
expect(g_editsStore.pendingEditsCount()).toBe(0);
|
||||
});
|
||||
|
||||
it("add edits", function()
|
||||
{
|
||||
var result;
|
||||
result = g_editsStore.pushEdit(g_editsStore.ADD, 6, g_test.pointFeature);
|
||||
expect(g_editsStore.pendingEditsCount()).toBe(1);
|
||||
expect(result.success).toBeTruthy();
|
||||
expect(result.error).toBeUndefined();
|
||||
result = g_editsStore.pushEdit(g_editsStore.UPDATE, 3, g_test.polygonFeature);
|
||||
expect(result.success).toBeTruthy();
|
||||
expect(result.error).toBeUndefined();
|
||||
expect(g_editsStore.pendingEditsCount()).toBe(2);
|
||||
});
|
||||
|
||||
it("report edit store size", function()
|
||||
{
|
||||
usedBytes = g_editsStore.getEditsStoreSizeBytes();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user