mirror of
https://github.com/kikobar/mastodon.git
synced 2024-11-05 17:31:51 +00:00
Fix the hot key (j, k) does not function correctly when there is a pinned toot in account timeline. (#7202)
* Fix the hot key (j, k) does not function correctly when there is a pinned toot in account timeline. * Fix typo * Add custom attribute prefix
This commit is contained in:
parent
ee2e0f694a
commit
23106844a1
|
@ -114,12 +114,12 @@ export default class Status extends ImmutablePureComponent {
|
||||||
this.context.router.history.push(`/accounts/${this._properStatus().getIn(['account', 'id'])}`);
|
this.context.router.history.push(`/accounts/${this._properStatus().getIn(['account', 'id'])}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyMoveUp = () => {
|
handleHotkeyMoveUp = e => {
|
||||||
this.props.onMoveUp(this.props.status.get('id'));
|
this.props.onMoveUp(this.props.status.get('id'), e.target.getAttribute('data-featured'));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyMoveDown = () => {
|
handleHotkeyMoveDown = e => {
|
||||||
this.props.onMoveDown(this.props.status.get('id'));
|
this.props.onMoveDown(this.props.status.get('id'), e.target.getAttribute('data-featured'));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyToggleHidden = () => {
|
handleHotkeyToggleHidden = () => {
|
||||||
|
@ -233,7 +233,7 @@ export default class Status extends ImmutablePureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HotKeys handlers={handlers}>
|
<HotKeys handlers={handlers}>
|
||||||
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility')}`, { focusable: !this.props.muted })} tabIndex={this.props.muted ? null : 0}>
|
<div className={classNames('status__wrapper', `status__wrapper-${status.get('visibility')}`, { focusable: !this.props.muted })} tabIndex={this.props.muted ? null : 0} data-featured={featured ? 'true' : null}>
|
||||||
{prepend}
|
{prepend}
|
||||||
|
|
||||||
<div className={classNames('status', `status-${status.get('visibility')}`, { muted: this.props.muted })} data-id={status.get('id')}>
|
<div className={classNames('status', `status-${status.get('visibility')}`, { muted: this.props.muted })} data-id={status.get('id')}>
|
||||||
|
|
|
@ -30,13 +30,25 @@ export default class StatusList extends ImmutablePureComponent {
|
||||||
trackScroll: true,
|
trackScroll: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
handleMoveUp = id => {
|
getFeaturedStatusCount = () => {
|
||||||
const elementIndex = this.props.statusIds.indexOf(id) - 1;
|
return this.props.featuredStatusIds ? this.props.featuredStatusIds.size : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
getCurrentStatusIndex = (id, featured) => {
|
||||||
|
if (featured) {
|
||||||
|
return this.props.featuredStatusIds.indexOf(id);
|
||||||
|
} else {
|
||||||
|
return this.props.statusIds.indexOf(id) + this.getFeaturedStatusCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleMoveUp = (id, featured) => {
|
||||||
|
const elementIndex = this.getCurrentStatusIndex(id, featured) - 1;
|
||||||
this._selectChild(elementIndex);
|
this._selectChild(elementIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMoveDown = id => {
|
handleMoveDown = (id, featured) => {
|
||||||
const elementIndex = this.props.statusIds.indexOf(id) + 1;
|
const elementIndex = this.getCurrentStatusIndex(id, featured) + 1;
|
||||||
this._selectChild(elementIndex);
|
this._selectChild(elementIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue