Skip to content

Commit 017bd04

Browse files
committed
chore: fix some review comments
1 parent 9da8911 commit 017bd04

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

libs/notification/src/services/notification.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const NOT_SUPPORTED_ERROR$ = throwError(
2222
() => new Error('Notification API is not supported in your browser'),
2323
);
2424

25+
const mapToVoid = map(() => undefined);
26+
2527
@Injectable({
2628
providedIn: 'root',
2729
})
@@ -86,17 +88,15 @@ export class NotificationService {
8688
targetNotification: Notification,
8789
eventName: E,
8890
): Observable<{action: string} | void> {
89-
const mapToVoid = map(() => undefined);
91+
const isTargetNotification = ({timestamp}: {timestamp?: number}) =>
92+
timestamp === targetNotification.timestamp;
9093

9194
return this.swRegistration$.pipe(
9295
switchMap(swRegistration => {
9396
if (!swRegistration) {
9497
return fromEvent(targetNotification, eventName).pipe(mapToVoid);
9598
}
9699

97-
const isTargetNotification = (notification: {timestamp?: number}) =>
98-
notification.timestamp === targetNotification.timestamp;
99-
100100
switch (eventName) {
101101
case 'click':
102102
return this.notificationSwClicks$.pipe(

libs/notification/src/tokens/notification-clicks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const NOTIFICATION_SW_CLICKS = new InjectionToken(
88
factory: () => {
99
const swPush = inject(SwPush, InjectFlags.Optional);
1010

11-
return swPush && swPush.isEnabled ? swPush.notificationClicks : NEVER;
11+
return swPush?.isEnabled ? swPush.notificationClicks : NEVER;
1212
},
1313
},
1414
);

libs/notification/src/tokens/notification-closes.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export const NOTIFICATION_SW_CLOSES = new InjectionToken(
2323
* return swPush && swPush.isEnabled ? swPush.notificationCloses : NEVER;
2424
* ```
2525
*/
26-
factory: (): Observable<Notification> => {
27-
return combineLatest([
26+
factory: (): Observable<Notification> =>
27+
combineLatest([
2828
from(inject(SERVICE_WORKER).getRegistration()),
2929
inject(ANIMATION_FRAME),
3030
]).pipe(
@@ -37,7 +37,6 @@ export const NOTIFICATION_SW_CLOSES = new InjectionToken(
3737
),
3838
zoneOptimized(inject(NgZone)),
3939
share(),
40-
);
41-
},
40+
),
4241
},
4342
);

0 commit comments

Comments
 (0)