Header: make account optional again

This commit is contained in:
Alex Gleason 2022-08-11 14:02:01 -05:00
parent 8c94a4b882
commit eccfdb90f8
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 22 additions and 24 deletions

View file

@ -96,7 +96,7 @@ const messages = defineMessages({
}); });
interface IHeader { interface IHeader {
account: Account, account?: Account,
} }
const Header: React.FC<IHeader> = ({ account }) => { const Header: React.FC<IHeader> = ({ account }) => {
@ -107,6 +107,26 @@ const Header: React.FC<IHeader> = ({ account }) => {
const features = useFeatures(); const features = useFeatures();
const ownAccount = useOwnAccount(); const ownAccount = useOwnAccount();
if (!account) {
return (
<div className='-mt-4 -mx-4'>
<div>
<div className='relative h-32 w-full lg:h-48 md:rounded-t-xl bg-gray-200 dark:bg-gray-900/50' />
</div>
<div className='px-4 sm:px-6'>
<div className='-mt-12 flex items-end space-x-5'>
<div className='flex relative'>
<div
className='h-24 w-24 bg-gray-400 rounded-full ring-4 ring-white dark:ring-gray-800'
/>
</div>
</div>
</div>
</div>
);
}
const onBlock = () => { const onBlock = () => {
if (account.relationship?.blocking) { if (account.relationship?.blocking) {
dispatch(unblockAccount(account.id)); dispatch(unblockAccount(account.id));
@ -701,26 +721,6 @@ const Header: React.FC<IHeader> = ({ account }) => {
); );
}; };
if (!account) {
return (
<div className='-mt-4 -mx-4'>
<div>
<div className='relative h-32 w-full lg:h-48 md:rounded-t-xl bg-gray-200 dark:bg-gray-900/50' />
</div>
<div className='px-4 sm:px-6'>
<div className='-mt-12 flex items-end space-x-5'>
<div className='flex relative'>
<div
className='h-24 w-24 bg-gray-400 rounded-full ring-4 ring-white dark:ring-gray-800'
/>
</div>
</div>
</div>
</div>
);
}
const info = makeInfo(); const info = makeInfo();
const menu = makeMenu(); const menu = makeMenu();

View file

@ -98,9 +98,7 @@ const ProfilePage: React.FC<IProfilePage> = ({ params, children }) => {
<Layout.Main> <Layout.Main>
<Column label={account ? `@${getAcct(account, displayFqn)}` : ''} withHeader={false}> <Column label={account ? `@${getAcct(account, displayFqn)}` : ''} withHeader={false}>
<div className='space-y-4'> <div className='space-y-4'>
{account && ( <Header account={account} />
<Header account={account} />
)}
<BundleContainer fetchComponent={ProfileInfoPanel}> <BundleContainer fetchComponent={ProfileInfoPanel}>
{Component => <Component username={username} account={account} />} {Component => <Component username={username} account={account} />}