Skip to content

Commit

Permalink
notifications sorted
Browse files Browse the repository at this point in the history
  • Loading branch information
harshbaldwa committed Sep 30, 2019
1 parent 746c793 commit 226a515
Show file tree
Hide file tree
Showing 9 changed files with 1 addition and 1,107 deletions.
784 changes: 0 additions & 784 deletions backend/app.js

This file was deleted.

11 changes: 0 additions & 11 deletions backend/check_auth.js

This file was deleted.

84 changes: 0 additions & 84 deletions backend/models/match.js

This file was deleted.

102 changes: 0 additions & 102 deletions backend/models/player.js

This file was deleted.

17 changes: 0 additions & 17 deletions backend/package.json

This file was deleted.

52 changes: 0 additions & 52 deletions backend/server.js

This file was deleted.

25 changes: 0 additions & 25 deletions backend/site.js

This file was deleted.

32 changes: 1 addition & 31 deletions src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,17 @@ export class LadderService {

// Notifications
getNumber(id: string) {
const myId = { id };
this.http.post<string>(BackendURLNotifications + 'challenges/', myId)
this.http.get(BackendURLNotifications + 'challenges/' + id)
.subscribe((notification) => {
this.challengesN = Number(notification[0]);
this.challengesP = Number(notification[1]);
this.challengesC = Number(notification[2]);
// tslint:disable: triple-equals
if (this.challengesN > this.challengesNOld && this.challengesNOld != undefined) {
this.myNotifi('New Challenge', 'You got a new challenge!', '/challenges');
}
this.challengesUpdatesN.next(this.challengesN);
this.challengesNOld = this.challengesN;

this.challengesUpdatesP.next(this.challengesP);

if (this.challengesC > this.challengesCOld && this.challengesCOld != undefined) {
this.myNotifi('Confirm Result', 'You got a new confirmation!', '/confirmation/confirm');
}
this.challengesUpdatesC.next(this.challengesC);
this.challengesCOld = this.challengesC;

});
}
Expand Down Expand Up @@ -343,25 +334,4 @@ export class LadderService {
this.snackBar.open(message, action, { duration: 2000 });
}

// Notifications Bitches!!!
myNotifi(title: string, body: string, link: string) {
const options = new PushNotificationOptions();
options.body = body;

this.notifications.create(title, options).subscribe((notif) => {
if (notif.event.type === 'show') {
setTimeout(() => {
notif.notification.close();
}, 10000);
}
if (notif.event.type === 'click') {
this.router.navigate([link]);
notif.notification.close();
}
},
(err) => {
console.log(err);
});
}

}
1 change: 0 additions & 1 deletion src/app/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ export class AuthService {
this.saveAuthData(token);
this.openSnackBar('Successfully logged in!', 'OK');
this.router.navigate(['/']);
this.ladderService.getNumber(response.id);
}
}, error => {
this.authStatusListener.next(false);
Expand Down

0 comments on commit 226a515

Please sign in to comment.