Skip to content

Commit

Permalink
fix(notifications): refactored notifications module
Browse files Browse the repository at this point in the history
refactored notifications UI and API modules
  • Loading branch information
xmlking committed Dec 4, 2018
1 parent 1599ab7 commit fa7c98c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ export class NotificationService extends CrudService<Notification> {
title: notification.title,
body: notification.body,
icon: 'assets/icons/icon-72x72.png',
data: {
click_url: '/dashboard',
},
data: notification,
vibrate: [200, 100, 200],
};

Expand Down
1 change: 1 addition & 0 deletions libs/core/src/lib/services/in-memory-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class InMemoryDataService implements InMemoryDbService {

parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl {
const newUrl = url
.replace(/\/notifications\/user/, '/notifications')
.replace(/\/datapower\/serviceproxy/, '/serviceproxy')
.replace(/\/nas\/cluster/, '/cluster')
.replace(/\/layer7\/my.cnf/, '/mycnf');
Expand Down
13 changes: 6 additions & 7 deletions libs/notifications/src/lib/notifications.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Injectable } from '@angular/core';
import { AddNotification, DeleteNotification, MarkAllAsRead, MarkAsRead } from './notifications.actions';
import { SendWebSocketAction } from '@ngx-starter-kit/socketio-plugin';
import { SwPush } from '@angular/service-worker';
import { AppNotification } from '@ngx-starter-kit/notifications';
import { AppNotification } from './app-notification.model';

@Injectable({
providedIn: 'root',
Expand All @@ -12,7 +12,7 @@ export class NotificationsHandler {
constructor(private actions$: Actions, private store: Store, private readonly swPush: SwPush) {
this.actions$
.pipe(ofActionSuccessful(DeleteNotification))
.subscribe(action => {console.log(action); this.store.dispatch(new SendWebSocketAction(action))});
.subscribe(action => this.store.dispatch(new SendWebSocketAction(action)));
this.actions$
.pipe(ofActionSuccessful(MarkAsRead))
.subscribe(action => this.store.dispatch(new SendWebSocketAction(action)));
Expand All @@ -21,11 +21,10 @@ export class NotificationsHandler {
.subscribe(action => this.store.dispatch(new SendWebSocketAction(action)));

if (this.swPush.isEnabled) {
// subscribe for new messages for testing
this.swPush.messages.subscribe(message => {
console.log('received push notification in NotificationsHandler', message);
// TODO:
// this.store.dispatch(new AddNotification(message as AppNotification));
this.swPush.messages.subscribe((message: { notification: Notification }) => {
if (message.notification.data.targetType) {
this.store.dispatch(new AddNotification(new AppNotification(message.notification.data)));
}
});
}
}
Expand Down

0 comments on commit fa7c98c

Please sign in to comment.