Skip to content

Commit

Permalink
remove node-notifier use h5 Notification, trazyn#21
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn committed Aug 29, 2017
1 parent 960acd2 commit 249e44e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 29 deletions.
5 changes: 3 additions & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ Description | Keys
New conversation | <kbd>Cmd</kbd> <kbd>N</kbd>
Search conversations | <kbd>Cmd</kbd> <kbd>F</kbd>
Hide conversation | <kbd>Shift</kbd> <kbd>Cmd</kbd> <kbd>M</kbd>
Jump to conversation | <kbd>Cmd</kbd> <kbd>0</kbd> ... <kdb>9</kdb>
Jump to conversation | <kbd>Cmd</kbd> <kbd>0</kbd> ... <kbd>9</kbd>
Next conversation | <kbd>Cmd</kbd> <kbd>J</kbd>
Previous conversation | <kbd>Cmd</kbd> <kbd>K</kbd>
Toggle Full Screen | <kbd>Shift</kbd> <kbd>Cmd</kbd> <kdb>F</kdb>
Toggle Full Screen | <kbd>Shift</kbd> <kbd>Cmd</kbd> <kbd>F</kbd>
Insert QQ emoji | <kbd>Cmd</kbd> <kbd>I</kbd>
Preferences | <kbd>Cmd</kbd> <kbd>,</kbd>

Expand Down Expand Up @@ -105,6 +105,7 @@ Preferences | <kbd>Cmd</kbd> <kbd>,</kbd>
- [ ] Theme
- [x] Send image from clipboard
- [x] Drag to send file
- [ ] Mention a user
- [ ] Chat bot

### License
Expand Down
17 changes: 0 additions & 17 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import fs from 'fs';
import tmp from 'tmp';
import { app, powerMonitor, BrowserWindow, Tray, Menu, ipcMain, clipboard, shell } from 'electron';
import windowStateKeeper from 'electron-window-state';
import notifier from 'node-notifier';
import AutoLaunch from 'auto-launch';

import pkg from './package.json';
Expand Down Expand Up @@ -485,22 +484,6 @@ const createMainWindow = () => {
}
});

ipcMain.on('message-receive', (event, args) => {
var { icon, title, message } = args;
var filename = `${imagesCacheDir}/notifier-icon.png`;

if (settings.showNotification) {
fs.writeFileSync(filename, icon.replace(/^data:image\/png;base64,/, ''), 'base64');

notifier.notify({
title,
sound: 'Blow',
contentImage: filename,
message,
});
}
});

ipcMain.on('file-paste', (event) => {
var image = clipboard.readImage();
var args = { hasImage: false };
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
"mobx": "^3.1.16",
"mobx-react": "^4.2.1",
"moment": "^2.18.1",
"node-notifier": "^5.1.2",
"play-sound": "^1.1.1",
"randomcolor": "^0.5.3",
"react": "^15.6.1",
Expand Down
19 changes: 10 additions & 9 deletions src/js/stores/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,19 @@ class Chat {

// Drop the duplicate message
if (!list.data.find(e => e.NewMsgId === message.NewMsgId)) {
message = await resolveMessage(message);
let title = user.RemarkName || user.NickName;

if (!helper.isMuted(user)) {
// Get the user avatar and use it as notifier icon
let response = await axios.get(user.HeadImgUrl, { responseType: 'arraybuffer' });
let base64 = new window.Buffer(response.data, 'binary').toString('base64');
message = await resolveMessage(message);

ipcRenderer.send('message-receive', {
icon: base64,
title: user.RemarkName || user.NickName,
message: helper.getMessageContent(message),
if (!helper.isMuted(user)
&& settings.showNotification) {
/* eslint-disable */
new Notification(title, {
icon: user.HeadImgUrl,
body: helper.getMessageContent(message),
vibrate: [200, 100, 200],
});
/* eslint-enable */
}
list.data.push(message);
}
Expand Down

0 comments on commit 249e44e

Please sign in to comment.