mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-09-12 07:10:07 +02:00
Avoid overlapping saves ...
This commit is contained in:
parent
90b584569b
commit
8de31d9edc
@ -46,22 +46,37 @@ mindplot.RESTPersistenceManager = new Class({
|
||||
query = query + (this.timestamp ? "×tamp=" + this.timestamp : "");
|
||||
query = query + (this.session ? "&session=" + this.session : "");
|
||||
|
||||
if (!persistence.onSave) {
|
||||
|
||||
// Mark save in process and fire a event unlocking the save ...
|
||||
persistence.onSave = true;
|
||||
persistence.clearTimeout = setTimeout(function () {
|
||||
persistence.clearTimeout = null;
|
||||
persistence.onSave = false;
|
||||
}, 10000);
|
||||
|
||||
var request = new Request({
|
||||
url:this.saveUrl.replace("{id}", mapId) + "?" + query,
|
||||
method:'put',
|
||||
async:!sync,
|
||||
|
||||
onSuccess:function (responseText, responseXML) {
|
||||
events.onSuccess();
|
||||
persistence.timestamp = responseText;
|
||||
events.onSuccess();
|
||||
},
|
||||
|
||||
onException:function (headerName, value) {
|
||||
console.log("onException....");
|
||||
|
||||
events.onError(persistence._buildError());
|
||||
},
|
||||
|
||||
onComplete:function () {
|
||||
// Clear event timeout ...
|
||||
if (persistence.clearTimeout) {
|
||||
clearTimeout(persistence.clearTimeout);
|
||||
}
|
||||
persistence.onSave = false;
|
||||
},
|
||||
|
||||
onFailure:function (xhr) {
|
||||
|
||||
var responseText = xhr.responseText;
|
||||
@ -85,7 +100,8 @@ mindplot.RESTPersistenceManager = new Class({
|
||||
}
|
||||
events.onError(userMsg);
|
||||
|
||||
// Only for debug. Remove.
|
||||
// @Todo: Only for debug. Remove.
|
||||
persistence.onSave = false;
|
||||
throw new Error("responseText:" + responseText + ",status:" + this.status);
|
||||
},
|
||||
|
||||
@ -94,6 +110,7 @@ mindplot.RESTPersistenceManager = new Class({
|
||||
urlEncoded:false
|
||||
});
|
||||
request.put(JSON.encode(data));
|
||||
}
|
||||
},
|
||||
|
||||
discardChanges:function (mapId) {
|
||||
|
Loading…
Reference in New Issue
Block a user