mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-07 19:05:08 +01:00
Refactor status handleClick
and handleHotkeyOpen
handlers (#33435)
This commit is contained in:
parent
af7d6e59af
commit
9712518b2f
@ -167,7 +167,12 @@ class Status extends ImmutablePureComponent {
|
|||||||
|
|
||||||
handleClick = e => {
|
handleClick = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.handleHotkeyOpen(e);
|
|
||||||
|
if (e?.button === 0 && !(e?.ctrlKey || e?.metaKey)) {
|
||||||
|
this._openStatus();
|
||||||
|
} else if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) {
|
||||||
|
this._openStatus(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMouseUp = e => {
|
handleMouseUp = e => {
|
||||||
@ -275,7 +280,11 @@ class Status extends ImmutablePureComponent {
|
|||||||
this.props.onMention(this._properStatus().get('account'));
|
this.props.onMention(this._properStatus().get('account'));
|
||||||
};
|
};
|
||||||
|
|
||||||
handleHotkeyOpen = (e) => {
|
handleHotkeyOpen = () => {
|
||||||
|
this._openStatus();
|
||||||
|
};
|
||||||
|
|
||||||
|
_openStatus = (newTab = false) => {
|
||||||
if (this.props.onClick) {
|
if (this.props.onClick) {
|
||||||
this.props.onClick();
|
this.props.onClick();
|
||||||
return;
|
return;
|
||||||
@ -290,7 +299,7 @@ class Status extends ImmutablePureComponent {
|
|||||||
|
|
||||||
const path = `/@${status.getIn(['account', 'acct'])}/${status.get('id')}`;
|
const path = `/@${status.getIn(['account', 'acct'])}/${status.get('id')}`;
|
||||||
|
|
||||||
if (e?.button === 1 || (e?.button === 0 && (e?.ctrlKey || e?.metaKey))) {
|
if (newTab) {
|
||||||
window.open(path, '_blank', 'noopener');
|
window.open(path, '_blank', 'noopener');
|
||||||
} else {
|
} else {
|
||||||
history.push(path);
|
history.push(path);
|
||||||
|
Loading…
Reference in New Issue
Block a user