Skip to content

Commit

Permalink
fixup! [WiP] Get rid of the infamous parseClick
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Dec 21, 2024
1 parent d287f02 commit fb79f2c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 59 deletions.
49 changes: 42 additions & 7 deletions app/javascript/flavours/glitch/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ 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 { DisplayName } from './display_name';
import { getHashtagBarForStatus } from './hashtag_bar';
import StatusActionBar from './status_action_bar';
import StatusContent from './status_content';
import StatusHeader from './status_header';
import StatusIcons from './status_icons';
import StatusPrepend from './status_prepend';

Expand Down Expand Up @@ -278,6 +280,19 @@ class Status extends ImmutablePureComponent {
this.handleHotkeyOpen();
};

handleAccountClick = (e, proper = true) => {
if (e && (e.button !== 0 || e.ctrlKey || e.metaKey)) {
return;
}

if (e) {
e.preventDefault();
e.stopPropagation();
}

this._openProfile(proper);
};

handleExpandedToggle = () => {
if (this.props.settings.getIn(['content_warnings', 'shared_state'])) {
this.props.onToggleHidden(this.props.status);
Expand Down Expand Up @@ -359,7 +374,18 @@ class Status extends ImmutablePureComponent {
};

handleHotkeyOpenProfile = () => {
this.props.history.push(`/@${this.props.status.getIn(['account', 'acct'])}`);
this._openProfile();
};

_openProfile = () => {
const { history } = this.props;
const status = this.props.status;

if (!history) {
return;
}

history.push(`/@${status.getIn(['account', 'acct'])}`);
};

handleHotkeyMoveUp = e => {
Expand Down Expand Up @@ -429,6 +455,7 @@ class Status extends ImmutablePureComponent {
let extraMediaIcons = [];
let media = contentMedia;
let mediaIcons = contentMediaIcons;
let statusAvatar;

if (settings.getIn(['content_warnings', 'media_outside'])) {
media = extraMedia;
Expand Down Expand Up @@ -636,6 +663,12 @@ 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);
contentMedia.push(hashtagBar);

Expand All @@ -661,11 +694,13 @@ class Status extends ImmutablePureComponent {
{(!muted) && (
/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */
<header onClick={this.handleClick} className='status__info'>
<StatusHeader
status={status}
friend={account}
avatarSize={avatarSize}
/>
<a onClick={this.handleAccountClick} href={status.getIn(['account', 'url'])} title={status.getIn(['account', 'acct'])} data-hover-card-account={status.getIn(['account', 'id'])} className='status__display-name' target='_blank' rel='noopener noreferrer'>
<div className='status__avatar'>
{statusAvatar}
</div>

<DisplayName account={status.get('account')} />
</a>
<StatusIcons
status={status}
mediaIcons={contentMediaIcons.concat(extraMediaIcons)}
Expand Down
52 changes: 0 additions & 52 deletions app/javascript/flavours/glitch/components/status_header.jsx

This file was deleted.

0 comments on commit fb79f2c

Please sign in to comment.