effects of notification are added
This commit is contained in:
parent
f4f986944b
commit
37691a565f
|
@ -108,19 +108,9 @@ export class AppNotificationService {
|
||||||
noti
|
noti
|
||||||
);
|
);
|
||||||
|
|
||||||
const appendInfo: Info = {
|
|
||||||
seq: noti.seq,
|
|
||||||
type: noti.eventType,
|
|
||||||
senderSeq: noti.SENDER_SEQ,
|
|
||||||
sendDate: noti.sendDate,
|
|
||||||
sentMessage: noti.message,
|
|
||||||
receiverCount: noti.receiverCount
|
|
||||||
};
|
|
||||||
|
|
||||||
this.store.dispatch(
|
this.store.dispatch(
|
||||||
EventStore.newInfo({
|
EventStore.sendNotification({
|
||||||
roomSeq: noti.roomSeq,
|
noti
|
||||||
info: appendInfo
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -133,6 +123,11 @@ export class AppNotificationService {
|
||||||
'Notification::eventProtocolService::ReadNotification',
|
'Notification::eventProtocolService::ReadNotification',
|
||||||
noti
|
noti
|
||||||
);
|
);
|
||||||
|
this.store.dispatch(
|
||||||
|
EventStore.readNotification({
|
||||||
|
noti
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SSVC_TYPE_EVENT_CANCEL_NOTI:
|
case SSVC_TYPE_EVENT_CANCEL_NOTI:
|
||||||
|
@ -142,6 +137,11 @@ export class AppNotificationService {
|
||||||
'Notification::eventProtocolService::CancelNotification',
|
'Notification::eventProtocolService::CancelNotification',
|
||||||
noti
|
noti
|
||||||
);
|
);
|
||||||
|
this.store.dispatch(
|
||||||
|
EventStore.cancelNotification({
|
||||||
|
noti
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SSVC_TYPE_EVENT_DEL_RES:
|
case SSVC_TYPE_EVENT_DEL_RES:
|
||||||
|
@ -151,6 +151,11 @@ export class AppNotificationService {
|
||||||
'Notification::eventProtocolService::DelNotification',
|
'Notification::eventProtocolService::DelNotification',
|
||||||
noti
|
noti
|
||||||
);
|
);
|
||||||
|
this.store.dispatch(
|
||||||
|
EventStore.delNotification({
|
||||||
|
noti
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -2,16 +2,22 @@ import { Type } from '@angular/core';
|
||||||
import { Action, combineReducers, Selector, createSelector } from '@ngrx/store';
|
import { Action, combineReducers, Selector, createSelector } from '@ngrx/store';
|
||||||
|
|
||||||
import * as AuthenticationStore from './authentication';
|
import * as AuthenticationStore from './authentication';
|
||||||
|
import * as InfoStore from './info';
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
authentication: AuthenticationStore.State;
|
authentication: AuthenticationStore.State;
|
||||||
|
info: InfoStore.State;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const effects: Type<any>[] = [AuthenticationStore.Effects];
|
export const effects: Type<any>[] = [
|
||||||
|
AuthenticationStore.Effects,
|
||||||
|
InfoStore.Effects
|
||||||
|
];
|
||||||
|
|
||||||
export function reducers(state: State | undefined, action: Action) {
|
export function reducers(state: State | undefined, action: Action) {
|
||||||
return combineReducers({
|
return combineReducers({
|
||||||
authentication: AuthenticationStore.reducer
|
authentication: AuthenticationStore.reducer,
|
||||||
|
info: InfoStore.reducer
|
||||||
})(state, action);
|
})(state, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +28,13 @@ export function selectors<S>(selector: Selector<any, State>) {
|
||||||
selector,
|
selector,
|
||||||
(state: State) => state.authentication
|
(state: State) => state.authentication
|
||||||
)
|
)
|
||||||
|
),
|
||||||
|
|
||||||
|
InfoSelector: InfoStore.selectors(
|
||||||
|
createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.info
|
||||||
|
)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { createAction, props } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { UserNotification } from '@ucap-webmessenger/protocol-info';
|
||||||
|
|
||||||
|
export const userNotification = createAction(
|
||||||
|
'[Account::Info] User Notification',
|
||||||
|
props<{ noti: UserNotification }>()
|
||||||
|
);
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
|
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||||
|
|
||||||
|
import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
|
import { NGXLogger } from 'ngx-logger';
|
||||||
|
import { userNotification } from './actions';
|
||||||
|
import { map, tap } from 'rxjs/operators';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class Effects {
|
||||||
|
userNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(userNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private actions$: Actions,
|
||||||
|
private store: Store<any>,
|
||||||
|
private logger: NGXLogger
|
||||||
|
) {}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
export * from './actions';
|
||||||
|
export * from './effects';
|
||||||
|
export * from './reducers';
|
||||||
|
export * from './state';
|
|
@ -0,0 +1,4 @@
|
||||||
|
import { createReducer, on } from '@ngrx/store';
|
||||||
|
import { initialState } from './state';
|
||||||
|
|
||||||
|
export const reducer = createReducer(initialState);
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { Selector, createSelector } from '@ngrx/store';
|
||||||
|
|
||||||
|
export interface State {
|
||||||
|
selectedRoom: string | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const initialState: State = {
|
||||||
|
selectedRoom: null
|
||||||
|
};
|
||||||
|
|
||||||
|
export function selectors<S>(selector: Selector<any, State>) {
|
||||||
|
return {
|
||||||
|
selectedRoom: createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.selectedRoom
|
||||||
|
)
|
||||||
|
};
|
||||||
|
}
|
|
@ -4,7 +4,11 @@ import {
|
||||||
Info,
|
Info,
|
||||||
InfoResponse,
|
InfoResponse,
|
||||||
SendResponse,
|
SendResponse,
|
||||||
SendRequest
|
SendRequest,
|
||||||
|
SendNotification,
|
||||||
|
ReadNotification,
|
||||||
|
CancelNotification,
|
||||||
|
DelNotification
|
||||||
} from '@ucap-webmessenger/protocol-event';
|
} from '@ucap-webmessenger/protocol-event';
|
||||||
|
|
||||||
export const info = createAction(
|
export const info = createAction(
|
||||||
|
@ -57,3 +61,23 @@ export const sendFailure = createAction(
|
||||||
'[Messenger::Event] Send Failure',
|
'[Messenger::Event] Send Failure',
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const sendNotification = createAction(
|
||||||
|
'[Messenger::Event] Send Notification',
|
||||||
|
props<{ noti: SendNotification }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const readNotification = createAction(
|
||||||
|
'[Messenger::Event] Read Notification',
|
||||||
|
props<{ noti: ReadNotification }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const cancelNotification = createAction(
|
||||||
|
'[Messenger::Event] Cancel Notification',
|
||||||
|
props<{ noti: CancelNotification }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const delNotification = createAction(
|
||||||
|
'[Messenger::Event] Delete Notification',
|
||||||
|
props<{ noti: DelNotification }>()
|
||||||
|
);
|
||||||
|
|
|
@ -35,7 +35,11 @@ import {
|
||||||
sendSuccess,
|
sendSuccess,
|
||||||
sendFailure,
|
sendFailure,
|
||||||
appendInfoList,
|
appendInfoList,
|
||||||
newInfo
|
newInfo,
|
||||||
|
sendNotification,
|
||||||
|
readNotification,
|
||||||
|
cancelNotification,
|
||||||
|
delNotification
|
||||||
} from './actions';
|
} from './actions';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
||||||
|
@ -130,6 +134,30 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
sendNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(sendNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {
|
||||||
|
const appendInfo: Info = {
|
||||||
|
seq: noti.seq,
|
||||||
|
type: noti.eventType,
|
||||||
|
senderSeq: noti.SENDER_SEQ,
|
||||||
|
sendDate: noti.sendDate,
|
||||||
|
sentMessage: noti.message,
|
||||||
|
receiverCount: noti.receiverCount
|
||||||
|
};
|
||||||
|
|
||||||
|
this.store.dispatch(
|
||||||
|
newInfo({ roomSeq: noti.roomSeq, info: appendInfo })
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
newInfo$ = createEffect(
|
newInfo$ = createEffect(
|
||||||
() => {
|
() => {
|
||||||
return this.actions$.pipe(
|
return this.actions$.pipe(
|
||||||
|
@ -151,6 +179,39 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
readNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(readNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
cancelNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(cancelNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
|
delNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(delNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
|
|
|
@ -3,7 +3,11 @@ import {
|
||||||
InfoRequest,
|
InfoRequest,
|
||||||
RoomInfo,
|
RoomInfo,
|
||||||
UserInfoShort,
|
UserInfoShort,
|
||||||
UserInfo
|
UserInfo,
|
||||||
|
InviteNotification,
|
||||||
|
ExitNotification,
|
||||||
|
ExitForcingNotification,
|
||||||
|
UpdateFontNotification
|
||||||
} from '@ucap-webmessenger/protocol-room';
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
|
|
||||||
export const info = createAction(
|
export const info = createAction(
|
||||||
|
@ -24,3 +28,23 @@ export const infoFailure = createAction(
|
||||||
'[Messenger::Room] Info Failure',
|
'[Messenger::Room] Info Failure',
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const inviteNotification = createAction(
|
||||||
|
'[Messenger::Room] Invite Notification',
|
||||||
|
props<{ noti: InviteNotification }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const exitNotification = createAction(
|
||||||
|
'[Messenger::Room] Exit Notification',
|
||||||
|
props<{ noti: ExitNotification }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const exitForcingNotification = createAction(
|
||||||
|
'[Messenger::Room] Exit Forcing Notification',
|
||||||
|
props<{ noti: ExitForcingNotification }>()
|
||||||
|
);
|
||||||
|
|
||||||
|
export const updateFontNotification = createAction(
|
||||||
|
'[Messenger::Room] Update Font Notification',
|
||||||
|
props<{ noti: UpdateFontNotification }>()
|
||||||
|
);
|
||||||
|
|
|
@ -24,7 +24,15 @@ import {
|
||||||
|
|
||||||
import * as ChatStore from '@app/store/messenger/chat';
|
import * as ChatStore from '@app/store/messenger/chat';
|
||||||
|
|
||||||
import { info, infoSuccess, infoFailure } from './actions';
|
import {
|
||||||
|
info,
|
||||||
|
infoSuccess,
|
||||||
|
infoFailure,
|
||||||
|
inviteNotification,
|
||||||
|
exitNotification,
|
||||||
|
exitForcingNotification,
|
||||||
|
updateFontNotification
|
||||||
|
} from './actions';
|
||||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||||
|
|
||||||
|
@ -91,6 +99,47 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
inviteNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(inviteNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
exitNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(exitNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
exitForcingNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(exitForcingNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
updateFontNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(updateFontNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import { createAction, props } from '@ngrx/store';
|
import { createAction, props } from '@ngrx/store';
|
||||||
import {
|
import {
|
||||||
BulkInfoRequest,
|
BulkInfoRequest,
|
||||||
StatusBulkInfo
|
StatusBulkInfo,
|
||||||
|
StatusNotification
|
||||||
} from '@ucap-webmessenger/protocol-status';
|
} from '@ucap-webmessenger/protocol-status';
|
||||||
|
|
||||||
export const bulkInfo = createAction(
|
export const bulkInfo = createAction(
|
||||||
|
@ -18,3 +19,8 @@ export const bulkInfoFailure = createAction(
|
||||||
'[Messenger::Status] Bulk Info Failure',
|
'[Messenger::Status] Bulk Info Failure',
|
||||||
props<{ error: any }>()
|
props<{ error: any }>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const statusNotification = createAction(
|
||||||
|
'[Messenger::Status] Status Notification',
|
||||||
|
props<{ noti: StatusNotification }>()
|
||||||
|
);
|
||||||
|
|
|
@ -6,7 +6,12 @@ import { Store } from '@ngrx/store';
|
||||||
|
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
import * as SyncStore from '@app/store/messenger/sync';
|
import * as SyncStore from '@app/store/messenger/sync';
|
||||||
import { bulkInfo, bulkInfoSuccess, bulkInfoFailure } from './actions';
|
import {
|
||||||
|
bulkInfo,
|
||||||
|
bulkInfoSuccess,
|
||||||
|
bulkInfoFailure,
|
||||||
|
statusNotification
|
||||||
|
} from './actions';
|
||||||
import { tap, switchMap, map, catchError } from 'rxjs/operators';
|
import { tap, switchMap, map, catchError } from 'rxjs/operators';
|
||||||
import {
|
import {
|
||||||
StatusProtocolService,
|
StatusProtocolService,
|
||||||
|
@ -68,6 +73,17 @@ export class Effects {
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
statusNotification$ = createEffect(
|
||||||
|
() => {
|
||||||
|
return this.actions$.pipe(
|
||||||
|
ofType(statusNotification),
|
||||||
|
map(action => action.noti),
|
||||||
|
tap(noti => {})
|
||||||
|
);
|
||||||
|
},
|
||||||
|
{ dispatch: false }
|
||||||
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private actions$: Actions,
|
private actions$: Actions,
|
||||||
private store: Store<any>,
|
private store: Store<any>,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user