[Glitch] Allow hiding featured tab from empty state
Port 19ef4e5c40 to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
1 parent
f84df36bd1
commit
c2fe62be6c
4 files changed
+137
-19
No files matched your search
+73
@@ -0,0 +1,73 @@
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
import { useHistory } from 'react-router';
|
||||
|
||||
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
||||
import { useCurrentAccountId } from '@/flavours/glitch/hooks/useAccountId';
|
||||
import { domain } from '@/flavours/glitch/initial_state';
|
||||
import { patchProfile } from '@/flavours/glitch/reducers/slices/profile_edit';
|
||||
import { useAppDispatch } from 'flavours/glitch/store';
|
||||
|
||||
import type { BaseConfirmationModalProps } from './confirmation_modal';
|
||||
import { ConfirmationModal } from './confirmation_modal';
|
||||
|
||||
const messages = defineMessages({
|
||||
title: {
|
||||
id: 'confirmations.hide_featured_tab.title',
|
||||
defaultMessage: 'Hide "Featured" tab?',
|
||||
},
|
||||
intro: {
|
||||
id: 'confirmations.hide_featured_tab.intro',
|
||||
defaultMessage:
|
||||
'You can change this at any time under <i>Edit profile > Profile tab settings</i>.',
|
||||
},
|
||||
message: {
|
||||
id: 'confirmations.hide_featured_tab.message',
|
||||
defaultMessage:
|
||||
'This will hide the tab for users on {serverName} and other servers running the latest version of Mastodon. Other displays may vary.',
|
||||
},
|
||||
confirm: {
|
||||
id: 'confirmations.hide_featured_tab.confirm',
|
||||
defaultMessage: 'Hide tab',
|
||||
},
|
||||
});
|
||||
|
||||
export const ConfirmHideFeaturedTabModal: React.FC<
|
||||
BaseConfirmationModalProps
|
||||
> = ({ onClose }) => {
|
||||
const intl = useIntl();
|
||||
const dispatch = useAppDispatch();
|
||||
const history = useHistory();
|
||||
const currentAccountId = useCurrentAccountId();
|
||||
const { acct: currentUserName } = useAccount(currentAccountId) ?? {};
|
||||
|
||||
const onConfirm = useCallback(() => {
|
||||
void dispatch(patchProfile({ show_featured: false }));
|
||||
history.push(`/@${currentUserName}`);
|
||||
}, [currentUserName, dispatch, history]);
|
||||
|
||||
return (
|
||||
<ConfirmationModal
|
||||
title={intl.formatMessage(messages.title)}
|
||||
extraContent={
|
||||
<div className='prose'>
|
||||
<p>
|
||||
{intl.formatMessage(messages.intro, {
|
||||
i: (words) => <i>{words}</i>,
|
||||
})}
|
||||
</p>
|
||||
<p>
|
||||
{intl.formatMessage(messages.message, {
|
||||
serverName: domain,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
confirm={intl.formatMessage(messages.confirm)}
|
||||
onConfirm={onConfirm}
|
||||
onClose={onClose}
|
||||
/>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user