Blocklist page: fix perpetual spinner when trying to refresh with no channels

There's nothing to do when you don't have a channel, so hide the button and ensure redux fails gracefully.
This commit is contained in:
infinite-persistence 2021-09-24 15:01:51 +08:00
parent 0e391a3d78
commit f38a15ee0d
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
2 changed files with 19 additions and 9 deletions

View file

@ -221,6 +221,7 @@ function ListBlocked(props: Props) {
function getRefreshElem() { function getRefreshElem() {
return ( return (
myChannelClaims && (
<Button <Button
icon={ICONS.REFRESH} icon={ICONS.REFRESH}
button="alt" button="alt"
@ -230,6 +231,7 @@ function ListBlocked(props: Props) {
fetchModAmIList(); fetchModAmIList();
}} }}
/> />
)
); );
} }

View file

@ -1055,6 +1055,10 @@ export function doFetchModBlockedList() {
return async (dispatch: Dispatch, getState: GetState) => { return async (dispatch: Dispatch, getState: GetState) => {
const state = getState(); const state = getState();
const myChannels = selectMyChannelClaims(state); const myChannels = selectMyChannelClaims(state);
if (!myChannels) {
dispatch({ type: ACTIONS.COMMENT_MODERATION_BLOCK_LIST_FAILED });
return;
}
dispatch({ dispatch({
type: ACTIONS.COMMENT_MODERATION_BLOCK_LIST_STARTED, type: ACTIONS.COMMENT_MODERATION_BLOCK_LIST_STARTED,
@ -1377,6 +1381,10 @@ export function doFetchCommentModAmIList(channelClaim: ChannelClaim) {
return async (dispatch: Dispatch, getState: GetState) => { return async (dispatch: Dispatch, getState: GetState) => {
const state = getState(); const state = getState();
const myChannels = selectMyChannelClaims(state); const myChannels = selectMyChannelClaims(state);
if (!myChannels) {
dispatch({ type: ACTIONS.COMMENT_MODERATION_AM_I_LIST_FAILED });
return;
}
dispatch({ type: ACTIONS.COMMENT_MODERATION_AM_I_LIST_STARTED }); dispatch({ type: ACTIONS.COMMENT_MODERATION_AM_I_LIST_STARTED });