From 003d1143320abf6421222f4cfd86f737fce08729 Mon Sep 17 00:00:00 2001 From: Thibaut Girka Date: Sun, 22 Apr 2018 22:08:30 +0200 Subject: [Glitch] Fix the hot key (j, k) does not function correctly when there is a pinned toot in account timeline. Port 23106844a10606dd0e04c8382281d5ff80d4bdd9 to glitch-soc --- app/javascript/flavours/glitch/components/status.js | 10 ++++++---- .../flavours/glitch/components/status_list.js | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) (limited to 'app/javascript') diff --git a/app/javascript/flavours/glitch/components/status.js b/app/javascript/flavours/glitch/components/status.js index cf82c9ac6..120772201 100644 --- a/app/javascript/flavours/glitch/components/status.js +++ b/app/javascript/flavours/glitch/components/status.js @@ -253,12 +253,12 @@ export default class Status extends ImmutablePureComponent { this.context.router.history.push(`/accounts/${this.props.status.getIn(['account', 'id'])}`); } - handleHotkeyMoveUp = () => { - this.props.onMoveUp(this.props.containerId || this.props.id); + handleHotkeyMoveUp = e => { + this.props.onMoveUp(this.props.containerId || this.props.id, e.target.getAttribute('data-featured')); } - handleHotkeyMoveDown = () => { - this.props.onMoveDown(this.props.containerId || this.props.id); + handleHotkeyMoveDown = e => { + this.props.onMoveDown(this.props.containerId || this.props.id, e.target.getAttribute('data-featured')); } handleRef = c => { @@ -292,6 +292,7 @@ export default class Status extends ImmutablePureComponent { onOpenMedia, notification, hidden, + featured, ...other } = this.props; const { isExpanded } = this.state; @@ -426,6 +427,7 @@ export default class Status extends ImmutablePureComponent { {...selectorAttribs} ref={handleRef} tabIndex='0' + data-featured={featured ? 'true' : null} >
diff --git a/app/javascript/flavours/glitch/components/status_list.js b/app/javascript/flavours/glitch/components/status_list.js index ea40463da..2b35d6f3d 100644 --- a/app/javascript/flavours/glitch/components/status_list.js +++ b/app/javascript/flavours/glitch/components/status_list.js @@ -28,13 +28,25 @@ export default class StatusList extends ImmutablePureComponent { trackScroll: true, }; - handleMoveUp = id => { - const elementIndex = this.props.statusIds.indexOf(id) - 1; + getFeaturedStatusCount = () => { + 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); } - handleMoveDown = id => { - const elementIndex = this.props.statusIds.indexOf(id) + 1; + handleMoveDown = (id, featured) => { + const elementIndex = this.getCurrentStatusIndex(id, featured) + 1; this._selectChild(elementIndex); } -- cgit