Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Commit

Permalink
Create T keybind to open all entities
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Mar 19, 2016
1 parent bfeb739 commit 30196af
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/utils/global-key-bind.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import * as Keycode from './keycode';
import RichState from './rich-state';
import Actions from '../actions';
import RichState from './rich-state';
import TwitterClient from './twitter-client';
import { shell } from 'electron';

export default class GlobalKeyBind {
static subscribe(store) {
Expand Down Expand Up @@ -36,6 +37,9 @@ export default class GlobalKeyBind {
case Keycode.F:
this.handleF(event);
break;
case Keycode.T:
this.handleT(event);
break;
case Keycode.SPACE:
case Keycode.ZERO:
this.handleZero(event);
Expand Down Expand Up @@ -90,14 +94,25 @@ export default class GlobalKeyBind {
event.preventDefault();

let client = new TwitterClient(this.state.activeAccount());
let active = this.state.activeTweet();
let active = this.state.activeTweet();
if (!active) return null;

client.favoriteStatus(active.id_str, (tweet) => {
this.dispatch(Actions.tweets.addTweet(tweet, this.state.activeAccount(), this.state.activeTab()));
});
}

handleT(event) {
event.preventDefault();

let tweet = this.state.activeTweet();
if (!tweet) return null;

for (let entity of [...tweet.entities.urls, ...(tweet.entities.media || [])]) {
shell.openExternal(entity.expanded_url);
}
}

handleZero(event) {
event.preventDefault();

Expand Down
1 change: 1 addition & 0 deletions src/utils/keycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export const ZERO = 48;
export const F = 70;
export const J = 74;
export const K = 75;
export const T = 84;

0 comments on commit 30196af

Please sign in to comment.