Skip to content

Commit

Permalink
added push.js notification library
Browse files Browse the repository at this point in the history
  • Loading branch information
joshterrill committed Jul 16, 2016
1 parent faaf757 commit 674ac71
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
Binary file added app/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<script src="bower_components/lodash/dist/lodash.compat.js"></script>
<script src="bower_components/angular-socket-io/socket.js"></script>
<script src="bower_components/ng-file-upload/angular-file-upload.js"></script>
<script src="bower_components/push.js/push.js"></script>
<!-- endbower -->
<!-- endbuild -->

Expand Down
9 changes: 9 additions & 0 deletions app/scripts/controllers/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ angular.module('peerflixServerApp')
_.remove($scope.torrents, torrent);
};

$scope.notify = function(name) {
Push.create('Your torrent has finished downloading!', {
body: name + ' has finished downloading.',
icon: 'images/logo.png'
});
};

torrentSocket.on('verifying', function (hash) {
findTorrent(hash).then(function (torrent) {
torrent.ready = false;
Expand All @@ -94,6 +101,8 @@ angular.module('peerflixServerApp')
torrentSocket.on('uninterested', function (hash) {
findTorrent(hash).then(function (torrent) {
torrent.interested = false;
console.log(torrent);
$scope.notify(torrent.name, torrent.link);
});
});

Expand Down
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"lodash": "~2.4.1",
"angular-socket-io": "~0.6.0",
"ng-file-upload": "~3.3.4",
"font-awesome": "~4.2.0"
"font-awesome": "~4.2.0",
"push.js": "^0.0.10"
},
"devDependencies": {
"angular-mocks": "~1.2.16"
Expand Down

0 comments on commit 674ac71

Please sign in to comment.