diff --git a/libs/chat-box/src/lib/state/chat-box.store.ts b/libs/chat-box/src/lib/state/chat-box.store.ts index afa9e55ca..492875baf 100644 --- a/libs/chat-box/src/lib/state/chat-box.store.ts +++ b/libs/chat-box/src/lib/state/chat-box.store.ts @@ -2,6 +2,7 @@ import { Action, Actions, createSelector, + NgxsAfterBootstrap, NgxsOnInit, ofActionDispatched, Selector, @@ -70,7 +71,7 @@ export class ChatBoxStateModel { loading: false, }, }) -export class ChatBoxState implements NgxsOnInit { +export class ChatBoxState implements NgxsAfterBootstrap { constructor( private nlp: NlpService, private stt: SpeechToTextService, @@ -149,7 +150,7 @@ export class ChatBoxState implements NgxsOnInit { return state.voiceForm.model; } - async ngxsOnInit({ getState, setState, patchState, dispatch }: StateContext) { + async ngxsAfterBootstrap({ patchState, dispatch }: StateContext) { console.log('ChatBoxState initialized, setting defaults'); if (this.tts.canUseSpeechSynthesis) { const voices = await this.tts.getVoiceList(); diff --git a/libs/navigator/src/lib/state/menu.state.ts b/libs/navigator/src/lib/state/menu.state.ts index c1607bc91..6ced033f0 100644 --- a/libs/navigator/src/lib/state/menu.state.ts +++ b/libs/navigator/src/lib/state/menu.state.ts @@ -1,4 +1,4 @@ -import { Action, NgxsOnInit, Selector, State, StateContext, Store } from '@ngxs/store'; +import { Action, NgxsAfterBootstrap, NgxsOnInit, Selector, State, StateContext, Store } from '@ngxs/store'; import { MenuItem } from '../models/menu-item.model'; import { MenuService } from '../services/menu.service'; import { Tree } from '@ngx-starter-kit/tree'; @@ -38,7 +38,7 @@ export interface MenuStateModel { iconMode: false, }, }) -export class MenuState implements NgxsOnInit { +export class MenuState implements NgxsAfterBootstrap { constructor(private menuService: MenuService) {} @Selector() @@ -55,7 +55,7 @@ export class MenuState implements NgxsOnInit { } } - ngxsOnInit({ setState, getState }: StateContext) { + ngxsAfterBootstrap({ setState, getState }: StateContext) { setState({ tree: this.menuService.tree, currentlyOpened: [], @@ -100,7 +100,7 @@ export class MenuState implements NgxsOnInit { } patchState({ - currentlyOpened: currentlyOpened, + currentlyOpened, }); } @@ -123,7 +123,7 @@ export class MenuState implements NgxsOnInit { } patchState({ - currentlyOpened: currentlyOpened, + currentlyOpened, }); } } diff --git a/libs/notifications/src/lib/notifications.handler.ts b/libs/notifications/src/lib/notifications.handler.ts index 1f32b3c0d..7639cb35d 100644 --- a/libs/notifications/src/lib/notifications.handler.ts +++ b/libs/notifications/src/lib/notifications.handler.ts @@ -26,6 +26,9 @@ export class NotificationsHandler { this.store.dispatch(new AddNotification(new AppNotification(message.notification.data))); } }); + this.swPush.notificationClicks.subscribe(({ action, notification: { title, ...notification } }) => { + console.log(`action: ${action}, title: ${title}, notification`, notification); + }); } } } diff --git a/libs/notifications/src/lib/notifications.state.ts b/libs/notifications/src/lib/notifications.state.ts index 53e34c222..85f06d2d6 100644 --- a/libs/notifications/src/lib/notifications.state.ts +++ b/libs/notifications/src/lib/notifications.state.ts @@ -1,4 +1,4 @@ -import { Action, NgxsOnInit, Selector, State, StateContext } from '@ngxs/store'; +import { Action, NgxsAfterBootstrap, Selector, State, StateContext } from '@ngxs/store'; import { produce } from '@ngxs-labs/immer-adapter'; import { tap } from 'rxjs/operators'; import { AppNotification } from './app-notification.model'; @@ -16,7 +16,7 @@ import { name: 'notifications', defaults: [], }) -export class NotificationsState implements NgxsOnInit { +export class NotificationsState implements NgxsAfterBootstrap { constructor(private notificationsService: NotificationsService) {} @Selector() @@ -24,11 +24,11 @@ export class NotificationsState implements NgxsOnInit { return state.filter(note => !note.read).length; } - ngxsOnInit(ctx: StateContext) { + ngxsAfterBootstrap(ctx: StateContext) { console.log('State initialized, now getting Notifications.'); /** * well, this way, it will be called before dashboard is routed due to preloadingStrategy. - * we will loose lazy loading benefits. so lets use ngOnInit on component to load initial data. + * we will loose lazy loading benefits. so lets use ngxsAfterBootstrap on component to load initial data. */ // ctx.dispatch(new FetchNotifications()) }