Skip muted list update if no change #7228
3 changed files with 17 additions and 6 deletions
|
@ -30,6 +30,14 @@ export default handleActions(
|
|||
) => {
|
||||
const { blocked } = action.data;
|
||||
const sanitizedBlocked = blocked && blocked.filter((e) => typeof e === 'string');
|
||||
|
||||
const next = sanitizedBlocked;
|
||||
const prev = state.blockedChannels;
|
||||
|
||||
if (next && prev && prev.length === next.length && prev.every((value, index) => value === next[index])) {
|
||||
return state;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
blockedChannels: sanitizedBlocked && sanitizedBlocked.length ? sanitizedBlocked : state.blockedChannels,
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
import { createSelector } from 'reselect';
|
||||
import { splitBySeparator } from 'lbry-redux';
|
||||
|
||||
const selectState = (state: { blocked: BlocklistState }) => state.blocked || {};
|
||||
type State = { blocked: BlocklistState };
|
||||
|
||||
export const selectMutedChannels = createSelector(selectState, (state: BlocklistState) => {
|
||||
return state.blockedChannels.filter((e) => typeof e === 'string');
|
||||
});
|
||||
const selectState = (state: State) => state.blocked || {};
|
||||
|
||||
export const selectMutedChannels = (state: State) => selectState(state).blockedChannels;
|
||||
|
||||
export const makeSelectChannelIsMuted = (uri: string) =>
|
||||
createSelector(selectMutedChannels, (state: Array<string>) => {
|
||||
|
|
|
@ -36,8 +36,11 @@ export const makeSelectPinnedCommentsForUri = (uri: string) =>
|
|||
}
|
||||
);
|
||||
|
||||
export const selectModerationBlockList = createSelector(selectState, (state) =>
|
||||
state.moderationBlockList ? state.moderationBlockList.reverse() : []
|
||||
export const selectModerationBlockList = createSelector(
|
||||
(state) => selectState(state).moderationBlockList,
|
||||
(moderationBlockList) => {
|
||||
return moderationBlockList ? moderationBlockList.reverse() : [];
|
||||
}
|
||||
);
|
||||
export const selectAdminBlockList = createSelector(selectState, (state) =>
|
||||
state.adminBlockList ? state.adminBlockList.reverse() : []
|
||||
|
|
Loading…
Reference in a new issue