-
Notifications
You must be signed in to change notification settings - Fork 308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix infinite reload of sample lists #4641
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ import { | |
observable, | ||
ObservableMap, | ||
reaction, | ||
runInAction, | ||
toJS, | ||
} from 'mobx'; | ||
import { | ||
|
@@ -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 | ||
|
@@ -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) { | ||
|
@@ -1004,14 +1011,6 @@ export class QueryStore { | |
); | ||
}, | ||
default: [], | ||
onResult: () => { | ||
if ( | ||
!this.initiallySelected.sampleListId || | ||
this.studiesHaveChangedSinceInitialization | ||
) { | ||
this._selectedSampleListId = undefined; | ||
} | ||
}, | ||
}); | ||
|
||
readonly validProfileIdSetForSelectedStudies = remoteData({ | ||
|
@@ -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 []; | ||
|
@@ -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({ | ||
|
@@ -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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is an unrelated improvement/bug fix? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, download mode doesn't exist anymore so I've been trying to clean this stuff out, but i should probably do it in a seperate PR |
||
|
||
return true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@BasLee this is the offending onResult. It depends upon this._selectedSampleListId, so when it mutates that value it re-fires invoke and is circular.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that it was necessary in order to clear the selection when user selected a different study. This can/should be handled on read by checking to see if the _selectedSampleListId matches selectedStudies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the weird thing was, that the infinite loop even existed without any code in the onResult: it seemed like the presence of onResult itself was causing the loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interesting. i will test that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see that you are right. in my testing, the problem is that mobxpromise's onResult references this.result in order to pass it to the callback:
when i use result instead of this.result, the problem goes away. will have to make this change to the library.
nevertheless, i think getting rid of onResult in general is a good idea as it is almost never actually necessary.