From f94a254f9bf640d8668e72c84b77aa3059719abd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Fri, 2 Mar 2018 14:16:55 +0100 Subject: [PATCH] Fix autosave making typed text disappear --- src/app/webide/webide.component.html | 2 +- src/app/webide/webide.component.ts | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/webide/webide.component.html b/src/app/webide/webide.component.html index 626cbfd..a85de03 100644 --- a/src/app/webide/webide.component.html +++ b/src/app/webide/webide.component.html @@ -9,7 +9,7 @@ -
{ this.setButtonStateSaved(); }); - setInterval(() => { this.sendCodeIfDirty(); }, autosave_interval); + this.resetAutoSaveCountdown(); } subscribeWS() { @@ -79,6 +80,13 @@ export class WebideComponent implements OnInit { this.saveButtonState = 'SAVED'; } + resetAutoSaveCountdown() { + if (this.autosave) { + clearInterval(this.autosave); + } + this.autosave = setInterval(() => { this.sendCodeIfDirty(); }, autosave_interval); + } + tabSwitchButtonHandler(file) { if (this.saveButtonState === 'DIRTY') { this.sendCodeContents();