Fix selectModal always returning a new reference

Never use `state` as an input to `createSelector` as it is _always_ invalidated per immutability pattern.
This commit is contained in:
infinite-persistence 2021-12-10 12:46:26 +08:00
parent 9307511c88
commit 70a339c5d4
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -47,16 +47,11 @@ export const selectDaemonVersionMatched = (state) => selectState(state).daemonVe
export const selectVolume = (state) => selectState(state).volume; export const selectVolume = (state) => selectState(state).volume;
export const selectMute = (state) => selectState(state).muted; export const selectMute = (state) => selectState(state).muted;
export const selectUpgradeTimer = (state) => selectState(state).checkUpgradeTimer; export const selectUpgradeTimer = (state) => selectState(state).checkUpgradeTimer;
const selectModalId = (state) => selectState(state).modal;
const selectModalProps = (state) => selectState(state).modalProps;
export const selectModal = createSelector(selectState, (state) => { export const selectModal = createSelector(selectModalId, selectModalProps, (id, modalProps) => {
if (!state.modal) { return id ? { id, modalProps } : null;
return null;
}
return {
id: state.modal,
modalProps: state.modalProps,
};
}); });
export const selectSearchOptionsExpanded = (state) => selectState(state).searchOptionsExpanded; export const selectSearchOptionsExpanded = (state) => selectState(state).searchOptionsExpanded;