Optimize tab switching: saving only happens if state is 'DIRTY'

This commit is contained in:
Kristóf Tóth 2018-03-02 10:40:31 +01:00
parent ddc4430bde
commit 685b9755b9
2 changed files with 9 additions and 1 deletions

View File

@ -3,7 +3,7 @@
class="btn btn-secondary"
[class.active]="filename === file"
[class.disabled]="filename === file"
(click)="sendCodeContents(); selectCode(file); requestCode()"
(click)="tabSwitchButtonHandler(file)"
[disabled]="filename === file">
{{file}}
</button>

View File

@ -76,6 +76,14 @@ export class WebideComponent implements OnInit {
this.updateFileData(data);
}
tabSwitchButtonHandler(file) {
if (this.saveButtonState === 'DIRTY') {
this.sendCodeContents();
}
this.selectCode(file);
this.requestCode();
}
setButtonStateSaved() {
this.saveButtonState = 'SAVED';
}