[Glitch] Refactors header from Status component

Port 7f53a77fa3 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo authored and Claire committed 2026-02-04 20:01:33 +01:00
1 parent 072c30681e
commit 84cc0dcac4
3 files changed
+180 -49

No files matched your search

@@ -7,7 +7,6 @@ import classNames from 'classnames';
import ImmutablePropTypes from 'react-immutable-proptypes';
import ImmutablePureComponent from 'react-immutable-pure-component';
import CancelFillIcon from '@/material-icons/400-24px/cancel-fill.svg?react';
import { Hotkeys } from 'flavours/glitch/components/hotkeys';
import { ContentWarning } from 'flavours/glitch/components/content_warning';
import { PictureInPicturePlaceholder } from 'flavours/glitch/components/picture_in_picture_placeholder';
@@ -23,16 +22,13 @@ import { SensitiveMediaContext } from '../features/ui/util/sensitive_media_conte
import { displayMedia } from '../initial_state';
import AttachmentList from './attachment_list';
import { Avatar } from './avatar';
import { AvatarOverlay } from './avatar_overlay';
import { LinkedDisplayName } from './display_name';
import { StatusHeader } from './status/header'
import { getHashtagBarForStatus } from './hashtag_bar';
import { MentionsPlaceholder } from './mentions_placeholder';
import StatusActionBar from './status_action_bar';
import StatusContent from './status_content';
import StatusIcons from './status_icons';
import StatusPrepend from './status_prepend';
import { IconButton } from './icon_button';
const domParser = new DOMParser();
@@ -111,7 +107,6 @@ class Status extends ImmutablePureComponent {
onToggleCollapsed: PropTypes.func,
onTranslate: PropTypes.func,
onInteractionModal: PropTypes.func,
onQuoteCancel: PropTypes.func,
muted: PropTypes.bool,
hidden: PropTypes.bool,
unread: PropTypes.bool,
@@ -130,6 +125,8 @@ class Status extends ImmutablePureComponent {
skipPrepend: PropTypes.bool,
avatarSize: PropTypes.number,
deployPictureInPicture: PropTypes.func,
unfocusable: PropTypes.bool,
headerRenderFn: PropTypes.func,
settings: ImmutablePropTypes.map.isRequired,
pictureInPicture: ImmutablePropTypes.contains({
inUse: PropTypes.bool,
@@ -160,7 +157,6 @@ class Status extends ImmutablePureComponent {
'expanded',
'unread',
'pictureInPicture',
'onQuoteCancel',
'previousId',
'nextInReplyToId',
'rootId',
@@ -342,10 +338,6 @@ class Status extends ImmutablePureComponent {
deployPictureInPicture(status, type, mediaProps);
};
handleQuoteCancel = () => {
this.props.onQuoteCancel?.();
}
handleHotkeyReply = e => {
e.preventDefault();
this.props.onReply(this.props.status);
@@ -455,27 +447,39 @@ class Status extends ImmutablePureComponent {
}
render () {
const { intl, hidden, featured, unfocusable, unread, pictureInPicture, previousId, nextInReplyToId, rootId, skipPrepend, avatarSize = 46, children } = this.props;
const {
intl,
hidden,
featured,
unfocusable,
unread,
showActions = true,
isQuotedPost = false,
pictureInPicture,
previousId,
nextInReplyToId,
rootId,
skipPrepend,
avatarSize = 46,
children,
} = this.props;
// glitch-soc-specific
const {
status,
account,
settings,
muted,
intersectionObserverWrapper,
onOpenVideo,
onOpenMedia,
notification,
history,
showActions = true,
isQuotedPost = false,
...other
} = this.props;
let attachments = null;
let media = [];
let mediaIcons = [];
let statusAvatar;
if (status === null) {
return null;
@@ -678,14 +682,25 @@ class Status extends ImmutablePureComponent {
rebloggedByText = intl.formatMessage({ id: 'status.reblogged_by', defaultMessage: '{name} boosted' }, { name: account.get('acct') });
}
if (account === undefined || account === null) {
statusAvatar = <Avatar account={status.get('account')} size={avatarSize} />;
} else {
statusAvatar = <AvatarOverlay account={status.get('account')} friend={account} />;
}
const {statusContentProps, hashtagBar} = getHashtagBarForStatus(status);
const header = this.props.headerRenderFn
? this.props.headerRenderFn({ status, account, avatarSize, messages, onHeaderClick: this.handleHeaderClick })
: (
<StatusHeader
status={status}
account={account}
avatarSize={avatarSize}
onHeaderClick={this.handleHeaderClick}
>
<StatusIcons
status={status}
mediaIcons={mediaIcons}
settings={settings.get('status_icons')}
/>
</StatusHeader>
);
return (
<Hotkeys handlers={handlers} focusable={!unfocusable}>
<div
@@ -716,31 +731,7 @@ class Status extends ImmutablePureComponent {
>
{(connectReply || connectUp || connectToRoot) && <div className={classNames('status__line', { 'status__line--full': connectReply, 'status__line--first': !status.get('in_reply_to_id') && !connectToRoot })} />}
{(!muted) && (
<header onClick={this.handleHeaderClick} onAuxClick={this.handleHeaderClick} className='status__info'>
<LinkedDisplayName displayProps={{account: status.get('account')}} className='status__display-name'>
<div className='status__avatar'>
{statusAvatar}
</div>
</LinkedDisplayName>
{isQuotedPost && !!this.props.onQuoteCancel ? (
<IconButton
onClick={this.handleQuoteCancel}
className='status__quote-cancel'
title={intl.formatMessage(messages.quote_cancel)}
icon="cancel-fill"
iconComponent={CancelFillIcon}
/>
) : (
<StatusIcons
status={status}
mediaIcons={mediaIcons}
settings={settings.get('status_icons')}
/>
)}
</header>
)}
{(!muted) && header}
<ContentWarning status={status} expanded={expanded} onClick={this.handleExpandedToggle} icons={mediaIcons} />