Skip to content

Commit 866ab10

Browse files
authored
WEB-276 replace custom api of Notification.service.ts (#2603)
1 parent 13840a0 commit 866ab10

File tree

3 files changed

+16
-69
lines changed

3 files changed

+16
-69
lines changed

src/app/notifications/notifications.resolver.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,26 @@ import { Injectable } from '@angular/core';
55
import { Observable } from 'rxjs';
66

77
/** Custom Services */
8-
import { NotificationsService } from './notifications.service';
8+
import { NotificationService } from '@fineract/client';
99

1010
/**
1111
* Notifications data resolver.
1212
*/
1313
@Injectable()
1414
export class NotificationsResolver {
1515
/**
16-
* @param {NotificationsService} notificationsService Notifications service.
16+
* @param {NotificationService} notificationService Notifications service.
1717
*/
18-
constructor(private notificationsService: NotificationsService) {}
18+
constructor(private notificationService: NotificationService) {}
1919

2020
/**
2121
* Returns the Notifications data.
2222
* @returns {Observable<any>}
2323
*/
2424
resolve(): Observable<any> {
25-
return this.notificationsService.getNotifications(true, 50);
25+
return this.notificationService.getAllNotifications({
26+
isRead: true,
27+
limit: 50
28+
});
2629
}
2730
}

src/app/notifications/notifications.service.ts

Lines changed: 0 additions & 57 deletions
This file was deleted.

src/app/shared/notifications-tray/notifications-tray.component.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Component, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core';
55
import { forkJoin } from 'rxjs';
66

77
/** Custom Services */
8-
import { NotificationsService } from 'app/notifications/notifications.service';
8+
import { NotificationService } from '@fineract/client';
99
import { environment } from '../../../environments/environment';
1010
import { MatIconButton } from '@angular/material/button';
1111
import { MatTooltip } from '@angular/material/tooltip';
@@ -65,12 +65,13 @@ export class NotificationsTrayComponent implements OnInit, OnDestroy {
6565
};
6666

6767
/**
68-
* @param {NotificationsService} notificationsService Notifications Service
68+
* @param {NotificationService} notificationService Notifications Service
6969
*/
70-
constructor(public notificationsService: NotificationsService) {
70+
constructor(public notificationService: NotificationService) {
7171
forkJoin([
72-
this.notificationsService.getNotifications(true, 9),
73-
this.notificationsService.getNotifications(false, 9)]).subscribe((response: any[]) => {
72+
this.notificationService.getAllNotifications({ isRead: true, limit: 9 }),
73+
this.notificationService.getAllNotifications({ isRead: false, limit: 9 })
74+
]).subscribe((response: any[]) => {
7475
this.readNotifications = response[0].pageItems;
7576
this.unreadNotifications = response[1].pageItems;
7677
this.setNotifications();
@@ -101,7 +102,7 @@ export class NotificationsTrayComponent implements OnInit, OnDestroy {
101102
* Recursively fetch unread notifications.
102103
*/
103104
fetchUnreadNotifications() {
104-
this.notificationsService.getNotifications(false, 9).subscribe((response: any) => {
105+
this.notificationService.getAllNotifications({ isRead: false, limit: 9 }).subscribe((response: any) => {
105106
this.unreadNotifications = this.unreadNotifications.concat(response.pageItems);
106107
this.setNotifications();
107108
});
@@ -116,7 +117,7 @@ export class NotificationsTrayComponent implements OnInit, OnDestroy {
116117
*/
117118
menuClosed() {
118119
// Update the server for read notifications.
119-
this.notificationsService.updateNotifications().subscribe(() => {});
120+
this.notificationService.getAllNotifications({ isRead: true }).subscribe(() => {});
120121
// Update locally for read notifications.
121122
this.readNotifications = this.unreadNotifications.concat(this.readNotifications);
122123
this.unreadNotifications = [];
@@ -127,7 +128,7 @@ export class NotificationsTrayComponent implements OnInit, OnDestroy {
127128
* Function to test notifications in case of faulty backend.
128129
*/
129130
mockNotifications() {
130-
this.notificationsService.getMockUnreadNotification().subscribe((response: any) => {
131+
this.notificationService.getAllNotifications({ isRead: false, limit: 9 }).subscribe((response: any) => {
131132
this.unreadNotifications = this.unreadNotifications.concat(response.pageItems);
132133
this.setNotifications();
133134
});

0 commit comments

Comments
 (0)