Skip to content

Commit

Permalink
Merge pull request #4641 from alisman/noInfinite
Browse files Browse the repository at this point in the history
Fix infinite reload of sample lists
  • Loading branch information
alisman authored Jun 15, 2023
2 parents 11e7099 + 2486439 commit 001469a
Showing 1 changed file with 13 additions and 31 deletions.
44 changes: 13 additions & 31 deletions src/shared/components/query/QueryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
observable,
ObservableMap,
reaction,
runInAction,
toJS,
} from 'mobx';
import {
Expand Down Expand Up @@ -296,7 +297,10 @@ export class QueryStore {
}

set selectableSelectedStudyIds(val: string[]) {
this._allSelectedStudyIds = observable.map(stringListToSet(val));
runInAction(() => {
this.selectedSampleListId = undefined;
this._allSelectedStudyIds = observable.map(stringListToSet(val));
});
}

@action
Expand Down Expand Up @@ -474,9 +478,12 @@ export class QueryStore {
@observable private _selectedSampleListId?: string = undefined; // user selection
@computed
public get selectedSampleListId() {
if (this._selectedSampleListId !== undefined)
return this._selectedSampleListId;
return this.defaultSelectedSampleListId;
const matchesSelectedStudy = this.sampleListInSelectedStudies.result.some(
sampleList => sampleList.sampleListId === this._selectedSampleListId
);
return matchesSelectedStudy
? this._selectedSampleListId
: this.defaultSelectedSampleListId;
}

public set selectedSampleListId(value) {
Expand Down Expand Up @@ -1004,14 +1011,6 @@ export class QueryStore {
);
},
default: [],
onResult: () => {
if (
!this.initiallySelected.sampleListId ||
this.studiesHaveChangedSinceInitialization
) {
this._selectedSampleListId = undefined;
}
},
});

readonly validProfileIdSetForSelectedStudies = remoteData({
Expand Down Expand Up @@ -1075,7 +1074,7 @@ export class QueryStore {
return _.sumBy(this.selectableSelectedStudies, s => s.allSampleCount);
}

readonly sampleLists = remoteData({
readonly sampleLists = remoteData<SampleList[]>({
invoke: async () => {
if (!this.isSingleNonVirtualStudySelected) {
return [];
Expand All @@ -1088,14 +1087,6 @@ export class QueryStore {
return _.sortBy(sampleLists, sampleList => sampleList.name);
},
default: [],
onResult: () => {
if (
!this.initiallySelected.sampleListId ||
this.studiesHaveChangedSinceInitialization
) {
this._selectedSampleListId = undefined;
}
},
});

readonly mutSigForSingleStudy = remoteData({
Expand Down Expand Up @@ -2295,16 +2286,7 @@ export class QueryStore {

let urlParams = this.asyncUrlParams.result;

if (this.forDownloadTab) {
formSubmit(
buildCBioPortalPageUrl('data_download'),
urlParams.query,
undefined,
'smart'
);
} else {
this.singlePageAppSubmitRoutine(urlParams.query, currentTab);
}
this.singlePageAppSubmitRoutine(urlParams.query, currentTab);

return true;
}
Expand Down

0 comments on commit 001469a

Please sign in to comment.