Simplify superchat selectors - memo not required
... since there are no transformations.
This commit is contained in:
parent
4876ad8671
commit
61a2ed2583
2 changed files with 16 additions and 24 deletions
|
@ -5,8 +5,8 @@ import { doCommentList, doSuperChatList } from 'redux/actions/comments';
|
||||||
import {
|
import {
|
||||||
selectTopLevelCommentsForUri,
|
selectTopLevelCommentsForUri,
|
||||||
selectIsFetchingComments,
|
selectIsFetchingComments,
|
||||||
makeSelectSuperChatsForUri,
|
selectSuperChatsForUri,
|
||||||
makeSelectSuperChatTotalAmountForUri,
|
selectSuperChatTotalAmountForUri,
|
||||||
selectPinnedCommentsForUri,
|
selectPinnedCommentsForUri,
|
||||||
} from 'redux/selectors/comments';
|
} from 'redux/selectors/comments';
|
||||||
import LivestreamComments from './view';
|
import LivestreamComments from './view';
|
||||||
|
@ -18,8 +18,8 @@ const select = (state, props) => ({
|
||||||
comments: selectTopLevelCommentsForUri(state, props.uri, MAX_LIVESTREAM_COMMENTS),
|
comments: selectTopLevelCommentsForUri(state, props.uri, MAX_LIVESTREAM_COMMENTS),
|
||||||
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
|
pinnedComments: selectPinnedCommentsForUri(state, props.uri),
|
||||||
fetchingComments: selectIsFetchingComments(state),
|
fetchingComments: selectIsFetchingComments(state),
|
||||||
superChats: makeSelectSuperChatsForUri(props.uri)(state),
|
superChats: selectSuperChatsForUri(state, props.uri),
|
||||||
superChatsTotalAmount: makeSelectSuperChatTotalAmountForUri(props.uri)(state),
|
superChatsTotalAmount: selectSuperChatTotalAmountForUri(state, props.uri),
|
||||||
myChannels: selectMyChannelClaims(state),
|
myChannels: selectMyChannelClaims(state),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -368,25 +368,17 @@ export const makeSelectUriIsBlockingOrUnBlocking = (uri: string) =>
|
||||||
return blockingByUri[uri] || unBlockingByUri[uri];
|
return blockingByUri[uri] || unBlockingByUri[uri];
|
||||||
});
|
});
|
||||||
|
|
||||||
export const makeSelectSuperChatDataForUri = (uri: string) =>
|
export const selectSuperChatDataForUri = (state: State, uri: string) => {
|
||||||
createSelector(selectSuperchatsByUri, (byUri) => {
|
const byUri = selectSuperchatsByUri(state);
|
||||||
return byUri[uri];
|
return byUri[uri];
|
||||||
});
|
};
|
||||||
|
|
||||||
export const makeSelectSuperChatsForUri = (uri: string) =>
|
export const selectSuperChatsForUri = (state: State, uri: string) => {
|
||||||
createSelector(makeSelectSuperChatDataForUri(uri), (superChatData) => {
|
const superChatData = selectSuperChatDataForUri(state, uri);
|
||||||
if (!superChatData) {
|
return superChatData ? superChatData.comments : undefined;
|
||||||
return undefined;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
return superChatData.comments;
|
export const selectSuperChatTotalAmountForUri = (state: State, uri: string) => {
|
||||||
});
|
const superChatData = selectSuperChatDataForUri(state, uri);
|
||||||
|
return superChatData ? superChatData.totalAmount : 0;
|
||||||
export const makeSelectSuperChatTotalAmountForUri = (uri: string) =>
|
};
|
||||||
createSelector(makeSelectSuperChatDataForUri(uri), (superChatData) => {
|
|
||||||
if (!superChatData) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return superChatData.totalAmount;
|
|
||||||
});
|
|
||||||
|
|
Loading…
Reference in a new issue