From 3de78e581509db03b1d31de7c48ca19a6da8e7cf Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 23 Mar 2017 16:57:05 +0300 Subject: [PATCH] Refactoring. --- apps/documenteditor/main/app/controller/Main.js | 13 ++++--------- apps/documenteditor/mobile/app/controller/Main.js | 13 ++++--------- .../presentationeditor/main/app/controller/Main.js | 13 ++++--------- .../mobile/app/controller/Main.js | 13 ++++--------- .../mobile/app/controller/Main.js | 14 ++++---------- 5 files changed, 20 insertions(+), 46 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index eba284fa2..b18104942 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -575,14 +575,9 @@ define([ if (id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) { if (this._state.fastCoauth && this._state.usersCount>1) { var me = this; - if (me._state.timerSave===undefined) - me._state.timerSave = setInterval(function(){ - if ((new Date()) - me._state.isSaving>500) { - clearInterval(me._state.timerSave); - me.getApplication().getController('Statusbar').setStatusCaption(me.textChangesSaved, false, 3000); - me._state.timerSave = undefined; - } - }, 500); + me._state.timerSave = setTimeout(function () { + me.getApplication().getController('Statusbar').setStatusCaption(me.textChangesSaved, false, 3000); + }, 500); } else this.getApplication().getController('Statusbar').setStatusCaption(this.textChangesSaved, false, 3000); } else @@ -614,7 +609,7 @@ define([ case Asc.c_oAscAsyncAction['Save']: case Asc.c_oAscAsyncAction['ForceSaveButton']: - this._state.isSaving = new Date(); + clearTimeout(this._state.timerSave); force = true; title = this.saveTitleText; text = this.saveTextText; diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index cca0a0c37..c0fc83dd6 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -312,14 +312,9 @@ define([ me.setLongActionView(action) } else { if (me._state.fastCoauth && me._state.usersCount>1 && id==Asc.c_oAscAsyncAction['Save']) { - if (me._state.timerSave===undefined) - me._state.timerSave = setInterval(function(){ - if ((new Date()) - me._state.isSaving>500) { - clearInterval(me._state.timerSave); - //console.debug('End long action'); - me._state.timerSave = undefined; - } - }, 500); + // me._state.timerSave = setTimeout(function () { + //console.debug('End long action'); + // }, 500); } else { // console.debug('End long action'); } @@ -352,7 +347,7 @@ define([ break; case Asc.c_oAscAsyncAction['Save']: - me._state.isSaving = new Date(); + // clearTimeout(this._state.timerSave); title = me.saveTitleText; text = me.saveTextText; break; diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 8cbebaeb7..d1853e910 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -389,14 +389,9 @@ define([ if (id==Asc.c_oAscAsyncAction['Save'] || id==Asc.c_oAscAsyncAction['ForceSaveButton']) { if (this._state.fastCoauth && this._state.usersCount>1) { var me = this; - if (me._state.timerSave===undefined) - me._state.timerSave = setInterval(function(){ - if ((new Date()) - me._state.isSaving>500) { - clearInterval(me._state.timerSave); - me.getApplication().getController('Statusbar').setStatusCaption(me.textChangesSaved, false, 3000); - me._state.timerSave = undefined; - } - }, 500); + me._state.timerSave = setTimeout(function () { + me.getApplication().getController('Statusbar').setStatusCaption(me.textChangesSaved, false, 3000); + }, 500); } else this.getApplication().getController('Statusbar').setStatusCaption(this.textChangesSaved, false, 3000); } else @@ -426,7 +421,7 @@ define([ case Asc.c_oAscAsyncAction['Save']: case Asc.c_oAscAsyncAction['ForceSaveButton']: - this._state.isSaving = new Date(); + clearTimeout(this._state.timerSave); force = true; title = this.saveTitleText; text = this.saveTextText; diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 78c189a89..57848bd51 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -302,14 +302,9 @@ define([ me.setLongActionView(action) } else { if (me._state.fastCoauth && me._state.usersCount>1 && id==Asc.c_oAscAsyncAction['Save']) { - if (me._state.timerSave===undefined) - me._state.timerSave = setInterval(function(){ - if ((new Date()) - me._state.isSaving>500) { - clearInterval(me._state.timerSave); - //console.debug('End long action'); - me._state.timerSave = undefined; - } - }, 500); + // me._state.timerSave = setTimeout(function () { + //console.debug('End long action'); + // }, 500); } else { // console.debug('End long action'); } @@ -342,7 +337,7 @@ define([ break; case Asc.c_oAscAsyncAction['Save']: - me._state.isSaving = new Date(); + // clearTimeout(me._state.timerSave); title = me.saveTitleText; text = me.saveTextText; break; diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index 6ce7f72c7..b16b005a3 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -305,15 +305,9 @@ define([ me.setLongActionView(action) } else { if (me._state.fastCoauth && me._state.usersCount>1 && id==Asc.c_oAscAsyncAction['Save']) { - var me = me; - if (me._state.timerSave===undefined) - me._state.timerSave = setInterval(function(){ - if ((new Date()) - me._state.isSaving>500) { - clearInterval(me._state.timerSave); - // console.debug('End long action'); - me._state.timerSave = undefined; - } - }, 500); + // me._state.timerSave = setTimeout(function () { + //console.debug('End long action'); + // }, 500); } else { // console.debug('End long action'); } @@ -346,7 +340,7 @@ define([ break; case Asc.c_oAscAsyncAction['Save']: - me._state.isSaving = new Date(); + // clearTimeout(me._state.timerSave); title = me.saveTitleText; text = me.saveTextText; break;