[Glitch] Profile redesign: Remove feature flag
Port ca5c0a144ade4bff7bd10446a39d86116879884e to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
c315d27f3c
commit
73caee93c2
@ -6,7 +6,6 @@ import classNames from 'classnames';
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { useIdentity } from '@/flavours/glitch/identity_context';
|
import { useIdentity } from '@/flavours/glitch/identity_context';
|
||||||
import { isServerFeatureEnabled } from '@/flavours/glitch/utils/environment';
|
|
||||||
import {
|
import {
|
||||||
fetchRelationships,
|
fetchRelationships,
|
||||||
followAccount,
|
followAccount,
|
||||||
@ -171,23 +170,10 @@ export const FollowButton: React.FC<{
|
|||||||
'button--compact': compact,
|
'button--compact': compact,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isServerFeatureEnabled('profile_redesign')) {
|
|
||||||
return (
|
|
||||||
<Link to='/profile/edit' className={buttonClasses}>
|
|
||||||
{label}
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<a
|
<Link to='/profile/edit' className={buttonClasses}>
|
||||||
href='/settings/profile'
|
|
||||||
target='_blank'
|
|
||||||
rel='noopener'
|
|
||||||
className={buttonClasses}
|
|
||||||
>
|
|
||||||
{label}
|
{label}
|
||||||
</a>
|
</Link>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import { useHistory } from 'react-router';
|
|||||||
import { List as ImmutableList } from 'immutable';
|
import { List as ImmutableList } from 'immutable';
|
||||||
|
|
||||||
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
||||||
import { isServerFeatureEnabled } from '@/flavours/glitch/utils/environment';
|
|
||||||
import { fetchEndorsedAccounts } from 'flavours/glitch/actions/accounts';
|
import { fetchEndorsedAccounts } from 'flavours/glitch/actions/accounts';
|
||||||
import { fetchFeaturedTags } from 'flavours/glitch/actions/featured_tags';
|
import { fetchFeaturedTags } from 'flavours/glitch/actions/featured_tags';
|
||||||
import { Account } from 'flavours/glitch/components/account';
|
import { Account } from 'flavours/glitch/components/account';
|
||||||
@ -49,11 +48,7 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
|
|||||||
|
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (
|
if (account && !account.show_featured) {
|
||||||
account &&
|
|
||||||
!account.show_featured &&
|
|
||||||
isServerFeatureEnabled('profile_redesign')
|
|
||||||
) {
|
|
||||||
history.push(`/@${account.acct}`);
|
history.push(`/@${account.acct}`);
|
||||||
}
|
}
|
||||||
}, [account, history]);
|
}, [account, history]);
|
||||||
@ -111,8 +106,7 @@ const AccountFeatured: React.FC<{ multiColumn: boolean }> = ({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const noTags =
|
const noTags = featuredTags.isEmpty();
|
||||||
featuredTags.isEmpty() || isServerFeatureEnabled('profile_redesign');
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
noTags &&
|
noTags &&
|
||||||
|
|||||||
@ -4,7 +4,6 @@ import { FormattedMessage, useIntl, defineMessages } from 'react-intl';
|
|||||||
|
|
||||||
import { List as ImmutableList, isList } from 'immutable';
|
import { List as ImmutableList, isList } from 'immutable';
|
||||||
|
|
||||||
import { isServerFeatureEnabled } from '@/flavours/glitch/utils/environment';
|
|
||||||
import PersonIcon from '@/material-icons/400-24px/person.svg?react';
|
import PersonIcon from '@/material-icons/400-24px/person.svg?react';
|
||||||
import { openModal } from 'flavours/glitch/actions/modal';
|
import { openModal } from 'flavours/glitch/actions/modal';
|
||||||
import { expandAccountMediaTimeline } from 'flavours/glitch/actions/timelines';
|
import { expandAccountMediaTimeline } from 'flavours/glitch/actions/timelines';
|
||||||
@ -31,8 +30,6 @@ const messages = defineMessages({
|
|||||||
|
|
||||||
const emptyList = ImmutableList<MediaAttachment>();
|
const emptyList = ImmutableList<MediaAttachment>();
|
||||||
|
|
||||||
const redesignEnabled = isServerFeatureEnabled('profile_redesign');
|
|
||||||
|
|
||||||
const selectGalleryTimeline = createAppSelector(
|
const selectGalleryTimeline = createAppSelector(
|
||||||
[
|
[
|
||||||
(_state, accountId?: string | null) => accountId,
|
(_state, accountId?: string | null) => accountId,
|
||||||
@ -62,7 +59,7 @@ const selectGalleryTimeline = createAppSelector(
|
|||||||
|
|
||||||
const { show_media, show_media_replies } = account;
|
const { show_media, show_media_replies } = account;
|
||||||
// If the account disabled showing media, don't display anything.
|
// If the account disabled showing media, don't display anything.
|
||||||
if (!show_media && redesignEnabled) {
|
if (!show_media) {
|
||||||
return {
|
return {
|
||||||
items,
|
items,
|
||||||
hasMore: false,
|
hasMore: false,
|
||||||
@ -71,7 +68,7 @@ const selectGalleryTimeline = createAppSelector(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const withReplies = show_media_replies && redesignEnabled;
|
const withReplies = show_media_replies;
|
||||||
const timeline = timelines.get(
|
const timeline = timelines.get(
|
||||||
`account:${accountId}:media${withReplies ? ':with_replies' : ''}`,
|
`account:${accountId}:media${withReplies ? ':with_replies' : ''}`,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,9 +1,4 @@
|
|||||||
import type { AccountFieldShape } from '@/flavours/glitch/models/account';
|
import type { AccountFieldShape } from '@/flavours/glitch/models/account';
|
||||||
import { isServerFeatureEnabled } from '@/flavours/glitch/utils/environment';
|
|
||||||
|
|
||||||
export function isRedesignEnabled() {
|
|
||||||
return isServerFeatureEnabled('profile_redesign');
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AccountField extends AccountFieldShape {
|
export interface AccountField extends AccountFieldShape {
|
||||||
nameHasEmojis: boolean;
|
nameHasEmojis: boolean;
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import { openModal } from '@/flavours/glitch/actions/modal';
|
|||||||
import { AccountBio } from '@/flavours/glitch/components/account_bio';
|
import { AccountBio } from '@/flavours/glitch/components/account_bio';
|
||||||
import { Avatar } from '@/flavours/glitch/components/avatar';
|
import { Avatar } from '@/flavours/glitch/components/avatar';
|
||||||
import { AnimateEmojiProvider } from '@/flavours/glitch/components/emoji/context';
|
import { AnimateEmojiProvider } from '@/flavours/glitch/components/emoji/context';
|
||||||
import { AccountNote } from '@/flavours/glitch/features/account/components/account_note';
|
|
||||||
import FollowRequestNoteContainer from '@/flavours/glitch/features/account/containers/follow_request_note_container';
|
import FollowRequestNoteContainer from '@/flavours/glitch/features/account/containers/follow_request_note_container';
|
||||||
import { useLayout } from '@/flavours/glitch/hooks/useLayout';
|
import { useLayout } from '@/flavours/glitch/hooks/useLayout';
|
||||||
import { useVisibility } from '@/flavours/glitch/hooks/useVisibility';
|
import { useVisibility } from '@/flavours/glitch/hooks/useVisibility';
|
||||||
@ -20,9 +19,6 @@ import type { Account } from '@/flavours/glitch/models/account';
|
|||||||
import { getAccountHidden } from '@/flavours/glitch/selectors/accounts';
|
import { getAccountHidden } from '@/flavours/glitch/selectors/accounts';
|
||||||
import { useAppSelector, useAppDispatch } from '@/flavours/glitch/store';
|
import { useAppSelector, useAppDispatch } from '@/flavours/glitch/store';
|
||||||
|
|
||||||
import { ActionBar } from '../../account/components/action_bar';
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
|
|
||||||
import { AccountName } from './account_name';
|
import { AccountName } from './account_name';
|
||||||
import { AccountSubscriptionForm } from './account_subscription_form';
|
import { AccountSubscriptionForm } from './account_subscription_form';
|
||||||
import { AccountBadges } from './badges';
|
import { AccountBadges } from './badges';
|
||||||
@ -33,6 +29,7 @@ import { AccountInfo } from './info';
|
|||||||
import { MemorialNote } from './memorial_note';
|
import { MemorialNote } from './memorial_note';
|
||||||
import { MovedNote } from './moved_note';
|
import { MovedNote } from './moved_note';
|
||||||
import { AccountNote as AccountNoteRedesign } from './note';
|
import { AccountNote as AccountNoteRedesign } from './note';
|
||||||
|
import { AccountNumberFields } from './number_fields';
|
||||||
import redesignClasses from './redesign.module.scss';
|
import redesignClasses from './redesign.module.scss';
|
||||||
import { AccountTabs } from './tabs';
|
import { AccountTabs } from './tabs';
|
||||||
|
|
||||||
@ -52,8 +49,6 @@ export const AccountHeader: React.FC<{
|
|||||||
accountId: string;
|
accountId: string;
|
||||||
hideTabs?: boolean;
|
hideTabs?: boolean;
|
||||||
}> = ({ accountId, hideTabs }) => {
|
}> = ({ accountId, hideTabs }) => {
|
||||||
const isRedesign = isRedesignEnabled();
|
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
const account = useAppSelector((state) => state.accounts.get(accountId));
|
const account = useAppSelector((state) => state.accounts.get(accountId));
|
||||||
const relationship = useAppSelector((state) =>
|
const relationship = useAppSelector((state) =>
|
||||||
@ -120,7 +115,7 @@ export const AccountHeader: React.FC<{
|
|||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'account__header__image',
|
'account__header__image',
|
||||||
isRedesign && redesignClasses.header,
|
redesignClasses.header,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{me !== account.id && relationship && (
|
{me !== account.id && relationship && (
|
||||||
@ -139,13 +134,13 @@ export const AccountHeader: React.FC<{
|
|||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'account__header__bar',
|
'account__header__bar',
|
||||||
isRedesign && redesignClasses.barWrapper,
|
redesignClasses.barWrapper,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'account__header__tabs',
|
'account__header__tabs',
|
||||||
isRedesign && redesignClasses.avatarWrapper,
|
redesignClasses.avatarWrapper,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
@ -157,33 +152,24 @@ export const AccountHeader: React.FC<{
|
|||||||
>
|
>
|
||||||
<Avatar
|
<Avatar
|
||||||
account={suspendedOrHidden ? undefined : account}
|
account={suspendedOrHidden ? undefined : account}
|
||||||
size={isRedesign ? 80 : 92}
|
size={80}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{!isRedesign && (
|
|
||||||
<AccountButtons
|
|
||||||
accountId={accountId}
|
|
||||||
className='account__header__buttons--desktop'
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'account__header__tabs__name',
|
'account__header__tabs__name',
|
||||||
isRedesign && redesignClasses.nameWrapper,
|
redesignClasses.nameWrapper,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<AccountName accountId={accountId} />
|
<AccountName accountId={accountId} />
|
||||||
{isRedesign && (
|
<AccountButtons
|
||||||
<AccountButtons
|
accountId={accountId}
|
||||||
accountId={accountId}
|
className={redesignClasses.buttonsDesktop}
|
||||||
className={redesignClasses.buttonsDesktop}
|
noShare={!isMe || 'share' in navigator}
|
||||||
noShare={!isMe || 'share' in navigator}
|
forceMenu={'share' in navigator}
|
||||||
forceMenu={'share' in navigator}
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AccountBadges accountId={accountId} />
|
<AccountBadges accountId={accountId} />
|
||||||
@ -192,58 +178,45 @@ export const AccountHeader: React.FC<{
|
|||||||
<FamiliarFollowers accountId={accountId} />
|
<FamiliarFollowers accountId={accountId} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!isRedesign && (
|
|
||||||
<AccountButtons
|
|
||||||
className='account__header__buttons--mobile'
|
|
||||||
accountId={accountId}
|
|
||||||
noShare
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!suspendedOrHidden && (
|
{!suspendedOrHidden && (
|
||||||
<div className='account__header__extra'>
|
<div className='account__header__extra'>
|
||||||
<div className='account__header__bio'>
|
<div className='account__header__bio'>
|
||||||
{me &&
|
{me && account.id !== me && (
|
||||||
account.id !== me &&
|
<AccountNoteRedesign accountId={accountId} />
|
||||||
(isRedesign ? (
|
)}
|
||||||
<AccountNoteRedesign accountId={accountId} />
|
|
||||||
) : (
|
|
||||||
<AccountNote accountId={accountId} />
|
|
||||||
))}
|
|
||||||
|
|
||||||
<AccountBio
|
<AccountBio
|
||||||
showDropdown
|
showDropdown
|
||||||
accountId={accountId}
|
accountId={accountId}
|
||||||
className={classNames(
|
className={classNames(
|
||||||
'account__header__content',
|
'account__header__content',
|
||||||
isRedesign && redesignClasses.bio,
|
redesignClasses.bio,
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<AccountHeaderFields accountId={accountId} />
|
<AccountHeaderFields accountId={accountId} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!me && account.email_subscriptions && (
|
{!me && account.email_subscriptions && (
|
||||||
<AccountSubscriptionForm accountId={accountId} />
|
<AccountSubscriptionForm accountId={accountId} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
<AccountNumberFields accountId={accountId} />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isRedesign && (
|
<AccountButtons
|
||||||
<AccountButtons
|
className={classNames(
|
||||||
className={classNames(
|
redesignClasses.buttonsMobile,
|
||||||
redesignClasses.buttonsMobile,
|
!isIntersecting && redesignClasses.buttonsMobileIsStuck,
|
||||||
!isIntersecting && redesignClasses.buttonsMobileIsStuck,
|
)}
|
||||||
)}
|
accountId={accountId}
|
||||||
accountId={accountId}
|
noShare
|
||||||
noShare
|
/>
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</AnimateEmojiProvider>
|
</AnimateEmojiProvider>
|
||||||
|
|
||||||
<ActionBar account={account} />
|
{!hideTabs && !hidden && <AccountTabs />}
|
||||||
|
|
||||||
{!hideTabs && !hidden && <AccountTabs acct={account.acct} />}
|
|
||||||
<div ref={observedRef} />
|
<div ref={observedRef} />
|
||||||
|
|
||||||
<Helmet>
|
<Helmet>
|
||||||
|
|||||||
@ -14,10 +14,6 @@ import { useAppSelector } from '@/flavours/glitch/store';
|
|||||||
import AtIcon from '@/material-icons/400-24px/alternate_email.svg?react';
|
import AtIcon from '@/material-icons/400-24px/alternate_email.svg?react';
|
||||||
import HelpIcon from '@/material-icons/400-24px/help.svg?react';
|
import HelpIcon from '@/material-icons/400-24px/help.svg?react';
|
||||||
import DomainIcon from '@/material-icons/400-24px/language.svg?react';
|
import DomainIcon from '@/material-icons/400-24px/language.svg?react';
|
||||||
import LockIcon from '@/material-icons/400-24px/lock.svg?react';
|
|
||||||
|
|
||||||
import { DomainPill } from '../../account/components/domain_pill';
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
|
|
||||||
import classes from './redesign.module.scss';
|
import classes from './redesign.module.scss';
|
||||||
|
|
||||||
@ -34,7 +30,6 @@ const messages = defineMessages({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const AccountName: FC<{ accountId: string }> = ({ accountId }) => {
|
export const AccountName: FC<{ accountId: string }> = ({ accountId }) => {
|
||||||
const intl = useIntl();
|
|
||||||
const account = useAccount(accountId);
|
const account = useAccount(accountId);
|
||||||
const me = useAppSelector((state) => state.meta.get('me') as string);
|
const me = useAppSelector((state) => state.meta.get('me') as string);
|
||||||
const localDomain = useAppSelector(
|
const localDomain = useAppSelector(
|
||||||
@ -47,32 +42,6 @@ export const AccountName: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
|
|
||||||
const [username = '', domain = localDomain] = account.acct.split('@');
|
const [username = '', domain = localDomain] = account.acct.split('@');
|
||||||
|
|
||||||
if (!isRedesignEnabled()) {
|
|
||||||
return (
|
|
||||||
<h1>
|
|
||||||
<DisplayName account={account} variant='simple' />
|
|
||||||
<small>
|
|
||||||
<span>
|
|
||||||
@{username}
|
|
||||||
<span className='invisible'>@{domain}</span>
|
|
||||||
</span>
|
|
||||||
<DomainPill
|
|
||||||
username={username}
|
|
||||||
domain={domain}
|
|
||||||
isSelf={me === account.id}
|
|
||||||
/>
|
|
||||||
{account.locked && (
|
|
||||||
<Icon
|
|
||||||
id='lock'
|
|
||||||
icon={LockIcon}
|
|
||||||
aria-label={intl.formatMessage(messages.lockedInfo)}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</small>
|
|
||||||
</h1>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classes.name}>
|
<div className={classes.name}>
|
||||||
<h1>
|
<h1>
|
||||||
|
|||||||
@ -20,8 +20,6 @@ import type { AccountRole } from '@/flavours/glitch/models/account';
|
|||||||
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
|
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
|
||||||
import IconPinned from '@/images/icons/icon_pinned.svg?react';
|
import IconPinned from '@/images/icons/icon_pinned.svg?react';
|
||||||
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
|
|
||||||
import classes from './redesign.module.scss';
|
import classes from './redesign.module.scss';
|
||||||
|
|
||||||
export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
||||||
@ -46,9 +44,6 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const isRedesign = isRedesignEnabled();
|
|
||||||
const className = isRedesign ? classes.badge : '';
|
|
||||||
|
|
||||||
const domain = account.acct.includes('@')
|
const domain = account.acct.includes('@')
|
||||||
? account.acct.split('@')[1]
|
? account.acct.split('@')[1]
|
||||||
: localDomain;
|
: localDomain;
|
||||||
@ -58,7 +53,7 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
<AdminBadge
|
<AdminBadge
|
||||||
key={role.id}
|
key={role.id}
|
||||||
label={role.name}
|
label={role.name}
|
||||||
className={className}
|
className={classes.badge}
|
||||||
domain={`(${domain})`}
|
domain={`(${domain})`}
|
||||||
roleId={role.id}
|
roleId={role.id}
|
||||||
/>,
|
/>,
|
||||||
@ -68,8 +63,8 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
<Badge
|
<Badge
|
||||||
key={role.id}
|
key={role.id}
|
||||||
label={role.name}
|
label={role.name}
|
||||||
className={className}
|
className={classes.badge}
|
||||||
domain={isRedesign ? `(${domain})` : domain}
|
domain={`(${domain})`}
|
||||||
roleId={role.id}
|
roleId={role.id}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
@ -77,17 +72,17 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (account.bot) {
|
if (account.bot) {
|
||||||
badges.push(<AutomatedBadge key='bot-badge' className={className} />);
|
badges.push(<AutomatedBadge key='bot-badge' className={classes.badge} />);
|
||||||
}
|
}
|
||||||
if (account.group) {
|
if (account.group) {
|
||||||
badges.push(<GroupBadge key='group-badge' className={className} />);
|
badges.push(<GroupBadge key='group-badge' className={classes.badge} />);
|
||||||
}
|
}
|
||||||
if (isRedesign && relationship) {
|
if (relationship) {
|
||||||
if (relationship.blocking) {
|
if (relationship.blocking) {
|
||||||
badges.push(
|
badges.push(
|
||||||
<BlockedBadge
|
<BlockedBadge
|
||||||
key='blocking'
|
key='blocking'
|
||||||
className={classNames(className, classes.badgeBlocked)}
|
className={classNames(classes.badge, classes.badgeBlocked)}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -95,7 +90,7 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
badges.push(
|
badges.push(
|
||||||
<BlockedBadge
|
<BlockedBadge
|
||||||
key='domain-blocking'
|
key='domain-blocking'
|
||||||
className={classNames(className, classes.badgeBlocked)}
|
className={classNames(classes.badge, classes.badgeBlocked)}
|
||||||
domain={domain}
|
domain={domain}
|
||||||
label={
|
label={
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
@ -110,7 +105,7 @@ export const AccountBadges: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
badges.push(
|
badges.push(
|
||||||
<MutedBadge
|
<MutedBadge
|
||||||
key='muted-badge'
|
key='muted-badge'
|
||||||
className={classNames(className, classes.badgeMuted)}
|
className={classNames(classes.badge, classes.badgeMuted)}
|
||||||
expiresAt={relationship.muting_expires_at}
|
expiresAt={relationship.muting_expires_at}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
@ -136,5 +131,5 @@ export const PinnedBadge: FC = () => (
|
|||||||
|
|
||||||
function isAdminBadge(role: AccountRole) {
|
function isAdminBadge(role: AccountRole) {
|
||||||
const name = role.name.toLowerCase();
|
const name = role.name.toLowerCase();
|
||||||
return isRedesignEnabled() && (name === 'admin' || name === 'owner');
|
return name === 'admin' || name === 'owner';
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,8 +16,6 @@ import NotificationsIcon from '@/material-icons/400-24px/notifications.svg?react
|
|||||||
import NotificationsActiveIcon from '@/material-icons/400-24px/notifications_active-fill.svg?react';
|
import NotificationsActiveIcon from '@/material-icons/400-24px/notifications_active-fill.svg?react';
|
||||||
import ShareIcon from '@/material-icons/400-24px/share.svg?react';
|
import ShareIcon from '@/material-icons/400-24px/share.svg?react';
|
||||||
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
|
|
||||||
import { AccountMenu } from './menu';
|
import { AccountMenu } from './menu';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
@ -97,7 +95,6 @@ const AccountButtonsOther: FC<
|
|||||||
accountId={accountId}
|
accountId={accountId}
|
||||||
className='account__header__follow-button'
|
className='account__header__follow-button'
|
||||||
labelLength='long'
|
labelLength='long'
|
||||||
withUnmute={!isRedesignEnabled()}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{isFollowing && (
|
{isFollowing && (
|
||||||
|
|||||||
@ -1,68 +1,30 @@
|
|||||||
import { useCallback, useMemo, useRef, useState } from 'react';
|
import { useCallback, useMemo, useRef, useState } from 'react';
|
||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
|
|
||||||
import { defineMessage, FormattedMessage, useIntl } from 'react-intl';
|
import { defineMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
|
||||||
import { openModal } from '@/flavours/glitch/actions/modal';
|
import { openModal } from '@/flavours/glitch/actions/modal';
|
||||||
import { AccountFields } from '@/flavours/glitch/components/account_fields';
|
|
||||||
import { CustomEmojiProvider } from '@/flavours/glitch/components/emoji/context';
|
import { CustomEmojiProvider } from '@/flavours/glitch/components/emoji/context';
|
||||||
import type { EmojiHTMLProps } from '@/flavours/glitch/components/emoji/html';
|
import type { EmojiHTMLProps } from '@/flavours/glitch/components/emoji/html';
|
||||||
import { EmojiHTML } from '@/flavours/glitch/components/emoji/html';
|
import { EmojiHTML } from '@/flavours/glitch/components/emoji/html';
|
||||||
import { FormattedDateWrapper } from '@/flavours/glitch/components/formatted_date';
|
|
||||||
import { Icon } from '@/flavours/glitch/components/icon';
|
import { Icon } from '@/flavours/glitch/components/icon';
|
||||||
import { IconButton } from '@/flavours/glitch/components/icon_button';
|
import { IconButton } from '@/flavours/glitch/components/icon_button';
|
||||||
import { MiniCard } from '@/flavours/glitch/components/mini_card';
|
import { MiniCard } from '@/flavours/glitch/components/mini_card';
|
||||||
import { useElementHandledLink } from '@/flavours/glitch/components/status/handled_link';
|
import { useElementHandledLink } from '@/flavours/glitch/components/status/handled_link';
|
||||||
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
||||||
import { useResizeObserver } from '@/flavours/glitch/hooks/useObserver';
|
import { useResizeObserver } from '@/flavours/glitch/hooks/useObserver';
|
||||||
import type { Account } from '@/flavours/glitch/models/account';
|
|
||||||
import { useAppDispatch } from '@/flavours/glitch/store';
|
import { useAppDispatch } from '@/flavours/glitch/store';
|
||||||
import IconVerified from '@/images/icons/icon_verified.svg?react';
|
import IconVerified from '@/images/icons/icon_verified.svg?react';
|
||||||
import MoreIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
import MoreIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
||||||
|
|
||||||
import { cleanExtraEmojis } from '../../emoji/normalize';
|
import { cleanExtraEmojis } from '../../emoji/normalize';
|
||||||
import type { AccountField } from '../common';
|
import type { AccountField } from '../common';
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
import { useFieldHtml } from '../hooks/useFieldHtml';
|
import { useFieldHtml } from '../hooks/useFieldHtml';
|
||||||
|
|
||||||
import classes from './redesign.module.scss';
|
import classes from './redesign.module.scss';
|
||||||
|
|
||||||
export const AccountHeaderFields: FC<{ accountId: string }> = ({
|
|
||||||
accountId,
|
|
||||||
}) => {
|
|
||||||
const account = useAccount(accountId);
|
|
||||||
|
|
||||||
if (!account) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRedesignEnabled()) {
|
|
||||||
return <RedesignAccountHeaderFields account={account} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='account__header__fields'>
|
|
||||||
<dl>
|
|
||||||
<dt>
|
|
||||||
<FormattedMessage id='account.joined_short' defaultMessage='Joined' />
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<FormattedDateWrapper
|
|
||||||
value={account.created_at}
|
|
||||||
year='numeric'
|
|
||||||
month='short'
|
|
||||||
day='2-digit'
|
|
||||||
/>
|
|
||||||
</dd>
|
|
||||||
</dl>
|
|
||||||
|
|
||||||
<AccountFields fields={account.fields} emojis={account.emojis} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const verifyMessage = defineMessage({
|
const verifyMessage = defineMessage({
|
||||||
id: 'account.link_verified_on',
|
id: 'account.link_verified_on',
|
||||||
defaultMessage: 'Ownership of this link was checked on {date}',
|
defaultMessage: 'Ownership of this link was checked on {date}',
|
||||||
@ -75,13 +37,22 @@ const dateFormatOptions: Intl.DateTimeFormatOptions = {
|
|||||||
minute: '2-digit',
|
minute: '2-digit',
|
||||||
};
|
};
|
||||||
|
|
||||||
const RedesignAccountHeaderFields: FC<{ account: Account }> = ({ account }) => {
|
export const AccountHeaderFields: FC<{ accountId: string }> = ({
|
||||||
|
accountId,
|
||||||
|
}) => {
|
||||||
|
const account = useAccount(accountId);
|
||||||
|
|
||||||
const emojis = useMemo(
|
const emojis = useMemo(
|
||||||
() => cleanExtraEmojis(account.emojis),
|
() => cleanExtraEmojis(account?.emojis),
|
||||||
[account.emojis],
|
[account?.emojis],
|
||||||
);
|
);
|
||||||
|
const accountFields = account?.fields;
|
||||||
const fields: AccountField[] = useMemo(() => {
|
const fields: AccountField[] = useMemo(() => {
|
||||||
const fields = account.fields.toJS();
|
const fields = accountFields?.toJS();
|
||||||
|
if (!fields) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
if (!emojis) {
|
if (!emojis) {
|
||||||
return fields.map((field) => ({
|
return fields.map((field) => ({
|
||||||
...field,
|
...field,
|
||||||
@ -102,10 +73,10 @@ const RedesignAccountHeaderFields: FC<{ account: Account }> = ({ account }) => {
|
|||||||
field.value_plain?.includes(`:${code}:`),
|
field.value_plain?.includes(`:${code}:`),
|
||||||
),
|
),
|
||||||
}));
|
}));
|
||||||
}, [account.fields, emojis]);
|
}, [accountFields, emojis]);
|
||||||
|
|
||||||
const htmlHandlers = useElementHandledLink({
|
const htmlHandlers = useElementHandledLink({
|
||||||
hashtagAccountId: account.id,
|
hashtagAccountId: account?.id,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { wrapperRef } = useColumnWrap();
|
const { wrapperRef } = useColumnWrap();
|
||||||
|
|||||||
@ -4,13 +4,9 @@ import { FormattedMessage } from 'react-intl';
|
|||||||
|
|
||||||
import type { Relationship } from '@/flavours/glitch/models/relationship';
|
import type { Relationship } from '@/flavours/glitch/models/relationship';
|
||||||
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
|
|
||||||
export const AccountInfo: FC<{ relationship?: Relationship }> = ({
|
export const AccountInfo: FC<{ relationship?: Relationship }> = ({
|
||||||
relationship,
|
relationship,
|
||||||
}) => {
|
}) => {
|
||||||
const isRedesign = isRedesignEnabled();
|
|
||||||
|
|
||||||
if (!relationship) {
|
if (!relationship) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -21,17 +17,17 @@ export const AccountInfo: FC<{ relationship?: Relationship }> = ({
|
|||||||
<AccountInfoFollower relationship={relationship} />
|
<AccountInfoFollower relationship={relationship} />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{!isRedesign && relationship.blocking && (
|
{relationship.blocking && (
|
||||||
<span className='relationship-tag'>
|
<span className='relationship-tag'>
|
||||||
<FormattedMessage id='account.blocking' defaultMessage='Blocking' />
|
<FormattedMessage id='account.blocking' defaultMessage='Blocking' />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{!isRedesign && relationship.muting && (
|
{relationship.muting && (
|
||||||
<span key='muting' className='relationship-tag'>
|
<span key='muting' className='relationship-tag'>
|
||||||
<FormattedMessage id='account.muting' defaultMessage='Muting' />
|
<FormattedMessage id='account.muting' defaultMessage='Muting' />
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
{!isRedesign && relationship.domain_blocking && (
|
{relationship.domain_blocking && (
|
||||||
<span key='domain_blocking' className='relationship-tag'>
|
<span key='domain_blocking' className='relationship-tag'>
|
||||||
<FormattedMessage
|
<FormattedMessage
|
||||||
id='account.domain_blocking'
|
id='account.domain_blocking'
|
||||||
|
|||||||
@ -43,8 +43,6 @@ import PersonRemoveIcon from '@/material-icons/400-24px/person_remove.svg?react'
|
|||||||
import ReportIcon from '@/material-icons/400-24px/report.svg?react';
|
import ReportIcon from '@/material-icons/400-24px/report.svg?react';
|
||||||
import ShareIcon from '@/material-icons/400-24px/share.svg?react';
|
import ShareIcon from '@/material-icons/400-24px/share.svg?react';
|
||||||
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
|
|
||||||
import classes from './redesign.module.scss';
|
import classes from './redesign.module.scss';
|
||||||
|
|
||||||
export const AccountMenu: FC<{ accountId: string }> = ({ accountId }) => {
|
export const AccountMenu: FC<{ accountId: string }> = ({ accountId }) => {
|
||||||
@ -66,19 +64,9 @@ export const AccountMenu: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isRedesignEnabled()) {
|
return redesignMenuItems({
|
||||||
return redesignMenuItems({
|
|
||||||
account,
|
|
||||||
signedIn: !isMe && signedIn,
|
|
||||||
permissions,
|
|
||||||
intl,
|
|
||||||
relationship,
|
|
||||||
dispatch,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return currentMenuItems({
|
|
||||||
account,
|
account,
|
||||||
signedIn,
|
signedIn: !isMe && signedIn,
|
||||||
permissions,
|
permissions,
|
||||||
intl,
|
intl,
|
||||||
relationship,
|
relationship,
|
||||||
@ -181,270 +169,6 @@ const messages = defineMessages({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function currentMenuItems({
|
|
||||||
account,
|
|
||||||
signedIn,
|
|
||||||
permissions,
|
|
||||||
intl,
|
|
||||||
relationship,
|
|
||||||
dispatch,
|
|
||||||
}: MenuItemsParams): MenuItem[] {
|
|
||||||
const items: MenuItem[] = [];
|
|
||||||
const isRemote = account.acct !== account.username;
|
|
||||||
|
|
||||||
if (signedIn && !account.suspended) {
|
|
||||||
items.push(
|
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.mention, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(mentionCompose(account));
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.direct, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(directCompose(account));
|
|
||||||
},
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isRemote) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.openOriginalPage),
|
|
||||||
href: account.url,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (signedIn) {
|
|
||||||
items.push(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!signedIn) {
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relationship?.following) {
|
|
||||||
// Timeline options
|
|
||||||
if (!relationship.muting) {
|
|
||||||
if (relationship.showing_reblogs) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.hideReblogs, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(followAccount(account.id, { reblogs: false }));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.showReblogs, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(followAccount(account.id, { reblogs: true }));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
items.push(
|
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.languages),
|
|
||||||
action: () => {
|
|
||||||
dispatch(
|
|
||||||
openModal({
|
|
||||||
modalType: 'SUBSCRIBED_LANGUAGES',
|
|
||||||
modalProps: {
|
|
||||||
accountId: account.id,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
items.push(
|
|
||||||
{
|
|
||||||
text: intl.formatMessage(
|
|
||||||
relationship.endorsed ? messages.unendorse : messages.endorse,
|
|
||||||
),
|
|
||||||
action: () => {
|
|
||||||
if (relationship.endorsed) {
|
|
||||||
dispatch(unpinAccount(account.id));
|
|
||||||
} else {
|
|
||||||
dispatch(pinAccount(account.id));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: intl.formatMessage(messages.add_or_remove_from_list),
|
|
||||||
action: () => {
|
|
||||||
dispatch(
|
|
||||||
openModal({
|
|
||||||
modalType: 'LIST_ADDER',
|
|
||||||
modalProps: {
|
|
||||||
accountId: account.id,
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relationship?.followed_by) {
|
|
||||||
const handleRemoveFromFollowers = () => {
|
|
||||||
dispatch(
|
|
||||||
openModal({
|
|
||||||
modalType: 'CONFIRM',
|
|
||||||
modalProps: {
|
|
||||||
title: intl.formatMessage(messages.confirmRemoveFromFollowersTitle),
|
|
||||||
message: intl.formatMessage(
|
|
||||||
messages.confirmRemoveFromFollowersMessage,
|
|
||||||
{ name: <strong>{account.acct}</strong> },
|
|
||||||
),
|
|
||||||
confirm: intl.formatMessage(
|
|
||||||
messages.confirmRemoveFromFollowersButton,
|
|
||||||
),
|
|
||||||
onConfirm: () => {
|
|
||||||
void dispatch(
|
|
||||||
removeAccountFromFollowers({ accountId: account.id }),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.removeFromFollowers, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: handleRemoveFromFollowers,
|
|
||||||
dangerous: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relationship?.muting) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.unmute, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(unmuteAccount(account.id));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.mute, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(initMuteModal(account));
|
|
||||||
},
|
|
||||||
dangerous: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (relationship?.blocking) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.unblock, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(unblockAccount(account.id));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.block, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(blockAccount(account.id));
|
|
||||||
},
|
|
||||||
dangerous: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!account.suspended) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.report, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(initReport(account));
|
|
||||||
},
|
|
||||||
dangerous: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const remoteDomain = isRemote ? account.acct.split('@')[1] : null;
|
|
||||||
if (remoteDomain) {
|
|
||||||
items.push(null);
|
|
||||||
|
|
||||||
if (relationship?.domain_blocking) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.unblockDomain, {
|
|
||||||
domain: remoteDomain,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(unblockDomain(remoteDomain));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.blockDomain, {
|
|
||||||
domain: remoteDomain,
|
|
||||||
}),
|
|
||||||
action: () => {
|
|
||||||
dispatch(initDomainBlockModal(account));
|
|
||||||
},
|
|
||||||
dangerous: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
|
||||||
(permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS ||
|
|
||||||
(isRemote &&
|
|
||||||
(permissions & PERMISSION_MANAGE_FEDERATION) ===
|
|
||||||
PERMISSION_MANAGE_FEDERATION)
|
|
||||||
) {
|
|
||||||
items.push(null);
|
|
||||||
if ((permissions & PERMISSION_MANAGE_USERS) === PERMISSION_MANAGE_USERS) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.admin_account, {
|
|
||||||
name: account.username,
|
|
||||||
}),
|
|
||||||
href: `/admin/accounts/${account.id}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
isRemote &&
|
|
||||||
(permissions & PERMISSION_MANAGE_FEDERATION) ===
|
|
||||||
PERMISSION_MANAGE_FEDERATION
|
|
||||||
) {
|
|
||||||
items.push({
|
|
||||||
text: intl.formatMessage(messages.admin_domain, {
|
|
||||||
domain: remoteDomain,
|
|
||||||
}),
|
|
||||||
href: `/admin/instances/${remoteDomain}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return items;
|
|
||||||
}
|
|
||||||
|
|
||||||
const redesignMessages = defineMessages({
|
const redesignMessages = defineMessages({
|
||||||
share: { id: 'account.menu.share', defaultMessage: 'Share…' },
|
share: { id: 'account.menu.share', defaultMessage: 'Share…' },
|
||||||
copy: { id: 'account.menu.copy', defaultMessage: 'Copy link' },
|
copy: { id: 'account.menu.copy', defaultMessage: 'Copy link' },
|
||||||
|
|||||||
@ -3,13 +3,6 @@ import type { FC } from 'react';
|
|||||||
|
|
||||||
import { FormattedMessage, useIntl } from 'react-intl';
|
import { FormattedMessage, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { NavLink } from 'react-router-dom';
|
|
||||||
|
|
||||||
import {
|
|
||||||
FollowersCounter,
|
|
||||||
FollowingCounter,
|
|
||||||
StatusesCounter,
|
|
||||||
} from '@/flavours/glitch/components/counters';
|
|
||||||
import { FormattedDateWrapper } from '@/flavours/glitch/components/formatted_date';
|
import { FormattedDateWrapper } from '@/flavours/glitch/components/formatted_date';
|
||||||
import {
|
import {
|
||||||
NumberFields,
|
NumberFields,
|
||||||
@ -18,54 +11,9 @@ import {
|
|||||||
import { ShortNumber } from '@/flavours/glitch/components/short_number';
|
import { ShortNumber } from '@/flavours/glitch/components/short_number';
|
||||||
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
||||||
|
|
||||||
import { isRedesignEnabled } from '../common';
|
export const AccountNumberFields: FC<{ accountId: string }> = ({
|
||||||
|
accountId,
|
||||||
const LegacyNumberFields: FC<{ accountId: string }> = ({ accountId }) => {
|
}) => {
|
||||||
const intl = useIntl();
|
|
||||||
const account = useAccount(accountId);
|
|
||||||
|
|
||||||
if (!account) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className='account__header__extra__links'>
|
|
||||||
<NavLink
|
|
||||||
to={`/@${account.acct}`}
|
|
||||||
title={intl.formatNumber(account.statuses_count)}
|
|
||||||
>
|
|
||||||
<ShortNumber
|
|
||||||
value={account.statuses_count}
|
|
||||||
renderer={StatusesCounter}
|
|
||||||
/>
|
|
||||||
</NavLink>
|
|
||||||
|
|
||||||
<NavLink
|
|
||||||
exact
|
|
||||||
to={`/@${account.acct}/following`}
|
|
||||||
title={intl.formatNumber(account.following_count)}
|
|
||||||
>
|
|
||||||
<ShortNumber
|
|
||||||
value={account.following_count}
|
|
||||||
renderer={FollowingCounter}
|
|
||||||
/>
|
|
||||||
</NavLink>
|
|
||||||
|
|
||||||
<NavLink
|
|
||||||
exact
|
|
||||||
to={`/@${account.acct}/followers`}
|
|
||||||
title={intl.formatNumber(account.followers_count)}
|
|
||||||
>
|
|
||||||
<ShortNumber
|
|
||||||
value={account.followers_count}
|
|
||||||
renderer={FollowersCounter}
|
|
||||||
/>
|
|
||||||
</NavLink>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const RedesignNumberFields: FC<{ accountId: string }> = ({ accountId }) => {
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const account = useAccount(accountId);
|
const account = useAccount(accountId);
|
||||||
const createdThisYear = useMemo(
|
const createdThisYear = useMemo(
|
||||||
@ -125,7 +73,3 @@ const RedesignNumberFields: FC<{ accountId: string }> = ({ accountId }) => {
|
|||||||
</NumberFields>
|
</NumberFields>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const AccountNumberFields = isRedesignEnabled()
|
|
||||||
? RedesignNumberFields
|
|
||||||
: LegacyNumberFields;
|
|
||||||
|
|||||||
@ -8,40 +8,13 @@ import { NavLink } from 'react-router-dom';
|
|||||||
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
import { useAccount } from '@/flavours/glitch/hooks/useAccount';
|
||||||
import { useAccountId } from '@/flavours/glitch/hooks/useAccountId';
|
import { useAccountId } from '@/flavours/glitch/hooks/useAccountId';
|
||||||
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
|
|
||||||
import classes from './redesign.module.scss';
|
import classes from './redesign.module.scss';
|
||||||
|
|
||||||
export const AccountTabs: FC<{ acct: string }> = ({ acct }) => {
|
|
||||||
if (isRedesignEnabled()) {
|
|
||||||
return <RedesignTabs />;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className='account__section-headline'>
|
|
||||||
<NavLink exact to={`/@${acct}/featured`}>
|
|
||||||
<FormattedMessage id='account.featured' defaultMessage='Featured' />
|
|
||||||
</NavLink>
|
|
||||||
<NavLink exact to={`/@${acct}`}>
|
|
||||||
<FormattedMessage id='account.posts' defaultMessage='Posts' />
|
|
||||||
</NavLink>
|
|
||||||
<NavLink exact to={`/@${acct}/with_replies`}>
|
|
||||||
<FormattedMessage
|
|
||||||
id='account.posts_with_replies'
|
|
||||||
defaultMessage='Posts and replies'
|
|
||||||
/>
|
|
||||||
</NavLink>
|
|
||||||
<NavLink exact to={`/@${acct}/media`}>
|
|
||||||
<FormattedMessage id='account.media' defaultMessage='Media' />
|
|
||||||
</NavLink>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isActive: Required<NavLinkProps>['isActive'] = (match, location) =>
|
const isActive: Required<NavLinkProps>['isActive'] = (match, location) =>
|
||||||
match?.url === location.pathname ||
|
match?.url === location.pathname ||
|
||||||
(!!match?.url && location.pathname.startsWith(`${match.url}/tagged/`));
|
(!!match?.url && location.pathname.startsWith(`${match.url}/tagged/`));
|
||||||
|
|
||||||
const RedesignTabs: FC = () => {
|
export const AccountTabs: FC = () => {
|
||||||
const accountId = useAccountId();
|
const accountId = useAccountId();
|
||||||
const account = useAccount(accountId);
|
const account = useAccount(accountId);
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,7 @@ export const AccountFilters: FC = () => {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<AccountTabs acct={acct} />
|
<AccountTabs />
|
||||||
<div className={classes.filtersWrapper}>
|
<div className={classes.filtersWrapper}>
|
||||||
<FilterDropdown />
|
<FilterDropdown />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import { selectTimelineByKey } from '@/flavours/glitch/selectors/timelines';
|
|||||||
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
|
import { useAppDispatch, useAppSelector } from '@/flavours/glitch/store';
|
||||||
import IconPinned from '@/images/icons/icon_pinned.svg?react';
|
import IconPinned from '@/images/icons/icon_pinned.svg?react';
|
||||||
|
|
||||||
import { isRedesignEnabled } from '../common';
|
|
||||||
import { PinnedBadge } from '../components/badges';
|
import { PinnedBadge } from '../components/badges';
|
||||||
|
|
||||||
import { useAccountContext } from './context';
|
import { useAccountContext } from './context';
|
||||||
@ -88,10 +87,6 @@ export const renderPinnedStatusHeader: StatusHeaderRenderFn = ({
|
|||||||
export const PinnedShowAllButton: FC = () => {
|
export const PinnedShowAllButton: FC = () => {
|
||||||
const { onShowAllPinned } = useAccountContext();
|
const { onShowAllPinned } = useAccountContext();
|
||||||
|
|
||||||
if (!isRedesignEnabled()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
onClick={onShowAllPinned}
|
onClick={onShowAllPinned}
|
||||||
|
|||||||
@ -27,7 +27,6 @@ import { layoutFromWindow } from 'flavours/glitch/is_mobile';
|
|||||||
import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications';
|
import { selectUnreadNotificationGroupsCount } from 'flavours/glitch/selectors/notifications';
|
||||||
import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
|
import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
|
||||||
import { checkAnnualReport } from '@/flavours/glitch/reducers/slices/annual_report';
|
import { checkAnnualReport } from '@/flavours/glitch/reducers/slices/annual_report';
|
||||||
import { isServerFeatureEnabled } from '@/flavours/glitch/utils/environment';
|
|
||||||
|
|
||||||
import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../actions/compose';
|
import { uploadCompose, resetCompose, changeComposeSpoilerness } from '../../actions/compose';
|
||||||
import { clearHeight } from '../../actions/height_cache';
|
import { clearHeight } from '../../actions/height_cache';
|
||||||
@ -190,20 +189,6 @@ class SwitchingColumnsArea extends PureComponent {
|
|||||||
rootRedirect = '/about';
|
rootRedirect = '/about';
|
||||||
}
|
}
|
||||||
|
|
||||||
const profileRedesignRoutes = [];
|
|
||||||
if (isServerFeatureEnabled('profile_redesign')) {
|
|
||||||
profileRedesignRoutes.push(
|
|
||||||
<WrappedRoute key="edit" path='/profile/edit' component={AccountEdit} content={children} />,
|
|
||||||
<WrappedRoute key="featured_tags" path='/profile/featured_tags' component={AccountEditFeaturedTags} content={children} />
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
// If profile editing is not enabled, redirect to the home timeline as the current editing pages are outside React Router.
|
|
||||||
profileRedesignRoutes.push(
|
|
||||||
<Redirect key="edit-redirect" from='/profile/edit' to='/' exact />,
|
|
||||||
<Redirect key="featured-tags-redirect" from='/profile/featured_tags' to='/' exact />,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ColumnsContextProvider multiColumn={!singleColumn}>
|
<ColumnsContextProvider multiColumn={!singleColumn}>
|
||||||
<ColumnsArea ref={this.setRef} singleColumn={singleColumn}>
|
<ColumnsArea ref={this.setRef} singleColumn={singleColumn}>
|
||||||
@ -250,7 +235,8 @@ class SwitchingColumnsArea extends PureComponent {
|
|||||||
<WrappedRoute path='/search' component={Search} content={children} />
|
<WrappedRoute path='/search' component={Search} content={children} />
|
||||||
<WrappedRoute path={['/publish', '/statuses/new']} component={Compose} content={children} />
|
<WrappedRoute path={['/publish', '/statuses/new']} component={Compose} content={children} />
|
||||||
|
|
||||||
{...profileRedesignRoutes}
|
<WrappedRoute path='/profile/edit' component={AccountEdit} content={children} />
|
||||||
|
<WrappedRoute path='/profile/featured_tags' component={AccountEditFeaturedTags} content={children} />
|
||||||
|
|
||||||
<WrappedRoute path={['/@:acct', '/accounts/:id']} exact component={AccountTimeline} content={children} />
|
<WrappedRoute path={['/@:acct', '/accounts/:id']} exact component={AccountTimeline} content={children} />
|
||||||
<WrappedRoute path={['/@:acct/featured', '/accounts/:id/featured']} component={AccountFeatured} content={children} />
|
<WrappedRoute path={['/@:acct/featured', '/accounts/:id/featured']} component={AccountFeatured} content={children} />
|
||||||
|
|||||||
@ -1,5 +1,3 @@
|
|||||||
import { isServerFeatureEnabled } from '@/flavours/glitch/utils/environment';
|
|
||||||
|
|
||||||
export function EmojiPicker () {
|
export function EmojiPicker () {
|
||||||
return import('../../emoji/emoji_picker');
|
return import('../../emoji/emoji_picker');
|
||||||
}
|
}
|
||||||
@ -79,10 +77,7 @@ export function PinnedStatuses () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function AccountTimeline () {
|
export function AccountTimeline () {
|
||||||
if (isServerFeatureEnabled('profile_redesign')) {
|
return import('../../account_timeline/v2');
|
||||||
return import('../../account_timeline/v2');
|
|
||||||
}
|
|
||||||
return import('../../account_timeline');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AccountGallery () {
|
export function AccountGallery () {
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export function isProduction() {
|
|||||||
else return import.meta.env.PROD;
|
else return import.meta.env.PROD;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ServerFeatures = 'fasp' | 'collections' | 'profile_redesign';
|
export type ServerFeatures = 'fasp' | 'collections';
|
||||||
|
|
||||||
export function isServerFeatureEnabled(feature: ServerFeatures) {
|
export function isServerFeatureEnabled(feature: ServerFeatures) {
|
||||||
return initialState?.features.includes(feature) ?? false;
|
return initialState?.features.includes(feature) ?? false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user