diff options
author | beatrix <beatrix.bitrot@gmail.com> | 2018-04-26 11:33:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-26 11:33:48 -0400 |
commit | 8f12afb5996c58ddf41ceaa20f6c4e036273d3a6 (patch) | |
tree | cd45c70b01529e66f7af00c313c2a11da102c283 /app/javascript/flavours/glitch/components/status_list.js | |
parent | 1e9fe95e132361110431e8002a6b6ef5360c99a5 (diff) | |
parent | 003d1143320abf6421222f4cfd86f737fce08729 (diff) |
Merge pull request #438 from ThibG/glitch-soc/fixes/j-k-hotkeys-pinned
[Glitch] Fix the hot key (j, k) does not function correctly when ther…
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); } |