Skip to content

Commit

Permalink
Only clear LIT layout if the layout changed, avoiding unnecessary bac…
Browse files Browse the repository at this point in the history
…kend calls.

PiperOrigin-RevId: 555623739
  • Loading branch information
nadah09 authored and LIT team committed Aug 10, 2023
1 parent 41d7edc commit fb2467d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lit_nlp/client/services/settings_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,18 @@ export class SettingsService extends LitService {
*/
@action
async updateSettings(updateParams: UpdateSettingsParams) {
// Clear all modules.
this.modulesService.clearLayout();

// After one animation frame, the modules have been cleared. Now make
// settings changes and recompute the layout.
await this.raf();
const nextModels = updateParams.models ?? this.appState.currentModels;
const nextDataset = updateParams.dataset ?? this.appState.currentDataset;
const nextLayout = updateParams.layoutName ?? this.appState.layoutName;

// Clear all modules.
if (nextLayout !== this.appState.layoutName) {
this.modulesService.clearLayout();
// After one animation frame, the modules have been cleared. Now make
// settings changes and recompute the layout.
await this.raf();
}

// Compare the updated models
const haveModelsChanged =
!arrayContainsSame(this.appState.currentModels, nextModels);
Expand Down

0 comments on commit fb2467d

Please sign in to comment.