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