Readd resetAutoSaveCountDown for more deterministic saving ops

This commit is contained in:
Kristóf Tóth 2018-03-30 23:04:31 +02:00
parent 31835c9140
commit 635d83e1b3
2 changed files with 9 additions and 2 deletions

View File

@ -34,7 +34,7 @@
</div>
</div>
<div (keyup)="setCodeState('DIRTY'); setDeployButtonState('TODEPLOY')"
<div (keyup)="setCodeState('DIRTY'); setDeployButtonState('TODEPLOY'); resetAutoSaveCountdown()"
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'); });
setInterval(() => { this.sendCodeIfDirty(); }, config.webide.autoSaveInterval);
this.resetAutoSaveCountdown();
}
subscribeWS() {
@ -95,6 +95,13 @@ 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();