Fix reload event overwriting your code for the nth time

This commit is contained in:
Kristóf Tóth 2018-03-28 17:33:13 +02:00
parent c3361f6ce0
commit 31835c9140
2 changed files with 5 additions and 11 deletions

View File

@ -34,7 +34,7 @@
</div>
</div>
<div (keyup)="setCodeState('DIRTY'); setDeployButtonState('TODEPLOY'); resetAutoSaveCountdown()"
<div (keyup)="setCodeState('DIRTY'); setDeployButtonState('TODEPLOY')"
ace-editor
[(text)]="code"
[mode]="language"

View File

@ -55,7 +55,7 @@ export class WebideComponent implements OnInit {
this.processManagerService.init();
this.processManagerService.subscribeCallback(config.webide.deployProcessName, (event) => { 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();