mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
reset phantom graphics queue
This commit is contained in:
parent
5c39eecb1e
commit
349565936a
@ -411,6 +411,63 @@ O.esri.Edit.EditStore = function()
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes some phantom graphics from database
|
||||
* @param callback boolean
|
||||
*/
|
||||
this.resetLimitedPhantomGraphicsQueue = function(responseObject,callback){
|
||||
|
||||
if( Object.keys(responseObject).length > 0 ){
|
||||
var db = this._db;
|
||||
|
||||
var errors = 0;
|
||||
var tx = db.transaction([objectStoreName], "readwrite");
|
||||
var objectStore = tx.objectStore(objectStoreName);
|
||||
|
||||
objectStore.onerror = function () {
|
||||
errors++; console.log("PHANTOM GRAPHIC ERROR")
|
||||
};
|
||||
|
||||
tx.oncomplete= function(){
|
||||
errors == 0 ? callback(true): callback(false);
|
||||
};
|
||||
|
||||
for(var key in responseObject){
|
||||
if (responseObject.hasOwnProperty(key)) {
|
||||
var edit = responseObject[key];
|
||||
var id = this.PHANTOM_GRAPHIC_PREFIX + this._PHANTOM_PREFIX_TOKEN + edit.id;
|
||||
console.log("EDIT " + JSON.stringify(edit))
|
||||
|
||||
// CAUTION:
|
||||
// TO-DO we do NOT match the edit.id with edit's objectId
|
||||
|
||||
if(edit.updateResults.length > 0){
|
||||
if(edit.updateResults[0].success){
|
||||
objectStore.delete(id);
|
||||
}
|
||||
}
|
||||
if(edit.deleteResults.length > 0){
|
||||
if(edit.deleteResults[0].success){
|
||||
objectStore.delete(id);
|
||||
}
|
||||
}
|
||||
if(edit.addResults.length > 0){
|
||||
if(edit.addResults[0].success){
|
||||
objectStore.delete(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(true);
|
||||
|
||||
}
|
||||
else{
|
||||
callback(true);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Removes all phantom graphics from database
|
||||
* @param callback boolean
|
||||
@ -676,13 +733,17 @@ O.esri.Edit.EditStore = function()
|
||||
|
||||
var count = 0;
|
||||
var id = this.FEATURE_LAYER_JSON_ID;
|
||||
var phantomGraphicPrefix = this.PHANTOM_GRAPHIC_PREFIX;
|
||||
|
||||
var transaction = this._db.transaction([objectStoreName],"readwrite")
|
||||
var objectStore = transaction.objectStore(objectStoreName);
|
||||
objectStore.openCursor().onsuccess = function(evt)
|
||||
{
|
||||
var cursor = evt.target.result;
|
||||
if(cursor && cursor.value && cursor.value.id)
|
||||
|
||||
// IMPORTANT:
|
||||
// Remember that we have feature layer JSON and Phantom Graphics in the same database
|
||||
if(cursor && cursor.value && cursor.value.id && cursor.value.id.indexOf(phantomGraphicPrefix) == -1)
|
||||
{
|
||||
if(cursor.value.id !== id){
|
||||
count++;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user