Skip to content

Commit

Permalink
Added notification (#7)
Browse files Browse the repository at this point in the history
* Added notification

* Updated readme, message

* Removed node notifier

* Added node-notifier dep

* Added notifier module
  • Loading branch information
ovekyc authored Jan 10, 2017
1 parent f0f3943 commit 23db829
Show file tree
Hide file tree
Showing 47 changed files with 2,810 additions and 7 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ Support x64 processor only
npm run test

If you face error message like below
Error: Module version mismatch. Expected 50, got 48
`Error: Module version mismatch. Expected 50, got 48`
try this

npm rebuild --runtime=electron --target=1.4.3 --disturl=https://atom.io/download/atom-shell --build-from-source

To see custom notification icon and name in OS X, need to re-build terminal-notifier.app with your own icon file.
And replace it `lib/text-logger-notifier/vendor/terminal-notifier.app`
For more detail, check issues below.
[node-notifier issue](https://github.com/mikaelbr/node-notifier/issues/71)
[terminal-notifier issue](https://github.com/julienXX/terminal-notifier/issues/131)
5 changes: 3 additions & 2 deletions app/core/database.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {clipboard} from 'electron';
import levelup from 'level';
import googleTranslate from './google-translate';
import glosbeTranslate from './glosbe-translate';
import Contents from './content';

const db = levelup('log.db', {valueEncoding: 'json'});
export async function store(cb) {
const clip = clipboard.readText();

const tranGoogle = await googleTranslate(clip);
const tranGlosbe = await glosbeTranslate(clip);
// TODO : remove it, glosbe API is not stable at all.
// const tranGlosbe = await glosbeTranslate(clip);
const tranGlosbe = 'N/A';

const contents = new Contents(clip, tranGoogle, tranGlosbe);
db.put(contents.source, contents, err => {
Expand Down
17 changes: 13 additions & 4 deletions app/core/main.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {app, globalShortcut, ipcMain} from 'electron';
import fs from 'fs';
import menubar from 'menubar';
import notifier from '../../lib/text-logger-notifier';
import setting from '../setting.json';
import {store, read, remove} from './database';

Expand All @@ -10,13 +11,21 @@ const settingPath = `${dir}/app/setting.json`;
const mb = menubar({index: indexPath, height: 450});

function notifyDone(contents) {
// TODO: impl
console.log(contents);
notifier.notify({
title: 'You just have scrapped text',
message: contents.source,
// icon: `${dir}/app/resources/app-icon-retina-white/[email protected]`,
sound: true
});
}

function notifyErr(err) {
// TODO: impl
console.log(err);
notifier.notify({
title: 'Fail to scrap text',
message: err.message,
icon: `${dir}/app/resources/app-icon-retina-white/[email protected]`,
sound: true
});
}

function registerIPCListener() {
Expand Down
Loading

0 comments on commit 23db829

Please sign in to comment.