From 37f9bafd137278781c8f91a0d55b5a3a559d0a2b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sat, 21 Oct 2023 12:38:21 -0500 Subject: [PATCH] AccountGallery: fix crash when account isn't loaded yet --- src/features/account-gallery/index.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/features/account-gallery/index.tsx b/src/features/account-gallery/index.tsx index 85dd0df83..a899d8d17 100644 --- a/src/features/account-gallery/index.tsx +++ b/src/features/account-gallery/index.tsx @@ -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 = useAppSelector((state) => getAccountGallery(state, account!.id)); + const attachments: ImmutableList = 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);