AccountGallery: fix crash when account isn't loaded yet

environments/review-main-yi2y9f/deployments/4207^2
Alex Gleason 2023-10-21 12:38:21 -05:00
rodzic 9c1effc9ee
commit 37f9bafd13
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 2 dodań i 2 usunięć

Wyświetl plik

@ -1,3 +1,4 @@
import { List as ImmutableList } from 'immutable';
import React, { useEffect, useRef } from 'react';
import { FormattedMessage } from 'react-intl';
import { useParams } from 'react-router-dom';
@ -13,7 +14,6 @@ import { getAccountGallery } from 'soapbox/selectors';
import MediaItem from './components/media-item';
import type { List as ImmutableList } from 'immutable';
import type { Attachment, Status } from 'soapbox/types/entities';
interface ILoadMoreMedia {
@ -41,7 +41,7 @@ const AccountGallery = () => {
isUnavailable,
} = useAccountLookup(username, { withRelationship: true });
const attachments: ImmutableList<Attachment> = useAppSelector((state) => getAccountGallery(state, account!.id));
const attachments: ImmutableList<Attachment> = useAppSelector((state) => account ? getAccountGallery(state, account.id) : ImmutableList());
const isLoading = useAppSelector((state) => state.timelines.get(`account:${account?.id}:media`)?.isLoading);
const hasMore = useAppSelector((state) => state.timelines.get(`account:${account?.id}:media`)?.hasMore);
const next = useAppSelector(state => state.timelines.get(`account:${account?.id}:media`)?.next);