From 31835c91403ff3e962521d37f5ce0757d570b5ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Wed, 28 Mar 2018 17:33:13 +0200 Subject: [PATCH] Fix reload event overwriting your code for the nth time --- src/app/webide/webide.component.html | 2 +- src/app/webide/webide.component.ts | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/app/webide/webide.component.html b/src/app/webide/webide.component.html index 937d2c1..bccf916 100644 --- a/src/app/webide/webide.component.html +++ b/src/app/webide/webide.component.html @@ -34,7 +34,7 @@ -
{ this.setDeployButtonState('DEPLOYED'); }); this.processManagerService.subscribeErrorCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('FAILED'); }); - this.resetAutoSaveCountdown(); + setInterval(() => { this.sendCodeIfDirty(); }, config.webide.autoSaveInterval); } subscribeWS() { @@ -82,8 +82,9 @@ export class WebideComponent implements OnInit { } readHandler(data: SourceCode) { - this.updateFileData(data); - this.setCodeState('SAVED'); + if (this.codeState == 'SAVED') { + this.updateFileData(data); + } } writeHandler() { @@ -94,13 +95,6 @@ export class WebideComponent implements OnInit { this.updateFileData(data); } - resetAutoSaveCountdown() { - if (this.autosave) { - clearInterval(this.autosave); - } - this.autosave = setInterval(() => { this.sendCodeIfDirty(); }, config.webide.autoSaveInterval); - } - tabSwitchButtonHandler(file) { if (this.codeState === 'DIRTY') { this.sendCodeContents();