More sidebar optimizations
- Remove the odd resolve call that's lingering in `App`. Feels out of place, plus we don't need it now since the "active subs" claim search would contain resolved results. - Don't search for active subs if Following count is zero.
This commit is contained in:
parent
56966ffa31
commit
429653a7dc
4 changed files with 14 additions and 23 deletions
|
@ -10,9 +10,8 @@ import {
|
||||||
selectHomepageFetched,
|
selectHomepageFetched,
|
||||||
} from 'redux/selectors/user';
|
} from 'redux/selectors/user';
|
||||||
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
|
import { selectUnclaimedRewards } from 'redux/selectors/rewards';
|
||||||
import { doFetchChannelListMine, doFetchCollectionListMine, doResolveUris } from 'redux/actions/claims';
|
import { doFetchChannelListMine, doFetchCollectionListMine } from 'redux/actions/claims';
|
||||||
import { selectMyChannelClaimIds } from 'redux/selectors/claims';
|
import { selectMyChannelClaimIds } from 'redux/selectors/claims';
|
||||||
import { selectSubscriptions } from 'redux/selectors/subscriptions';
|
|
||||||
import { selectLanguage, selectLoadedLanguages, selectThemePath } from 'redux/selectors/settings';
|
import { selectLanguage, selectLoadedLanguages, selectThemePath } from 'redux/selectors/settings';
|
||||||
import {
|
import {
|
||||||
selectIsUpgradeAvailable,
|
selectIsUpgradeAvailable,
|
||||||
|
@ -46,7 +45,6 @@ const select = (state) => ({
|
||||||
syncFatalError: selectSyncFatalError(state),
|
syncFatalError: selectSyncFatalError(state),
|
||||||
activeChannelClaim: selectActiveChannelClaim(state),
|
activeChannelClaim: selectActiveChannelClaim(state),
|
||||||
myChannelClaimIds: selectMyChannelClaimIds(state),
|
myChannelClaimIds: selectMyChannelClaimIds(state),
|
||||||
subscriptions: selectSubscriptions(state),
|
|
||||||
hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state),
|
hasPremiumPlus: selectOdyseeMembershipIsPremiumPlus(state),
|
||||||
homepageFetched: selectHomepageFetched(state),
|
homepageFetched: selectHomepageFetched(state),
|
||||||
});
|
});
|
||||||
|
@ -62,7 +60,6 @@ const perform = (dispatch) => ({
|
||||||
setActiveChannelIfNotSet: () => dispatch(doSetActiveChannel()),
|
setActiveChannelIfNotSet: () => dispatch(doSetActiveChannel()),
|
||||||
setIncognito: () => dispatch(doSetIncognito()),
|
setIncognito: () => dispatch(doSetIncognito()),
|
||||||
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
|
fetchModBlockedList: () => dispatch(doFetchModBlockedList()),
|
||||||
resolveUris: (uris) => dispatch(doResolveUris(uris)),
|
|
||||||
fetchModAmIList: () => dispatch(doFetchCommentModAmIList()),
|
fetchModAmIList: () => dispatch(doFetchCommentModAmIList()),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import * as PAGES from 'constants/pages';
|
import * as PAGES from 'constants/pages';
|
||||||
import React, { useEffect, useRef, useState, useLayoutEffect } from 'react';
|
import React, { useEffect, useRef, useState } from 'react';
|
||||||
import { lazyImport } from 'util/lazyImport';
|
import { lazyImport } from 'util/lazyImport';
|
||||||
import { tusUnlockAndNotify, tusHandleTabUpdates } from 'util/tus';
|
import { tusUnlockAndNotify, tusHandleTabUpdates } from 'util/tus';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
|
@ -24,7 +24,6 @@ import usePersistedState from 'effects/use-persisted-state';
|
||||||
import useConnectionStatus from 'effects/use-connection-status';
|
import useConnectionStatus from 'effects/use-connection-status';
|
||||||
import Spinner from 'component/spinner';
|
import Spinner from 'component/spinner';
|
||||||
import LANGUAGES from 'constants/languages';
|
import LANGUAGES from 'constants/languages';
|
||||||
import { SIDEBAR_SUBS_DISPLAYED } from 'constants/subscriptions';
|
|
||||||
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
|
import YoutubeWelcome from 'web/component/youtubeReferralWelcome';
|
||||||
import {
|
import {
|
||||||
useDegradedPerformance,
|
useDegradedPerformance,
|
||||||
|
@ -86,12 +85,10 @@ type Props = {
|
||||||
syncFatalError: boolean,
|
syncFatalError: boolean,
|
||||||
activeChannelClaim: ?ChannelClaim,
|
activeChannelClaim: ?ChannelClaim,
|
||||||
myChannelClaimIds: ?Array<string>,
|
myChannelClaimIds: ?Array<string>,
|
||||||
subscriptions: Array<Subscription>,
|
|
||||||
hasPremiumPlus: ?boolean,
|
hasPremiumPlus: ?boolean,
|
||||||
setActiveChannelIfNotSet: () => void,
|
setActiveChannelIfNotSet: () => void,
|
||||||
setIncognito: (boolean) => void,
|
setIncognito: (boolean) => void,
|
||||||
fetchModBlockedList: () => void,
|
fetchModBlockedList: () => void,
|
||||||
resolveUris: (Array<string>) => void,
|
|
||||||
fetchModAmIList: () => void,
|
fetchModAmIList: () => void,
|
||||||
homepageFetched: boolean,
|
homepageFetched: boolean,
|
||||||
};
|
};
|
||||||
|
@ -126,8 +123,6 @@ function App(props: Props) {
|
||||||
setActiveChannelIfNotSet,
|
setActiveChannelIfNotSet,
|
||||||
setIncognito,
|
setIncognito,
|
||||||
fetchModBlockedList,
|
fetchModBlockedList,
|
||||||
resolveUris,
|
|
||||||
subscriptions,
|
|
||||||
hasPremiumPlus,
|
hasPremiumPlus,
|
||||||
fetchModAmIList,
|
fetchModAmIList,
|
||||||
homepageFetched,
|
homepageFetched,
|
||||||
|
@ -149,10 +144,8 @@ function App(props: Props) {
|
||||||
|
|
||||||
const { pathname, hash, search } = props.location;
|
const { pathname, hash, search } = props.location;
|
||||||
const [upgradeNagClosed, setUpgradeNagClosed] = useState(false);
|
const [upgradeNagClosed, setUpgradeNagClosed] = useState(false);
|
||||||
const [resolvedSubscriptions, setResolvedSubscriptions] = useState(false);
|
|
||||||
const [retryingSync, setRetryingSync] = useState(false);
|
const [retryingSync, setRetryingSync] = useState(false);
|
||||||
const [langRenderKey, setLangRenderKey] = useState(0);
|
const [langRenderKey, setLangRenderKey] = useState(0);
|
||||||
const [sidebarOpen] = usePersistedState('sidebar', true);
|
|
||||||
const [seenSunsestMessage, setSeenSunsetMessage] = usePersistedState('lbrytv-sunset', false);
|
const [seenSunsestMessage, setSeenSunsetMessage] = usePersistedState('lbrytv-sunset', false);
|
||||||
const showUpgradeButton =
|
const showUpgradeButton =
|
||||||
(autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable)) && !upgradeNagClosed;
|
(autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable)) && !upgradeNagClosed;
|
||||||
|
@ -169,7 +162,6 @@ function App(props: Props) {
|
||||||
const hasNoChannels = myChannelClaimIds && myChannelClaimIds.length === 0;
|
const hasNoChannels = myChannelClaimIds && myChannelClaimIds.length === 0;
|
||||||
const shouldMigrateLanguage = LANGUAGE_MIGRATIONS[language];
|
const shouldMigrateLanguage = LANGUAGE_MIGRATIONS[language];
|
||||||
const hasActiveChannelClaim = activeChannelClaim !== undefined;
|
const hasActiveChannelClaim = activeChannelClaim !== undefined;
|
||||||
const isPersonalized = !IS_WEB || hasVerifiedEmail;
|
|
||||||
const renderFiledrop = !isMobile && isAuthenticated;
|
const renderFiledrop = !isMobile && isAuthenticated;
|
||||||
const connectionStatus = useConnectionStatus();
|
const connectionStatus = useConnectionStatus();
|
||||||
|
|
||||||
|
@ -475,16 +467,6 @@ function App(props: Props) {
|
||||||
}
|
}
|
||||||
}, [hasVerifiedEmail, signIn, hasSignedIn]);
|
}, [hasVerifiedEmail, signIn, hasSignedIn]);
|
||||||
|
|
||||||
// batch resolve subscriptions to be used by the sideNavigation component.
|
|
||||||
// add it here so that it only resolves the first time, despite route changes.
|
|
||||||
// useLayoutEffect because it has to be executed before the sideNavigation component requests them
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
if (sidebarOpen && isPersonalized && subscriptions && !resolvedSubscriptions) {
|
|
||||||
setResolvedSubscriptions(true);
|
|
||||||
resolveUris(subscriptions.slice(0, SIDEBAR_SUBS_DISPLAYED).map((sub) => sub.uri));
|
|
||||||
}
|
|
||||||
}, [sidebarOpen, isPersonalized, resolvedSubscriptions, subscriptions, resolveUris, setResolvedSubscriptions]);
|
|
||||||
|
|
||||||
useDegradedPerformance(setLbryTvApiStatus, user);
|
useDegradedPerformance(setLbryTvApiStatus, user);
|
||||||
|
|
||||||
useAdOutbrain(Boolean(hasPremiumPlus), isAuthenticated);
|
useAdOutbrain(Boolean(hasPremiumPlus), isAuthenticated);
|
||||||
|
|
|
@ -336,6 +336,10 @@ function SideNavigation(props: Props) {
|
||||||
lastActiveSubs && lastActiveSubs.length > 0 ? lastActiveSubs : subscriptions.slice(0, SIDEBAR_SUBS_DISPLAYED);
|
lastActiveSubs && lastActiveSubs.length > 0 ? lastActiveSubs : subscriptions.slice(0, SIDEBAR_SUBS_DISPLAYED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (lastActiveSubs === undefined) {
|
||||||
|
return null; // Don't show yet, just wait to save some renders
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className="navigation__secondary navigation-links">
|
<ul className="navigation__secondary navigation-links">
|
||||||
{subscriptions.length > SIDEBAR_SUBS_DISPLAYED && (
|
{subscriptions.length > SIDEBAR_SUBS_DISPLAYED && (
|
||||||
|
|
|
@ -118,6 +118,14 @@ export function doFetchLastActiveSubs(forceFetch: boolean = false, count: number
|
||||||
const channelIds = subscriptions.map((sub) => parseIdFromUri(sub.uri));
|
const channelIds = subscriptions.map((sub) => parseIdFromUri(sub.uri));
|
||||||
activeSubsLastFetchedTime = now;
|
activeSubsLastFetchedTime = now;
|
||||||
|
|
||||||
|
if (channelIds.length === 0) {
|
||||||
|
dispatch({
|
||||||
|
type: ACTIONS.FETCH_LAST_ACTIVE_SUBS_DONE,
|
||||||
|
data: [],
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const searchOptions = {
|
const searchOptions = {
|
||||||
limit_claims_per_channel: 1,
|
limit_claims_per_channel: 1,
|
||||||
channel_ids: channelIds,
|
channel_ids: channelIds,
|
||||||
|
|
Loading…
Reference in a new issue