Browse Source

Add hotkey for bookmarking a toot

closed-social-glitch-2
Thibaut Girka 5 years ago
committed by ThibG
parent
commit
f3acf8f414
4 changed files with 16 additions and 0 deletions
  1. +6
    -0
      app/javascript/flavours/glitch/components/status.js
  2. +4
    -0
      app/javascript/flavours/glitch/features/keyboard_shortcuts/index.js
  3. +5
    -0
      app/javascript/flavours/glitch/features/status/index.js
  4. +1
    -0
      app/javascript/flavours/glitch/features/ui/index.js

+ 6
- 0
app/javascript/flavours/glitch/components/status.js View File

@ -53,6 +53,7 @@ export default class Status extends ImmutablePureComponent {
onReply: PropTypes.func, onReply: PropTypes.func,
onFavourite: PropTypes.func, onFavourite: PropTypes.func,
onReblog: PropTypes.func, onReblog: PropTypes.func,
onBookmark: PropTypes.func,
onDelete: PropTypes.func, onDelete: PropTypes.func,
onDirect: PropTypes.func, onDirect: PropTypes.func,
onMention: PropTypes.func, onMention: PropTypes.func,
@ -337,6 +338,10 @@ export default class Status extends ImmutablePureComponent {
this.props.onReblog(this.props.status, e); this.props.onReblog(this.props.status, e);
} }
handleHotkeyBookmark = e => {
this.props.onBookmark(this.props.status, e);
}
handleHotkeyMention = e => { handleHotkeyMention = e => {
e.preventDefault(); e.preventDefault();
this.props.onMention(this.props.status.get('account'), this.context.router.history); this.props.onMention(this.props.status.get('account'), this.context.router.history);
@ -550,6 +555,7 @@ export default class Status extends ImmutablePureComponent {
moveUp: this.handleHotkeyMoveUp, moveUp: this.handleHotkeyMoveUp,
moveDown: this.handleHotkeyMoveDown, moveDown: this.handleHotkeyMoveDown,
toggleSpoiler: this.handleExpandedToggle, toggleSpoiler: this.handleExpandedToggle,
bookmark: this.handleHotkeyBookmark,
}; };
const computedClass = classNames('status', `status-${status.get('visibility')}`, { const computedClass = classNames('status', `status-${status.get('visibility')}`, {

+ 4
- 0
app/javascript/flavours/glitch/features/keyboard_shortcuts/index.js View File

@ -52,6 +52,10 @@ export default class KeyboardShortcuts extends ImmutablePureComponent {
<td><kbd>b</kbd></td> <td><kbd>b</kbd></td>
<td><FormattedMessage id='keyboard_shortcuts.boost' defaultMessage='to boost' /></td> <td><FormattedMessage id='keyboard_shortcuts.boost' defaultMessage='to boost' /></td>
</tr> </tr>
<tr>
<td><kbd>d</kbd></td>
<td><FormattedMessage id='keyboard_shortcuts.bookmark' defaultMessage='to bookmark' /></td>
</tr>
<tr> <tr>
<td><kbd>enter</kbd>, <kbd>o</kbd></td> <td><kbd>enter</kbd>, <kbd>o</kbd></td>
<td><FormattedMessage id='keyboard_shortcuts.enter' defaultMessage='to open status' /></td> <td><FormattedMessage id='keyboard_shortcuts.enter' defaultMessage='to open status' /></td>

+ 5
- 0
app/javascript/flavours/glitch/features/status/index.js View File

@ -325,6 +325,10 @@ export default class Status extends ImmutablePureComponent {
this.handleReblogClick(this.props.status); this.handleReblogClick(this.props.status);
} }
handleHotkeyBookmark = () => {
this.handleBookmarkClick(this.props.status);
}
handleHotkeyMention = e => { handleHotkeyMention = e => {
e.preventDefault(); e.preventDefault();
this.handleMentionClick(this.props.status); this.handleMentionClick(this.props.status);
@ -463,6 +467,7 @@ export default class Status extends ImmutablePureComponent {
reply: this.handleHotkeyReply, reply: this.handleHotkeyReply,
favourite: this.handleHotkeyFavourite, favourite: this.handleHotkeyFavourite,
boost: this.handleHotkeyBoost, boost: this.handleHotkeyBoost,
bookmark: this.handleHotkeyBookmark,
mention: this.handleHotkeyMention, mention: this.handleHotkeyMention,
openProfile: this.handleHotkeyOpenProfile, openProfile: this.handleHotkeyOpenProfile,
toggleSpoiler: this.handleExpandedToggle, toggleSpoiler: this.handleExpandedToggle,

+ 1
- 0
app/javascript/flavours/glitch/features/ui/index.js View File

@ -98,6 +98,7 @@ const keyMap = {
goToMuted: 'g m', goToMuted: 'g m',
goToRequests: 'g r', goToRequests: 'g r',
toggleSpoiler: 'x', toggleSpoiler: 'x',
bookmark: 'd',
}; };
@connect(mapStateToProps) @connect(mapStateToProps)

Loading…
Cancel
Save