From 30196af89f3a5e47be3c188536b6f1b40f4238b5 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 20 Mar 2016 04:15:05 +0900 Subject: [PATCH] Create T keybind to open all entities --- src/utils/global-key-bind.js | 19 +++++++++++++++++-- src/utils/keycode.js | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/utils/global-key-bind.js b/src/utils/global-key-bind.js index 8f8554d..e9f4ccd 100644 --- a/src/utils/global-key-bind.js +++ b/src/utils/global-key-bind.js @@ -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) { @@ -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); @@ -90,7 +94,7 @@ 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) => { @@ -98,6 +102,17 @@ export default class GlobalKeyBind { }); } + 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(); diff --git a/src/utils/keycode.js b/src/utils/keycode.js index 1781686..906a15e 100644 --- a/src/utils/keycode.js +++ b/src/utils/keycode.js @@ -7,3 +7,4 @@ export const ZERO = 48; export const F = 70; export const J = 74; export const K = 75; +export const T = 84;