New synchronize pattern

This commit is contained in:
benweet 2013-04-21 01:51:07 +01:00
parent d8b22a2b28
commit f25a6c15b8
7 changed files with 20 additions and 8 deletions

View File

@ -122,6 +122,9 @@ define(
var endOfMsg = msg.indexOf("|");
if(endOfMsg !== -1) {
msg = msg.substring(0, endOfMsg);
if(!msg) {
return;
}
}
options = options || {};
iconClass = iconClass || "icon-info-sign";

View File

@ -33,7 +33,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
task.chain();
}).fail(function() {
core.setOffline();
task.error(new Error("Network timeout"));
task.error(new Error("Network timeout|stopPublish"));
});
});
}
@ -250,6 +250,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
client = undefined;
authenticated = false;
core.setOffline();
errorMsg = "|stopPublish";
} else {
errorMsg = "Dropbox error ("
+ error.status + ").";

View File

@ -26,7 +26,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
task.chain();
}).fail(function() {
core.setOffline();
task.error(new Error("Network timeout"));
task.error(new Error("Network timeout|stopPublish"));
});
});
}

View File

@ -27,7 +27,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
dataType : "script", timeout : AJAX_TIMEOUT
}).fail(function() {
core.setOffline();
task.error(new Error("Network timeout"));
task.error(new Error("Network timeout|stopPublish"));
});
});
}
@ -329,6 +329,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
connected = false;
authenticated = false;
core.setOffline();
errorMsg = "|stopPublish";
} else {
errorMsg = "Google error (" + error.code + ": "
+ error.message + ").";

2
js/main-min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -87,10 +87,17 @@ define(["jquery", "core", "github-provider", "blogger-provider", "dropbox-provid
// Call the provider
var provider = providerMap[publishAttributes.provider];
provider.publish(publishAttributes, publishTitle, content, function(error) {
if(error !== undefined && error.toString().indexOf("|removePublish") !== -1) {
if(error !== undefined) {
var errorMsg = error.toString();
if(errorMsg.indexOf("|removePublish") !== -1) {
core.fileManager.removePublish(publishIndex);
core.showMessage(provider.providerName + " publish location has been removed.");
}
if(errorMsg.indexOf("|stopPublish") !== -1) {
callback(error);
return;
}
}
publishLocation(callback, errorFlag || error );
});
}

View File

@ -63,7 +63,7 @@ define(["jquery", "core", "dropbox-provider", "gdrive-provider", "underscore"],
if(uploadFlag === true) {
// If uploadFlag is true, request another upload cycle
uploadCycle = true;
// When page is refreshed, this flag is false but should be true
// When page is refreshed, this flag is false but should be true here
uploadPending = true;
}
if(error) {