Perform doFetchModBlockedList in splash. #7671

Closed
Ruk33 wants to merge 1 commit from 7668-improve-startup-performance-while-fetching-comment-moderation-info into master
5 changed files with 58 additions and 59 deletions
Showing only changes of commit 320e4e6bb7 - Show all commits

View file

@ -30,7 +30,7 @@ import {
doSetActiveChannel,
doSetIncognito,
} from 'redux/actions/app';
import { doFetchModBlockedList, doFetchCommentModAmIList } from 'redux/actions/comments';
import { doFetchCommentModAmIList } from 'redux/actions/comments';
import App from './view';
const select = (state) => ({
@ -67,7 +67,6 @@ const perform = (dispatch) => ({
setReferrer: (referrer, doClaim) => dispatch(doUserSetReferrer(referrer, doClaim)),
setActiveChannelIfNotSet: () => dispatch(doSetActiveChannel()),
setIncognito: () => dispatch(doSetIncognito()),
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
resolveUris: (uris) => dispatch(doResolveUris(uris)),
fetchModAmIList: () => dispatch(doFetchCommentModAmIList()),
});

View file

@ -73,7 +73,6 @@ type Props = {
subscriptions: Array<Subscription>,
setActiveChannelIfNotSet: () => void,
setIncognito: (boolean) => void,
fetchModBlockedList: () => void,
resolveUris: (Array<string>) => void,
fetchModAmIList: () => void,
isUpdateModalDisplayed: boolean,
@ -108,7 +107,6 @@ function App(props: Props) {
activeChannelId,
setActiveChannelIfNotSet,
setIncognito,
fetchModBlockedList,
resolveUris,
subscriptions,
fetchModAmIList,
@ -233,7 +231,6 @@ function App(props: Props) {
}
if (hasMyChannels) {
fetchModBlockedList();
fetchModAmIList();
}
}, [hasMyChannels, hasNoChannels, hasActiveChannelClaim, setActiveChannelIfNotSet, setIncognito]);

View file

@ -2,6 +2,7 @@ import * as MODALS from 'constants/modal_types';
import { connect } from 'react-redux';
import { selectDaemonVersionMatched, selectModal, selectSplashAnimationEnabled } from 'redux/selectors/app';
import { doCheckDaemonVersion, doOpenModal, doHideModal, doToggleSplashAnimation } from 'redux/actions/app';
import { doFetchModBlockedList } from 'redux/actions/comments';
import { doClearDaemonSetting } from 'redux/actions/settings';
import * as DAEMON_SETTINGS from 'constants/daemon_settings';
import { doToast } from 'redux/actions/notifications';
@ -21,6 +22,7 @@ const perform = (dispatch) => ({
toggleSplashAnimation: () => dispatch(doToggleSplashAnimation()),
clearWalletServers: () => dispatch(doClearDaemonSetting(DAEMON_SETTINGS.LBRYUM_SERVERS)),
doShowSnackBar: (message) => dispatch(doToast({ isError: true, message })),
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
});
export default connect(select, perform)(SplashScreen);

View file

@ -31,6 +31,7 @@ type Props = {
toggleSplashAnimation: () => void,
clearWalletServers: () => void,
doShowSnackBar: (string) => void,
fetchModBlockedList: () => Promise<any>,
};
type State = {
@ -197,10 +198,14 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
this.setState({ launchWithIncompatibleDaemon: true }, () => this.continueAppLaunch());
}
continueAppLaunch() {
continueAppLaunch = async () => {
const { daemonVersionMatched, onReadyToLaunch } = this.props;
const { isRunning, launchWithIncompatibleDaemon } = this.state;
try {
await this.props.fetchModBlockedList();
} catch (e) {}
if (daemonVersionMatched) {
onReadyToLaunch();
} 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
onReadyToLaunch();
}
}
};
timeout: ?TimeoutID;

View file

@ -1186,11 +1186,7 @@ export function doFetchModBlockedList() {
const moderatorTimeoutMap = {};
const blockListsPerChannel = res.map((r) => r.value);
blockListsPerChannel
.sort((a, b) => {
return 1;
})
.forEach((channelBlockLists) => {
blockListsPerChannel.forEach((channelBlockLists) => {
const storeList = (fetchedList, blockedList, timeoutMap, blockedByMap) => {
if (fetchedList) {
fetchedList.forEach((blockedChannel) => {