Add button to re-fetch Mod Blocklist

... otherwise, a full F5 reload is needed.
This commit is contained in:
infinite-persistence 2021-06-08 01:37:33 +08:00 committed by jessopb
parent d6ac2c7954
commit d36c8748e3
2 changed files with 11 additions and 2 deletions

View file

@ -1,4 +1,5 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doFetchModBlockedList } from 'redux/actions/comments';
import { selectMutedChannels } from 'redux/selectors/blocked'; import { selectMutedChannels } from 'redux/selectors/blocked';
import { selectModerationBlockList, selectFetchingModerationBlockList } from 'redux/selectors/comments'; import { selectModerationBlockList, selectFetchingModerationBlockList } from 'redux/selectors/comments';
import ListBlocked from './view'; import ListBlocked from './view';
@ -9,4 +10,8 @@ const select = (state) => ({
fetchingModerationBlockList: selectFetchingModerationBlockList(state), fetchingModerationBlockList: selectFetchingModerationBlockList(state),
}); });
export default connect(select)(ListBlocked); const perform = (dispatch) => ({
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
});
export default connect(select, perform)(ListBlocked);

View file

@ -15,13 +15,14 @@ type Props = {
mutedUris: ?Array<string>, mutedUris: ?Array<string>,
blockedUris: ?Array<string>, blockedUris: ?Array<string>,
fetchingModerationBlockList: boolean, fetchingModerationBlockList: boolean,
fetchModBlockedList: () => void,
}; };
const VIEW_BLOCKED = 'blocked'; const VIEW_BLOCKED = 'blocked';
const VIEW_MUTED = 'muted'; const VIEW_MUTED = 'muted';
function ListBlocked(props: Props) { function ListBlocked(props: Props) {
const { mutedUris, blockedUris, fetchingModerationBlockList } = props; const { mutedUris, blockedUris, fetchingModerationBlockList, fetchModBlockedList } = props;
const [viewMode, setViewMode] = usePersistedState('blocked-muted:display', VIEW_BLOCKED); const [viewMode, setViewMode] = usePersistedState('blocked-muted:display', VIEW_BLOCKED);
// Keep a local list to allow for undoing actions in this component // Keep a local list to allow for undoing actions in this component
@ -100,6 +101,9 @@ function ListBlocked(props: Props) {
onClick={() => setViewMode(VIEW_MUTED)} onClick={() => setViewMode(VIEW_MUTED)}
/> />
</div> </div>
<div className="section__actions--inline">
<Button icon={ICONS.REFRESH} button="alt" label={__('Refresh')} onClick={() => fetchModBlockedList()} />
</div>
</div> </div>
{showUris && <div className="help--notice">{viewMode === VIEW_MUTED ? mutedHelpText : blockedHelpText}</div>} {showUris && <div className="help--notice">{viewMode === VIEW_MUTED ? mutedHelpText : blockedHelpText}</div>}