Skip to content

Commit

Permalink
add shortcuts to insert qq emoji
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn committed Aug 28, 2017
1 parent 8c67ed6 commit 24282e9
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Search conversations | <kbd>Cmd</kbd> <kbd>F</kbd>
Hide conversation | <kbd>Shift</kbd> <kbd>Cmd</kbd> <kbd>M</kbd>
Next conversation | <kbd>Cmd</kbd> <kbd>J</kbd>
Previous conversation | <kbd>Cmd</kbd> <kbd>K</kbd>
Insert QQ emoji | <kbd>Cmd</kbd> <kbd>I</kbd>
Preferences | <kbd>Cmd</kbd> <kbd>,</kbd>

### TODO
Expand Down
11 changes: 11 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@ function createMenu() {
{
type: 'separator',
},
{
label: 'Insert emoji',
accelerator: 'Cmd+I',
click() {
mainWindow.show();
mainWindow.webContents.send('show-emoji');
}
},
{
type: 'separator',
},
{
label: 'Next conversation',
accelerator: 'Cmd+J',
Expand Down
26 changes: 24 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,62 +23,84 @@ class App extends Component {
await stores.search.getHistory();
}

canisend() {
return this.refs.navigator.state.location.pathname === '/'
&& stores.chat.user;
}

componentDidMount() {
// Hide the tray icon
ipcRenderer.on('hide-tray', () => {
stores.settings.setShowOnTray(false);
});

// Shwo the settings page
ipcRenderer.on('show-settings', () => {
this.refs.navigator.router.push('/settings');
});

// Show a modal to create a new conversation
ipcRenderer.on('show-newchat', () => {
this.refs.navigator.router.push('/');
stores.newchat.toggle(true);
});

// Show the conversation pane
ipcRenderer.on('show-conversation', () => {
if (this.refs.navigator.state.location.pathname === '/'
&& stores.chat.user) {
if (this.canisend()) {
stores.chat.toggleConversation();
}
});

// Search in currently conversation list
ipcRenderer.on('show-search', () => {
this.refs.navigator.router.push('/');
stores.chat.toggleConversation(true);

setTimeout(() => document.querySelector('#search').focus());
});

// Show the home page
ipcRenderer.on('show-messages', () => {
this.refs.navigator.router.push('/');
stores.chat.toggleConversation(true);
});

// Insert the qq emoji
ipcRenderer.on('show-emoji', () => {
if (this.canisend()) {
document.querySelector('#showEmoji').click();
}
});

// Show contacts page
ipcRenderer.on('show-contacts', () => {
this.refs.navigator.router.push('/contacts');
});

// Go to next conversation
ipcRenderer.on('show-next', () => {
this.refs.navigator.router.push('/');
stores.chat.toggleConversation(true);
setTimeout(stores.chat.chatToNext);
});

// Go to the previous conversation
ipcRenderer.on('show-previous', () => {
this.refs.navigator.router.push('/');
stores.chat.toggleConversation(true);
setTimeout(stores.chat.chatToPrev);
});

// When the system resume reconnet to WeChat
ipcRenderer.on('os-resume', async() => {
var session = stores.session;

session.keepalive()
.catch(ex => session.logout());
});

// Show the daemon error
ipcRenderer.on('show-errors', (event, args) => {
stores.snackbar.showMessage(args.message);
});
Expand Down
6 changes: 5 additions & 1 deletion src/js/pages/Footer/Home.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,12 @@ export default class Input extends Component {
onKeyPress={e => this.handleEnter(e)} />

<div className={classes.action}>
<i className="icon-ion-android-attach" onClick={e => canisend && this.refs.uploader.click()} />
<i
id="showUploader"
className="icon-ion-android-attach"
onClick={e => canisend && this.refs.uploader.click()} />
<i
id="showEmoji"
className="icon-ion-ios-heart"
style={{
color: 'red',
Expand Down

0 comments on commit 24282e9

Please sign in to comment.