From 0df6c2a4121947618cf4fbd30bfb26edcf15d049 Mon Sep 17 00:00:00 2001 From: Mo Bitar Date: Mon, 13 Nov 2017 12:20:30 -0600 Subject: [PATCH] Component saving timeouts --- .../app/frontend/controllers/editor.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/frontend/controllers/editor.js b/app/assets/javascripts/app/frontend/controllers/editor.js index 054b067ec..0b04ea0c2 100644 --- a/app/assets/javascripts/app/frontend/controllers/editor.js +++ b/app/assets/javascripts/app/frontend/controllers/editor.js @@ -382,12 +382,19 @@ angular.module('app.frontend') else if(action === "save-items" || action === "save-success" || action == "save-error") { if(data.items.map((item) => {return item.uuid}).includes(this.note.uuid)) { + if(action == "save-items") { - this.showSavingStatus(); - } else if(action == "save-success") { - $timeout(this.showAllChangesSavedStatus.bind(this), 200); - } else { - $timeout(this.showErrorStatus.bind(this), 200); + if(this.componentSaveTimeout) $timeout.cancel(this.componentSaveTimeout); + this.componentSaveTimeout = $timeout(this.showSavingStatus.bind(this), 10); + } + + else { + if(this.componentStatusTimeout) $timeout.cancel(this.componentStatusTimeout); + if(action == "save-success") { + this.componentStatusTimeout = $timeout(this.showAllChangesSavedStatus.bind(this), 400); + } else { + this.componentStatusTimeout = $timeout(this.showErrorStatus.bind(this), 400); + } } } }