mirror of
https://github.com/avatao-content/frontend-tutorial-framework
synced 2025-01-16 03:01:56 +00:00
Fix autosave making typed text disappear
This commit is contained in:
parent
c46f5a3458
commit
f94a254f9b
@ -9,7 +9,7 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div (keypress)="setButtonStateDirty()"
|
||||
<div (keypress)="setButtonStateDirty(); resetAutoSaveCountdown()"
|
||||
ace-editor
|
||||
[(text)]="code"
|
||||
[mode]="language"
|
||||
|
@ -34,6 +34,7 @@ export class WebideComponent implements OnInit {
|
||||
theme = 'monokai';
|
||||
files: string[];
|
||||
saveButtonState = 'SAVED';
|
||||
autosave = null;
|
||||
command_handlers = { 'reload': this.reloadHandler.bind(this),
|
||||
'read': this.readHandler.bind(this),
|
||||
'select': this.selectHandler.bind(this),
|
||||
@ -49,7 +50,7 @@ export class WebideComponent implements OnInit {
|
||||
this.requestCode();
|
||||
this.processManagerService.init();
|
||||
this.processManagerService.subscribeCallback('login', (event) => { 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();
|
||||
|
Loading…
Reference in New Issue
Block a user