room info is implemented
This commit is contained in:
parent
bf2490dda3
commit
9aae0885aa
|
@ -1 +1,3 @@
|
|||
<div *ngFor="let room of roomList$ | async">{{ room.finalEventMessage }}</div>
|
||||
<div *ngFor="let room of roomList$ | async" (click)="onSelectedRoom(room)">
|
||||
{{ room.finalEventMessage }}
|
||||
</div>
|
||||
|
|
|
@ -5,6 +5,7 @@ import { Store, select } from '@ngrx/store';
|
|||
import { Observable } from 'rxjs';
|
||||
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
||||
import * as AppStore from '@app/store';
|
||||
import * as ChatStore from '@app/store/messenger/chat';
|
||||
|
||||
@Component({
|
||||
selector: 'app-layout-chat-left-sidenav-chat',
|
||||
|
@ -22,4 +23,8 @@ export class ChatComponent implements OnInit {
|
|||
select(AppStore.MessengerSelector.SyncSelector.roomList)
|
||||
);
|
||||
}
|
||||
|
||||
onSelectedRoom(roomInfo: RoomInfo) {
|
||||
this.store.dispatch(ChatStore.selectedRoom({ roomSeq: roomInfo.roomSeq }));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ export class GroupComponent implements OnInit {
|
|||
}
|
||||
|
||||
onSelectBuddy(buddy: UserInfo) {
|
||||
this.store.dispatch(ChatStore.selectedRoom({ roomSeq: buddy.seq }));
|
||||
this.store.dispatch(ChatStore.selectedRoom({ roomSeq: String(buddy.seq) }));
|
||||
}
|
||||
|
||||
onKeyDownEnterOrganizationTenantSearch(params: {
|
||||
|
|
|
@ -11,7 +11,7 @@ import { Observable } from 'rxjs';
|
|||
styleUrls: ['./main.page.component.scss']
|
||||
})
|
||||
export class MainPageComponent implements OnInit {
|
||||
selectedChat$: Observable<number | null>;
|
||||
selectedChat$: Observable<string | null>;
|
||||
|
||||
constructor(private store: Store<any>) {}
|
||||
|
||||
|
|
|
@ -2,5 +2,5 @@ import { createAction, props } from '@ngrx/store';
|
|||
|
||||
export const selectedRoom = createAction(
|
||||
'[Messenger::Chat] selectedRoom',
|
||||
props<{ roomSeq: number }>()
|
||||
props<{ roomSeq: string }>()
|
||||
);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Selector, createSelector } from '@ngrx/store';
|
||||
|
||||
export interface State {
|
||||
selectedRoom: number | null;
|
||||
selectedRoom: string | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
|
|
|
@ -4,6 +4,7 @@ import { Action, combineReducers, Selector, createSelector } from '@ngrx/store';
|
|||
import * as ChatStore from './chat';
|
||||
import * as OptionStore from './option';
|
||||
import * as QueryStore from './query';
|
||||
import * as RoomStore from './room';
|
||||
import * as StatusStore from './status';
|
||||
import * as SyncStore from './sync';
|
||||
|
||||
|
@ -11,6 +12,7 @@ export interface State {
|
|||
chat: ChatStore.State;
|
||||
option: OptionStore.State;
|
||||
query: QueryStore.State;
|
||||
room: RoomStore.State;
|
||||
status: StatusStore.State;
|
||||
sync: SyncStore.State;
|
||||
}
|
||||
|
@ -19,6 +21,7 @@ export const effects: Type<any>[] = [
|
|||
ChatStore.Effects,
|
||||
OptionStore.Effects,
|
||||
QueryStore.Effects,
|
||||
RoomStore.Effects,
|
||||
StatusStore.Effects,
|
||||
SyncStore.Effects
|
||||
];
|
||||
|
@ -28,6 +31,7 @@ export function reducers(state: State | undefined, action: Action) {
|
|||
chat: ChatStore.reducer,
|
||||
option: OptionStore.reducer,
|
||||
query: QueryStore.reducer,
|
||||
room: RoomStore.reducer,
|
||||
status: StatusStore.reducer,
|
||||
sync: SyncStore.reducer
|
||||
})(state, action);
|
||||
|
@ -47,6 +51,12 @@ export function selectors<S>(selector: Selector<any, State>) {
|
|||
(state: State) => state.option
|
||||
)
|
||||
),
|
||||
RoomSelector: RoomStore.selectors(
|
||||
createSelector(
|
||||
selector,
|
||||
(state: State) => state.room
|
||||
)
|
||||
),
|
||||
QuerySelector: QueryStore.selectors(
|
||||
createSelector(
|
||||
selector,
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
import { createAction, props } from '@ngrx/store';
|
||||
import {
|
||||
InfoRequest,
|
||||
RoomInfo,
|
||||
UserInfoShort,
|
||||
UserInfo
|
||||
} from '@ucap-webmessenger/protocol-room';
|
||||
|
||||
export const info = createAction(
|
||||
'[Messenger::Room] Info',
|
||||
props<InfoRequest>()
|
||||
);
|
||||
|
||||
export const infoSuccess = createAction(
|
||||
'[Messenger::Room] Info Success',
|
||||
props<{
|
||||
roomInfo: RoomInfo;
|
||||
userInfoShortList: UserInfoShort[];
|
||||
userInfoList: UserInfo[];
|
||||
}>()
|
||||
);
|
||||
|
||||
export const infoFailure = createAction(
|
||||
'[Messenger::Room] Info Failure',
|
||||
props<{ error: any }>()
|
||||
);
|
|
@ -0,0 +1,101 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { NGXLogger } from 'ngx-logger';
|
||||
|
||||
import { of } from 'rxjs';
|
||||
import { tap, switchMap, map, catchError } from 'rxjs/operators';
|
||||
import {
|
||||
RoomInfo,
|
||||
UserInfoShort,
|
||||
UserInfo,
|
||||
RoomProtocolService,
|
||||
SSVC_TYPE_ROOM_INFO_ROOM,
|
||||
InfoData,
|
||||
SSVC_TYPE_ROOM_INFO_USER,
|
||||
SSVC_TYPE_ROOM_INFO_USER2,
|
||||
SSVC_TYPE_ROOM_INFO_RES,
|
||||
UserShortData,
|
||||
UserData
|
||||
} from '@ucap-webmessenger/protocol-room';
|
||||
|
||||
import * as ChatStore from '@app/store/messenger/chat';
|
||||
|
||||
import { info, infoSuccess, infoFailure } from './actions';
|
||||
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
|
||||
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
|
||||
|
||||
@Injectable()
|
||||
export class Effects {
|
||||
selectedRoomForInfo$ = createEffect(() =>
|
||||
this.actions$.pipe(
|
||||
ofType(ChatStore.selectedRoom),
|
||||
map(action => {
|
||||
const loginInfo = this.sessionStorageService.get<LoginInfo>(
|
||||
KEY_LOGIN_INFO
|
||||
);
|
||||
return info({
|
||||
roomSeq: action.roomSeq,
|
||||
isDetail: true,
|
||||
localeCode: loginInfo.localeCode
|
||||
});
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
info$ = createEffect(
|
||||
() => {
|
||||
let roomInfo: RoomInfo;
|
||||
let userInfoShortList: UserInfoShort[];
|
||||
let userInfoList: UserInfo[];
|
||||
|
||||
return this.actions$.pipe(
|
||||
ofType(info),
|
||||
tap(() => {
|
||||
roomInfo = null;
|
||||
userInfoShortList = [];
|
||||
userInfoList = [];
|
||||
}),
|
||||
switchMap(req => {
|
||||
return this.roomProtocolService.info(req).pipe(
|
||||
map(res => {
|
||||
switch (res.Type) {
|
||||
case SSVC_TYPE_ROOM_INFO_ROOM:
|
||||
roomInfo = (res as InfoData).roomInfo;
|
||||
break;
|
||||
case SSVC_TYPE_ROOM_INFO_USER:
|
||||
userInfoShortList.push(...(res as UserShortData).userInfos);
|
||||
break;
|
||||
case SSVC_TYPE_ROOM_INFO_USER2:
|
||||
userInfoList.push(...(res as UserData).userInfos);
|
||||
break;
|
||||
case SSVC_TYPE_ROOM_INFO_RES:
|
||||
this.store.dispatch(
|
||||
infoSuccess({
|
||||
roomInfo,
|
||||
userInfoShortList,
|
||||
userInfoList
|
||||
})
|
||||
);
|
||||
break;
|
||||
}
|
||||
}),
|
||||
catchError(error => of(infoFailure({ error })))
|
||||
);
|
||||
})
|
||||
);
|
||||
},
|
||||
{ dispatch: false }
|
||||
);
|
||||
|
||||
constructor(
|
||||
private actions$: Actions,
|
||||
private store: Store<any>,
|
||||
private roomProtocolService: RoomProtocolService,
|
||||
private sessionStorageService: SessionStorageService,
|
||||
private logger: NGXLogger
|
||||
) {}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export * from './actions';
|
||||
export * from './effects';
|
||||
export * from './reducers';
|
||||
export * from './state';
|
|
@ -0,0 +1,15 @@
|
|||
import { createReducer, on } from '@ngrx/store';
|
||||
import { initialState } from './state';
|
||||
import { infoSuccess } from './actions';
|
||||
|
||||
export const reducer = createReducer(
|
||||
initialState,
|
||||
on(infoSuccess, (state, action) => {
|
||||
return {
|
||||
...state,
|
||||
roomInfo: action.roomInfo,
|
||||
userInfoList: action.userInfoList,
|
||||
userInfoShortList: action.userInfoShortList
|
||||
};
|
||||
})
|
||||
);
|
|
@ -0,0 +1,36 @@
|
|||
import { Selector, createSelector } from '@ngrx/store';
|
||||
import {
|
||||
InfoRequest,
|
||||
RoomInfo,
|
||||
UserInfoShort,
|
||||
UserInfo
|
||||
} from '@ucap-webmessenger/protocol-room';
|
||||
|
||||
export interface State {
|
||||
roomInfo: RoomInfo | null;
|
||||
userInfoShortList: UserInfoShort[] | null;
|
||||
userInfoList: UserInfo[] | null;
|
||||
}
|
||||
|
||||
export const initialState: State = {
|
||||
roomInfo: null,
|
||||
userInfoShortList: null,
|
||||
userInfoList: null
|
||||
};
|
||||
|
||||
export function selectors<S>(selector: Selector<any, State>) {
|
||||
return {
|
||||
roomInfo: createSelector(
|
||||
selector,
|
||||
(state: State) => state.roomInfo
|
||||
),
|
||||
userInfoShortList: createSelector(
|
||||
selector,
|
||||
(state: State) => state.userInfoShortList
|
||||
),
|
||||
userInfoList: createSelector(
|
||||
selector,
|
||||
(state: State) => state.userInfoList
|
||||
)
|
||||
};
|
||||
}
|
|
@ -13,5 +13,6 @@ export * from './lib/protocols/open';
|
|||
export * from './lib/services/room-protocol.service';
|
||||
export * from './lib/types/employee.type';
|
||||
export * from './lib/types/room.type';
|
||||
export * from './lib/types/service';
|
||||
|
||||
export * from './lib/ucap-room-protocol.module';
|
||||
|
|
Loading…
Reference in New Issue
Block a user