Prevent notes from being double-created with multiple clicks on Save
This commit is contained in:
parent
265ae7d004
commit
95482c49d1
@ -4,7 +4,18 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var save_in_progress = false;
|
||||||
|
|
||||||
function saveme(callback) {
|
function saveme(callback) {
|
||||||
|
if (save_in_progress) {
|
||||||
|
console.log("Warning: save already in progress, doing nothing.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
app.toast.create({
|
||||||
|
text: '<i class="fas fa-sync fa-spin"></i> Saving...',
|
||||||
|
closeTimeout: 2 * 60 * 1000 // two whole minutes should be enough for *any* connection.
|
||||||
|
}).open();
|
||||||
|
save_in_progress = true;
|
||||||
sync(); // update textareas with correct content
|
sync(); // update textareas with correct content
|
||||||
|
|
||||||
var noteid = $("#note_content").data("noteid");
|
var noteid = $("#note_content").data("noteid");
|
||||||
@ -20,10 +31,11 @@ function saveme(callback) {
|
|||||||
NOTES.set(note);
|
NOTES.set(note);
|
||||||
NOTES.syncAll(function () {
|
NOTES.syncAll(function () {
|
||||||
app.toast.create({
|
app.toast.create({
|
||||||
text: 'Note saved.',
|
text: '<i class="fas fa-check"></i> Note saved.',
|
||||||
closeTimeout: 2000
|
closeTimeout: 3000
|
||||||
}).open();
|
}).open();
|
||||||
$("#orig_content").val(note.content);
|
$("#orig_content").val(note.content);
|
||||||
|
save_in_progress = false;
|
||||||
if (typeof callback == "function") {
|
if (typeof callback == "function") {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@ -33,6 +45,7 @@ function saveme(callback) {
|
|||||||
closeTimeout: 2000
|
closeTimeout: 2000
|
||||||
}).open();
|
}).open();
|
||||||
$("#orig_content").val(note.content);
|
$("#orig_content").val(note.content);
|
||||||
|
save_in_progress = false;
|
||||||
if (typeof callback == "function") {
|
if (typeof callback == "function") {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user