Fix header avatar stuck in pending mode when all channels are deleted (#911)

## Issue
535

## Change
- Header: Use the "channel list undefined" instead of "active channel url undefined" to determine if the button should be "pending".
- App: restore the use of `activeChannelClaim` instead of `activeChannelId`. In the existing design, the latter is never cleared is some situations, so the former is more accurate as it takes the current channel list into account. We might want to hide (not export) `activeChannelId` to avoid this mis-use again.
This commit is contained in:
infinite-persistence 2022-02-18 05:14:54 -08:00 committed by GitHub
parent 636b00f9db
commit a6316ce71e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 8 deletions

View file

@ -12,7 +12,7 @@ import {
selectIsUpgradeAvailable, selectIsUpgradeAvailable,
selectAutoUpdateDownloaded, selectAutoUpdateDownloaded,
selectModal, selectModal,
selectActiveChannelId, selectActiveChannelClaim,
selectIsReloadRequired, selectIsReloadRequired,
} from 'redux/selectors/app'; } from 'redux/selectors/app';
import { selectUploadCount } from 'redux/selectors/publish'; import { selectUploadCount } from 'redux/selectors/publish';
@ -37,7 +37,7 @@ const select = (state) => ({
isAuthenticated: selectUserVerifiedEmail(state), isAuthenticated: selectUserVerifiedEmail(state),
currentModal: selectModal(state), currentModal: selectModal(state),
syncFatalError: selectSyncFatalError(state), syncFatalError: selectSyncFatalError(state),
activeChannelId: selectActiveChannelId(state), activeChannelClaim: selectActiveChannelClaim(state),
myChannelClaimIds: selectMyChannelClaimIds(state), myChannelClaimIds: selectMyChannelClaimIds(state),
subscriptions: selectSubscriptions(state), subscriptions: selectSubscriptions(state),
}); });

View file

@ -79,7 +79,7 @@ type Props = {
syncLoop: (?boolean) => void, syncLoop: (?boolean) => void,
currentModal: any, currentModal: any,
syncFatalError: boolean, syncFatalError: boolean,
activeChannelId: ?string, activeChannelClaim: ?ChannelClaim,
myChannelClaimIds: ?Array<string>, myChannelClaimIds: ?Array<string>,
subscriptions: Array<Subscription>, subscriptions: Array<Subscription>,
setActiveChannelIfNotSet: () => void, setActiveChannelIfNotSet: () => void,
@ -114,7 +114,7 @@ function App(props: Props) {
currentModal, currentModal,
syncFatalError, syncFatalError,
myChannelClaimIds, myChannelClaimIds,
activeChannelId, activeChannelClaim,
setActiveChannelIfNotSet, setActiveChannelIfNotSet,
setIncognito, setIncognito,
fetchModBlockedList, fetchModBlockedList,
@ -154,7 +154,7 @@ function App(props: Props) {
const hasMyChannels = myChannelClaimIds && myChannelClaimIds.length > 0; const hasMyChannels = myChannelClaimIds && myChannelClaimIds.length > 0;
const hasNoChannels = myChannelClaimIds && myChannelClaimIds.length === 0; const hasNoChannels = myChannelClaimIds && myChannelClaimIds.length === 0;
const shouldMigrateLanguage = LANGUAGE_MIGRATIONS[language]; const shouldMigrateLanguage = LANGUAGE_MIGRATIONS[language];
const hasActiveChannelClaim = activeChannelId !== undefined; const hasActiveChannelClaim = activeChannelClaim !== undefined;
const isPersonalized = !IS_WEB || hasVerifiedEmail; const isPersonalized = !IS_WEB || hasVerifiedEmail;
const renderFiledrop = !isMobile && isAuthenticated; const renderFiledrop = !isMobile && isAuthenticated;
const connectionStatus = useConnectionStatus(); const connectionStatus = useConnectionStatus();

View file

@ -1,10 +1,12 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { doSignOut } from 'redux/actions/app'; import { doSignOut } from 'redux/actions/app';
import { selectActiveChannelClaim } from 'redux/selectors/app'; import { selectActiveChannelClaim } from 'redux/selectors/app';
import { selectMyChannelClaimIds } from 'redux/selectors/claims';
import { selectUserEmail, selectUserVerifiedEmail } from 'redux/selectors/user'; import { selectUserEmail, selectUserVerifiedEmail } from 'redux/selectors/user';
import HeaderProfileMenuButton from './view'; import HeaderProfileMenuButton from './view';
const select = (state) => ({ const select = (state) => ({
myChannelClaimIds: selectMyChannelClaimIds(state),
activeChannelClaim: selectActiveChannelClaim(state), activeChannelClaim: selectActiveChannelClaim(state),
authenticated: selectUserVerifiedEmail(state), authenticated: selectUserVerifiedEmail(state),
email: selectUserEmail(state), email: selectUserEmail(state),

View file

@ -12,6 +12,7 @@ import React from 'react';
import Skeleton from '@mui/material/Skeleton'; import Skeleton from '@mui/material/Skeleton';
type HeaderMenuButtonProps = { type HeaderMenuButtonProps = {
myChannelClaimIds: ?Array<string>,
activeChannelClaim: ?ChannelClaim, activeChannelClaim: ?ChannelClaim,
authenticated: boolean, authenticated: boolean,
email: ?string, email: ?string,
@ -19,14 +20,14 @@ type HeaderMenuButtonProps = {
}; };
export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) { export default function HeaderProfileMenuButton(props: HeaderMenuButtonProps) {
const { activeChannelClaim, authenticated, email, signOut } = props; const { myChannelClaimIds, activeChannelClaim, authenticated, email, signOut } = props;
const pendingChannelFetch = myChannelClaimIds === undefined;
const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url; const activeChannelUrl = activeChannelClaim && activeChannelClaim.permanent_url;
return ( return (
<div className="header__buttons"> <div className="header__buttons">
<Menu> <Menu>
{activeChannelUrl === undefined ? ( {pendingChannelFetch ? (
<Skeleton variant="circular" animation="wave" className="header__navigationItem--iconSkeleton" /> <Skeleton variant="circular" animation="wave" className="header__navigationItem--iconSkeleton" />
) : ( ) : (
<MenuButton <MenuButton