feat: Add "a" keyboard shortcut to bookmark a toot. (#2268)

Fixes #2237.

Co-authored-by: Nolan Lawson <nolan@nolanlawson.com>
This commit is contained in:
James Teh 2022-12-03 08:01:02 +10:00 committed by GitHub
parent da28e98cfb
commit 30b00667f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -154,6 +154,7 @@ export default {
<li><kbd>b</kbd> to boost</li> <li><kbd>b</kbd> to boost</li>
<li><kbd>r</kbd> to reply</li> <li><kbd>r</kbd> to reply</li>
<li><kbd>Escape</kbd> to close reply</li> <li><kbd>Escape</kbd> to close reply</li>
<li><kbd>a</kbd> to bookmark</li>
<li><kbd>i</kbd> to open images, video, or audio</li> <li><kbd>i</kbd> to open images, video, or audio</li>
<li><kbd>y</kbd> to show or hide sensitive media</li> <li><kbd>y</kbd> to show or hide sensitive media</li>
<li><kbd>m</kbd> to mention the author</li> <li><kbd>m</kbd> to mention the author</li>

View File

@ -44,6 +44,7 @@
<Shortcut scope={shortcutScope} key="r" on:pressed="reply()"/> <Shortcut scope={shortcutScope} key="r" on:pressed="reply()"/>
<Shortcut scope={shortcutScope} key="escape" on:pressed="dismiss()"/> <Shortcut scope={shortcutScope} key="escape" on:pressed="dismiss()"/>
<Shortcut scope={shortcutScope} key="b" on:pressed="reblog(true)"/> <Shortcut scope={shortcutScope} key="b" on:pressed="reblog(true)"/>
<Shortcut scope={shortcutScope} key="a" on:pressed="bookmark()"/>
{/if} {/if}
<style> <style>
.status-toolbar { .status-toolbar {
@ -81,6 +82,7 @@
import { CHECKMARK_ANIMATION, FAVORITE_ANIMATION, REBLOG_ANIMATION } from '../../_static/animations.js' import { CHECKMARK_ANIMATION, FAVORITE_ANIMATION, REBLOG_ANIMATION } from '../../_static/animations.js'
import { on } from '../../_utils/eventBus.js' import { on } from '../../_utils/eventBus.js'
import { announceAriaLivePolite } from '../../_utils/announceAriaLivePolite.js' import { announceAriaLivePolite } from '../../_utils/announceAriaLivePolite.js'
import { setStatusBookmarkedOrUnbookmarked } from '../../_actions/bookmark.js'
export default { export default {
oncreate () { oncreate () {
@ -174,6 +176,10 @@
// return status to the reply button after posting a reply // return status to the reply button after posting a reply
this.refs.node.querySelector('.status-toolbar-reply-button').focus({ preventScroll: true }) this.refs.node.querySelector('.status-toolbar-reply-button').focus({ preventScroll: true })
} catch (e) { /* ignore */ } } catch (e) { /* ignore */ }
},
bookmark () {
const { originalStatus, originalStatusId } = this.get()
/* no await */ setStatusBookmarkedOrUnbookmarked(originalStatusId, !originalStatus.bookmarked)
} }
}, },
data: () => ({ data: () => ({