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("|"); var endOfMsg = msg.indexOf("|");
if(endOfMsg !== -1) { if(endOfMsg !== -1) {
msg = msg.substring(0, endOfMsg); msg = msg.substring(0, endOfMsg);
if(!msg) {
return;
}
} }
options = options || {}; options = options || {};
iconClass = iconClass || "icon-info-sign"; iconClass = iconClass || "icon-info-sign";

View File

@ -33,7 +33,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
task.chain(); task.chain();
}).fail(function() { }).fail(function() {
core.setOffline(); 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; client = undefined;
authenticated = false; authenticated = false;
core.setOffline(); core.setOffline();
errorMsg = "|stopPublish";
} else { } else {
errorMsg = "Dropbox error (" errorMsg = "Dropbox error ("
+ error.status + ")."; + error.status + ").";

View File

@ -26,7 +26,7 @@ define(["jquery", "core", "async-runner"], function($, core, asyncRunner) {
task.chain(); task.chain();
}).fail(function() { }).fail(function() {
core.setOffline(); 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 dataType : "script", timeout : AJAX_TIMEOUT
}).fail(function() { }).fail(function() {
core.setOffline(); 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; connected = false;
authenticated = false; authenticated = false;
core.setOffline(); core.setOffline();
errorMsg = "|stopPublish";
} else { } else {
errorMsg = "Google error (" + error.code + ": " errorMsg = "Google error (" + error.code + ": "
+ error.message + ")."; + 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 // Call the provider
var provider = providerMap[publishAttributes.provider]; var provider = providerMap[publishAttributes.provider];
provider.publish(publishAttributes, publishTitle, content, function(error) { 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.fileManager.removePublish(publishIndex);
core.showMessage(provider.providerName + " publish location has been removed."); core.showMessage(provider.providerName + " publish location has been removed.");
} }
if(errorMsg.indexOf("|stopPublish") !== -1) {
callback(error);
return;
}
}
publishLocation(callback, errorFlag || error ); publishLocation(callback, errorFlag || error );
}); });
} }

View File

@ -63,7 +63,7 @@ define(["jquery", "core", "dropbox-provider", "gdrive-provider", "underscore"],
if(uploadFlag === true) { if(uploadFlag === true) {
// If uploadFlag is true, request another upload cycle // If uploadFlag is true, request another upload cycle
uploadCycle = true; 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; uploadPending = true;
} }
if(error) { if(error) {