Skip to content

Commit af3160b

Browse files
committed
Only call saveSettings/syncURL if needed
1 parent e52ba7f commit af3160b

1 file changed

Lines changed: 41 additions & 14 deletions

File tree

packages/components/src/public/QueryModel/useQueryModels.ts

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,10 @@ export class QueryModelManager {
343343
});
344344

345345
this.maybeLoad(id, false, shouldLoad);
346-
this.syncURL(id);
346+
347+
if (shouldLoad) {
348+
this.syncURL(id);
349+
}
347350
};
348351

349352
loadLastPage = (id: string): void => {
@@ -355,7 +358,10 @@ export class QueryModelManager {
355358
}
356359
});
357360
this.maybeLoad(id, false, shouldLoad);
358-
this.syncURL(id);
361+
362+
if (shouldLoad) {
363+
this.syncURL(id);
364+
}
359365
};
360366

361367
loadModel = (id: string, loadSelections = false, reloadTotalCount = false): void => {
@@ -371,7 +377,10 @@ export class QueryModelManager {
371377
}
372378
});
373379
this.maybeLoad(id, false, shouldLoad);
374-
this.syncURL(id);
380+
381+
if (shouldLoad) {
382+
this.syncURL(id);
383+
}
375384
};
376385

377386
loadPreviousPage = (id: string): void => {
@@ -383,7 +392,10 @@ export class QueryModelManager {
383392
}
384393
});
385394
this.maybeLoad(id, false, shouldLoad);
386-
this.syncURL(id);
395+
396+
if (shouldLoad) {
397+
this.syncURL(id);
398+
}
387399
};
388400

389401
loadQueryInfo = async (
@@ -626,7 +638,7 @@ export class QueryModelManager {
626638
}
627639
});
628640

629-
// Loading & replacing selections are mutually exclusive, if we aren't replacing anything then load
641+
// Loading & replacing selections are mutually exclusive, if we aren't replacing anything, then load
630642
const loadSelections = selectionsForReplace === undefined;
631643
this.maybeLoad(id, false, true, loadSelections, shouldLoadTotalCount, selectionsForReplace);
632644
this.syncURL(id);
@@ -768,8 +780,11 @@ export class QueryModelManager {
768780
});
769781
// When filters change, we need to reload selections and counts.
770782
this.maybeLoad(id, false, shouldLoad, shouldLoad && loadSelections, true);
771-
this.saveSettings(id);
772-
this.syncURL(id);
783+
784+
if (shouldLoad) {
785+
this.saveSettings(id);
786+
this.syncURL(id);
787+
}
773788
};
774789

775790
setMaxRows = (id: string, maxRows: number): void => {
@@ -782,8 +797,11 @@ export class QueryModelManager {
782797
}
783798
});
784799
this.maybeLoad(id, false, shouldLoad);
785-
this.saveSettings(id);
786-
this.syncURL(id);
800+
801+
if (shouldLoad) {
802+
this.saveSettings(id);
803+
this.syncURL(id);
804+
}
787805
};
788806

789807
setOffset = (id: string, offset: number, reloadModel = true): void => {
@@ -795,7 +813,10 @@ export class QueryModelManager {
795813
}
796814
});
797815
this.maybeLoad(id, false, reloadModel && shouldLoad);
798-
this.syncURL(id);
816+
817+
if (shouldLoad) {
818+
this.syncURL(id);
819+
}
799820
};
800821

801822
setSchemaQuery = (id: string, schemaQuery: SchemaQuery, loadSelections = false): void => {
@@ -851,8 +872,11 @@ export class QueryModelManager {
851872
}
852873
});
853874
this.maybeLoad(id, false, shouldLoad);
854-
this.saveSettings(id);
855-
this.syncURL(id);
875+
876+
if (shouldLoad) {
877+
this.saveSettings(id);
878+
this.syncURL(id);
879+
}
856880
};
857881

858882
setView = (id: string, viewName: string, loadSelections = false): void => {
@@ -869,8 +893,11 @@ export class QueryModelManager {
869893
}
870894
});
871895
this.maybeLoad(id, false, shouldLoad, shouldLoad && loadSelections);
872-
this.saveSettings(id);
873-
this.syncURL(id);
896+
897+
if (shouldLoad) {
898+
this.saveSettings(id);
899+
this.syncURL(id);
900+
}
874901
};
875902
}
876903

0 commit comments

Comments
 (0)