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> </div>
<div (keyup)="setCodeState('DIRTY'); setDeployButtonState('TODEPLOY'); resetAutoSaveCountdown()" <div (keyup)="setCodeState('DIRTY'); setDeployButtonState('TODEPLOY')"
ace-editor ace-editor
[(text)]="code" [(text)]="code"
[mode]="language" [mode]="language"

View File

@ -55,7 +55,7 @@ export class WebideComponent implements OnInit {
this.processManagerService.init(); this.processManagerService.init();
this.processManagerService.subscribeCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('DEPLOYED'); }); this.processManagerService.subscribeCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('DEPLOYED'); });
this.processManagerService.subscribeErrorCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('FAILED'); }); this.processManagerService.subscribeErrorCallback(config.webide.deployProcessName, (event) => { this.setDeployButtonState('FAILED'); });
this.resetAutoSaveCountdown(); setInterval(() => { this.sendCodeIfDirty(); }, config.webide.autoSaveInterval);
} }
subscribeWS() { subscribeWS() {
@ -82,8 +82,9 @@ export class WebideComponent implements OnInit {
} }
readHandler(data: SourceCode) { readHandler(data: SourceCode) {
this.updateFileData(data); if (this.codeState == 'SAVED') {
this.setCodeState('SAVED'); this.updateFileData(data);
}
} }
writeHandler() { writeHandler() {
@ -94,13 +95,6 @@ export class WebideComponent implements OnInit {
this.updateFileData(data); this.updateFileData(data);
} }
resetAutoSaveCountdown() {
if (this.autosave) {
clearInterval(this.autosave);
}
this.autosave = setInterval(() => { this.sendCodeIfDirty(); }, config.webide.autoSaveInterval);
}
tabSwitchButtonHandler(file) { tabSwitchButtonHandler(file) {
if (this.codeState === 'DIRTY') { if (this.codeState === 'DIRTY') {
this.sendCodeContents(); this.sendCodeContents();