Perform doFetchModBlockedList in splash. #7671
5 changed files with 58 additions and 59 deletions
|
@ -30,7 +30,7 @@ import {
|
||||||
doSetActiveChannel,
|
doSetActiveChannel,
|
||||||
doSetIncognito,
|
doSetIncognito,
|
||||||
} from 'redux/actions/app';
|
} from 'redux/actions/app';
|
||||||
import { doFetchModBlockedList, doFetchCommentModAmIList } from 'redux/actions/comments';
|
import { doFetchCommentModAmIList } from 'redux/actions/comments';
|
||||||
import App from './view';
|
import App from './view';
|
||||||
|
|
||||||
const select = (state) => ({
|
const select = (state) => ({
|
||||||
|
@ -67,7 +67,6 @@ const perform = (dispatch) => ({
|
||||||
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
|
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
|
||||||
setActiveChannelIfNotSet: () => dispatch(doSetActiveChannel()),
|
setActiveChannelIfNotSet: () => dispatch(doSetActiveChannel()),
|
||||||
setIncognito: () => dispatch(doSetIncognito()),
|
setIncognito: () => dispatch(doSetIncognito()),
|
||||||
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
|
|
||||||
resolveUris: (uris) => dispatch(doResolveUris(uris)),
|
resolveUris: (uris) => dispatch(doResolveUris(uris)),
|
||||||
fetchModAmIList: () => dispatch(doFetchCommentModAmIList()),
|
fetchModAmIList: () => dispatch(doFetchCommentModAmIList()),
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,7 +73,6 @@ type Props = {
|
||||||
subscriptions: Array<Subscription>,
|
subscriptions: Array<Subscription>,
|
||||||
setActiveChannelIfNotSet: () => void,
|
setActiveChannelIfNotSet: () => void,
|
||||||
setIncognito: (boolean) => void,
|
setIncognito: (boolean) => void,
|
||||||
fetchModBlockedList: () => void,
|
|
||||||
resolveUris: (Array<string>) => void,
|
resolveUris: (Array<string>) => void,
|
||||||
fetchModAmIList: () => void,
|
fetchModAmIList: () => void,
|
||||||
isUpdateModalDisplayed: boolean,
|
isUpdateModalDisplayed: boolean,
|
||||||
|
@ -108,7 +107,6 @@ function App(props: Props) {
|
||||||
activeChannelId,
|
activeChannelId,
|
||||||
setActiveChannelIfNotSet,
|
setActiveChannelIfNotSet,
|
||||||
setIncognito,
|
setIncognito,
|
||||||
fetchModBlockedList,
|
|
||||||
resolveUris,
|
resolveUris,
|
||||||
subscriptions,
|
subscriptions,
|
||||||
fetchModAmIList,
|
fetchModAmIList,
|
||||||
|
@ -233,7 +231,6 @@ function App(props: Props) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasMyChannels) {
|
if (hasMyChannels) {
|
||||||
fetchModBlockedList();
|
|
||||||
fetchModAmIList();
|
fetchModAmIList();
|
||||||
}
|
}
|
||||||
}, [hasMyChannels, hasNoChannels, hasActiveChannelClaim, setActiveChannelIfNotSet, setIncognito]);
|
}, [hasMyChannels, hasNoChannels, hasActiveChannelClaim, setActiveChannelIfNotSet, setIncognito]);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import * as MODALS from 'constants/modal_types';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { selectDaemonVersionMatched, selectModal, selectSplashAnimationEnabled } from 'redux/selectors/app';
|
import { selectDaemonVersionMatched, selectModal, selectSplashAnimationEnabled } from 'redux/selectors/app';
|
||||||
import { doCheckDaemonVersion, doOpenModal, doHideModal, doToggleSplashAnimation } from 'redux/actions/app';
|
import { doCheckDaemonVersion, doOpenModal, doHideModal, doToggleSplashAnimation } from 'redux/actions/app';
|
||||||
|
import { doFetchModBlockedList } from 'redux/actions/comments';
|
||||||
import { doClearDaemonSetting } from 'redux/actions/settings';
|
import { doClearDaemonSetting } from 'redux/actions/settings';
|
||||||
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
|
||||||
import { doToast } from 'redux/actions/notifications';
|
import { doToast } from 'redux/actions/notifications';
|
||||||
|
@ -21,6 +22,7 @@ const perform = (dispatch) => ({
|
||||||
toggleSplashAnimation: () => dispatch(doToggleSplashAnimation()),
|
toggleSplashAnimation: () => dispatch(doToggleSplashAnimation()),
|
||||||
clearWalletServers: () => dispatch(doClearDaemonSetting(DAEMON_SETTINGS.LBRYUM_SERVERS)),
|
clearWalletServers: () => dispatch(doClearDaemonSetting(DAEMON_SETTINGS.LBRYUM_SERVERS)),
|
||||||
doShowSnackBar: (message) => dispatch(doToast({ isError: true, message })),
|
doShowSnackBar: (message) => dispatch(doToast({ isError: true, message })),
|
||||||
|
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
|
||||||
});
|
});
|
||||||
|
|
||||||
export default connect(select, perform)(SplashScreen);
|
export default connect(select, perform)(SplashScreen);
|
||||||
|
|
|
@ -31,6 +31,7 @@ type Props = {
|
||||||
toggleSplashAnimation: () => void,
|
toggleSplashAnimation: () => void,
|
||||||
clearWalletServers: () => void,
|
clearWalletServers: () => void,
|
||||||
doShowSnackBar: (string) => void,
|
doShowSnackBar: (string) => void,
|
||||||
|
fetchModBlockedList: () => Promise<any>,
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
@ -197,10 +198,14 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
|
||||||
this.setState({ launchWithIncompatibleDaemon: true }, () => this.continueAppLaunch());
|
this.setState({ launchWithIncompatibleDaemon: true }, () => this.continueAppLaunch());
|
||||||
}
|
}
|
||||||
|
|
||||||
continueAppLaunch() {
|
continueAppLaunch = async () => {
|
||||||
const { daemonVersionMatched, onReadyToLaunch } = this.props;
|
const { daemonVersionMatched, onReadyToLaunch } = this.props;
|
||||||
const { isRunning, launchWithIncompatibleDaemon } = this.state;
|
const { isRunning, launchWithIncompatibleDaemon } = this.state;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.props.fetchModBlockedList();
|
||||||
|
} catch (e) {}
|
||||||
|
|
||||||
if (daemonVersionMatched) {
|
if (daemonVersionMatched) {
|
||||||
onReadyToLaunch();
|
onReadyToLaunch();
|
||||||
} else if (launchWithIncompatibleDaemon && isRunning) {
|
} else if (launchWithIncompatibleDaemon && isRunning) {
|
||||||
|
@ -209,7 +214,7 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
|
||||||
// If it isn't running, this function will be called after the daemon is started
|
// If it isn't running, this function will be called after the daemon is started
|
||||||
onReadyToLaunch();
|
onReadyToLaunch();
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
timeout: ?TimeoutID;
|
timeout: ?TimeoutID;
|
||||||
|
|
||||||
|
|
|
@ -1186,64 +1186,60 @@ export function doFetchModBlockedList() {
|
||||||
const moderatorTimeoutMap = {};
|
const moderatorTimeoutMap = {};
|
||||||
|
|
||||||
const blockListsPerChannel = res.map((r) => r.value);
|
const blockListsPerChannel = res.map((r) => r.value);
|
||||||
blockListsPerChannel
|
blockListsPerChannel.forEach((channelBlockLists) => {
|
||||||
.sort((a, b) => {
|
const storeList = (fetchedList, blockedList, timeoutMap, blockedByMap) => {
|
||||||
return 1;
|
if (fetchedList) {
|
||||||
})
|
fetchedList.forEach((blockedChannel) => {
|
||||||
.forEach((channelBlockLists) => {
|
if (blockedChannel.blocked_channel_name) {
|
||||||
const storeList = (fetchedList, blockedList, timeoutMap, blockedByMap) => {
|
const channelUri = buildURI({
|
||||||
if (fetchedList) {
|
channelName: blockedChannel.blocked_channel_name,
|
||||||
fetchedList.forEach((blockedChannel) => {
|
channelClaimId: blockedChannel.blocked_channel_id,
|
||||||
if (blockedChannel.blocked_channel_name) {
|
});
|
||||||
const channelUri = buildURI({
|
|
||||||
channelName: blockedChannel.blocked_channel_name,
|
|
||||||
channelClaimId: blockedChannel.blocked_channel_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (!blockedList.find((blockedChannel) => isURIEqual(blockedChannel.channelUri, channelUri))) {
|
if (!blockedList.find((blockedChannel) => isURIEqual(blockedChannel.channelUri, channelUri))) {
|
||||||
blockedList.push({ channelUri, blockedAt: blockedChannel.blocked_at });
|
blockedList.push({ channelUri, blockedAt: blockedChannel.blocked_at });
|
||||||
|
|
||||||
if (blockedChannel.banned_for) {
|
if (blockedChannel.banned_for) {
|
||||||
timeoutMap[channelUri] = {
|
timeoutMap[channelUri] = {
|
||||||
blockedAt: blockedChannel.blocked_at,
|
blockedAt: blockedChannel.blocked_at,
|
||||||
bannedFor: blockedChannel.banned_for,
|
bannedFor: blockedChannel.banned_for,
|
||||||
banRemaining: blockedChannel.ban_remaining,
|
banRemaining: blockedChannel.ban_remaining,
|
||||||
};
|
};
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockedByMap !== undefined) {
|
|
||||||
const blockedByChannelUri = buildURI({
|
|
||||||
channelName: blockedChannel.blocked_by_channel_name,
|
|
||||||
channelClaimId: blockedChannel.blocked_by_channel_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (blockedByMap[channelUri]) {
|
|
||||||
if (!blockedByMap[channelUri].includes(blockedByChannelUri)) {
|
|
||||||
blockedByMap[channelUri].push(blockedByChannelUri);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
blockedByMap[channelUri] = [blockedByChannelUri];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const blocked_channels = channelBlockLists && channelBlockLists.blocked_channels;
|
if (blockedByMap !== undefined) {
|
||||||
const globally_blocked_channels = channelBlockLists && channelBlockLists.globally_blocked_channels;
|
const blockedByChannelUri = buildURI({
|
||||||
const delegated_blocked_channels = channelBlockLists && channelBlockLists.delegated_blocked_channels;
|
channelName: blockedChannel.blocked_by_channel_name,
|
||||||
|
channelClaimId: blockedChannel.blocked_by_channel_id,
|
||||||
|
});
|
||||||
|
|
||||||
storeList(blocked_channels, personalBlockList, personalTimeoutMap);
|
if (blockedByMap[channelUri]) {
|
||||||
storeList(globally_blocked_channels, adminBlockList, adminTimeoutMap);
|
if (!blockedByMap[channelUri].includes(blockedByChannelUri)) {
|
||||||
storeList(
|
blockedByMap[channelUri].push(blockedByChannelUri);
|
||||||
delegated_blocked_channels,
|
}
|
||||||
moderatorBlockList,
|
} else {
|
||||||
moderatorTimeoutMap,
|
blockedByMap[channelUri] = [blockedByChannelUri];
|
||||||
moderatorBlockListDelegatorsMap
|
}
|
||||||
);
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const blocked_channels = channelBlockLists && channelBlockLists.blocked_channels;
|
||||||
|
const globally_blocked_channels = channelBlockLists && channelBlockLists.globally_blocked_channels;
|
||||||
|
const delegated_blocked_channels = channelBlockLists && channelBlockLists.delegated_blocked_channels;
|
||||||
|
|
||||||
|
storeList(blocked_channels, personalBlockList, personalTimeoutMap);
|
||||||
|
storeList(globally_blocked_channels, adminBlockList, adminTimeoutMap);
|
||||||
|
storeList(
|
||||||
|
delegated_blocked_channels,
|
||||||
|
moderatorBlockList,
|
||||||
|
moderatorTimeoutMap,
|
||||||
|
moderatorBlockListDelegatorsMap
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: ACTIONS.COMMENT_MODERATION_BLOCK_LIST_COMPLETED,
|
type: ACTIONS.COMMENT_MODERATION_BLOCK_LIST_COMPLETED,
|
||||||
|
|
Loading…
Reference in a new issue