diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-04-22 22:08:30 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-04-22 23:11:16 +0200 |
commit | 003d1143320abf6421222f4cfd86f737fce08729 (patch) | |
tree | 90bcb19598dba1ed8df8dc30ae964ecd7e2d3bf4 /app/javascript/flavours/glitch/components/status_list.js | |
parent | 06fc278e4cfad385ba1ffd672c8c43a800f49bc3 (diff) |
[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
Diffstat (limited to 'app/javascript/flavours/glitch/components/status_list.js')
-rw-r--r-- | app/javascript/flavours/glitch/components/status_list.js | 20 |
1 files changed, 16 insertions, 4 deletions
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); } |