Skip to content

Commit

Permalink
add notification if app is not activate
Browse files Browse the repository at this point in the history
  • Loading branch information
Darmody committed Mar 20, 2016
1 parent 5fe3ec8 commit 3e48f37
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
A beautiful mac desktop application for [Douban FM](http://douban.fm)

<br/>
<img src="screenshots/logo.png" alt="DoubanFMac" width="256px" />
<img src="static/logo.png" alt="DoubanFMac" width="256px" />
<br/> <br/>

## Screenshots
Expand Down
1 change: 0 additions & 1 deletion app/components/Player/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export default class Player extends Component {
}
}


componentWillUnmount() {
if (this.state.playInterval) clearInterval(this.state.playInterval);
}
Expand Down
22 changes: 22 additions & 0 deletions app/containers/HomePage/Content/Content.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { bindActionCreators } from 'redux';
import cx from 'classnames';
import { connect } from 'react-redux';
import ipc from 'ipc';
import notifier from 'node-notifier';
import { Player } from 'components';
import { fetch, like, dislike, ban } from 'reducers/song';
import styles from './Content.scss';
Expand All @@ -28,11 +29,32 @@ export default class Content extends Component {
super(props);

this.state = { playing: true };
this.handleShortcut();
}

componentDidMount() {
this.props.fetch(0);
}

componentWillReceiveProps(nextProps) {
if (this.props.song.id !== nextProps.song.id) {
this.notice(nextProps.song);
}
}

notice = (song) => {
if (document.hasFocus()) return;

notifier.notify({
title: song.name,
message: song.artist,
contentImage: song.cover,
sender: 'com.electron.doubanfmac',
sound: 'Pop',
});
}

handleShortcut = () => {
ipc.on('shortcut-pressed', (event) => {
switch (event) {
case 'controlSong':
Expand Down
83 changes: 83 additions & 0 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"menubar": "^4.0.2",
"moment": "^2.12.0",
"nock": "^7.2.2",
"node-notifier": "^4.5.0",
"normalize.css": "^3.0.3",
"react": "^0.14.2",
"react-addons-clicked-away-mixin": "^0.1.2",
Expand Down
File renamed without changes
3 changes: 3 additions & 0 deletions webpack/config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ module.exports = {
extensions: ['', '.js', '.json'],
packageMains: ['webpack', 'browser', 'web', 'browserify', ['jam', 'main'], 'main']
},
node: {
__dirname: true
},
plugins: [

],
Expand Down

0 comments on commit 3e48f37

Please sign in to comment.