mirror of
				https://github.com/avatao-content/frontend-tutorial-framework
				synced 2025-11-04 06:22:56 +00:00 
			
		
		
		
	Optimize tab switching: saving only happens if state is 'DIRTY'
This commit is contained in:
		@@ -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>
 | 
			
		||||
 
 | 
			
		||||
@@ -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';
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user