Merge branch 'master' of http://10.81.13.221:6990/Web/next-ucap-messenger
This commit is contained in:
commit
c90656aabb
|
@ -83,7 +83,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
|
||||||
);
|
);
|
||||||
|
|
||||||
this.eventList$ = this.store.pipe(
|
this.eventList$ = this.store.pipe(
|
||||||
select(AppStore.MessengerSelector.EventSelector.infoList)
|
select(AppStore.MessengerSelector.EventSelector.selectAllInfoList)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.scrollToBottomForMessageBoxContainer();
|
this.scrollToBottomForMessageBoxContainer();
|
||||||
|
|
|
@ -37,6 +37,13 @@ export const newInfo = createAction(
|
||||||
}>()
|
}>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const recallInfoList = createAction(
|
||||||
|
'[Messenger::Event] recall InfoList',
|
||||||
|
props<{
|
||||||
|
eventSeq: number;
|
||||||
|
}>()
|
||||||
|
);
|
||||||
|
|
||||||
export const appendInfoList = createAction(
|
export const appendInfoList = createAction(
|
||||||
'[Messenger::Event] Append InfoList',
|
'[Messenger::Event] Append InfoList',
|
||||||
props<{
|
props<{
|
||||||
|
|
|
@ -39,7 +39,8 @@ import {
|
||||||
sendNotification,
|
sendNotification,
|
||||||
readNotification,
|
readNotification,
|
||||||
cancelNotification,
|
cancelNotification,
|
||||||
delNotification
|
delNotification,
|
||||||
|
recallInfoList
|
||||||
} 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';
|
||||||
|
@ -194,8 +195,20 @@ export class Effects {
|
||||||
() => {
|
() => {
|
||||||
return this.actions$.pipe(
|
return this.actions$.pipe(
|
||||||
ofType(cancelNotification),
|
ofType(cancelNotification),
|
||||||
map(action => action.noti),
|
withLatestFrom(
|
||||||
tap(noti => {})
|
this.store.pipe(
|
||||||
|
select((state: any) => state.messenger.room.roomInfo as RoomInfo)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
tap(([action, roomInfo]) => {
|
||||||
|
if (!!roomInfo && roomInfo.roomSeq === action.noti.roomSeq) {
|
||||||
|
this.logger.debug('cancelNotification$', action, roomInfo);
|
||||||
|
this.store.dispatch(
|
||||||
|
recallInfoList({ eventSeq: action.noti.eventSeq })
|
||||||
|
);
|
||||||
|
// this.store.dispatch(ChatStore.newEventMessage(action));
|
||||||
|
}
|
||||||
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
{ dispatch: false }
|
{ dispatch: false }
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
import { createReducer, on } from '@ngrx/store';
|
import { createReducer, on } from '@ngrx/store';
|
||||||
import { initialState } from './state';
|
import { initialState, adapterInfoList } from './state';
|
||||||
import { infoSuccess, appendInfoList, info, infoFailure } from './actions';
|
import {
|
||||||
|
infoSuccess,
|
||||||
|
appendInfoList,
|
||||||
|
info,
|
||||||
|
infoFailure,
|
||||||
|
recallInfoList
|
||||||
|
} from './actions';
|
||||||
import * as AuthenticationStore from '@app/store/account/authentication';
|
import * as AuthenticationStore from '@app/store/account/authentication';
|
||||||
|
import { Info, EventType } from '@ucap-webmessenger/protocol-event';
|
||||||
|
|
||||||
export const reducer = createReducer(
|
export const reducer = createReducer(
|
||||||
initialState,
|
initialState,
|
||||||
|
@ -15,7 +22,9 @@ export const reducer = createReducer(
|
||||||
on(infoSuccess, (state, action) => {
|
on(infoSuccess, (state, action) => {
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
infoList: action.infoList,
|
infoList: adapterInfoList.addAll(action.infoList, {
|
||||||
|
...state.infoList
|
||||||
|
}),
|
||||||
infoStatus: action.res,
|
infoStatus: action.res,
|
||||||
infoListProcessing: false
|
infoListProcessing: false
|
||||||
};
|
};
|
||||||
|
@ -29,9 +38,38 @@ export const reducer = createReducer(
|
||||||
}),
|
}),
|
||||||
|
|
||||||
on(appendInfoList, (state, action) => {
|
on(appendInfoList, (state, action) => {
|
||||||
|
const eventinfo = action.info;
|
||||||
|
|
||||||
|
const statusEventInfo: Info = {
|
||||||
|
...state.infoList.entities[eventinfo.seq],
|
||||||
|
type: eventinfo.type,
|
||||||
|
senderSeq: eventinfo.senderSeq,
|
||||||
|
sendDate: eventinfo.sendDate,
|
||||||
|
sentMessage: eventinfo.sentMessage,
|
||||||
|
receiverCount: eventinfo.receiverCount
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
infoList: [...state.infoList, action.info]
|
infoList: adapterInfoList.upsertOne(eventinfo, { ...state.infoList })
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
|
on(recallInfoList, (state, action) => {
|
||||||
|
const eventSeq = action.eventSeq;
|
||||||
|
|
||||||
|
const statusEventInfo: Info = {
|
||||||
|
...state.infoList.entities[eventSeq],
|
||||||
|
type: EventType.RecalledMessage,
|
||||||
|
sentMessage: '회수된 메시지'
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
infoList: adapterInfoList.updateOne(
|
||||||
|
{ id: eventSeq, changes: statusEventInfo },
|
||||||
|
{ ...state.infoList }
|
||||||
|
)
|
||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,40 @@
|
||||||
import { Selector, createSelector } from '@ngrx/store';
|
import { Selector, createSelector } from '@ngrx/store';
|
||||||
import { InfoResponse, Info } from '@ucap-webmessenger/protocol-event';
|
import { InfoResponse, Info } from '@ucap-webmessenger/protocol-event';
|
||||||
|
import { EntityState, createEntityAdapter } from '@ngrx/entity';
|
||||||
|
|
||||||
|
export interface InfoListState extends EntityState<Info> {}
|
||||||
|
|
||||||
export interface State {
|
export interface State {
|
||||||
infoListProcessing: boolean;
|
infoListProcessing: boolean;
|
||||||
infoList: Info[] | null;
|
infoList: InfoListState;
|
||||||
infoStatus: InfoResponse | null;
|
infoStatus: InfoResponse | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const adapterInfoList = createEntityAdapter<Info>({
|
||||||
|
selectId: info => info.seq
|
||||||
|
});
|
||||||
|
|
||||||
|
const infoListInitialState: InfoListState = adapterInfoList.getInitialState({});
|
||||||
|
|
||||||
export const initialState: State = {
|
export const initialState: State = {
|
||||||
infoListProcessing: false,
|
infoListProcessing: false,
|
||||||
infoList: null,
|
infoList: infoListInitialState,
|
||||||
infoStatus: null
|
infoStatus: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const {
|
||||||
|
selectAll: ngeSelectAllInfoList,
|
||||||
|
selectEntities: ngeSelectEntitiesInfoList,
|
||||||
|
selectIds: ngeSelectIdsInfoList,
|
||||||
|
selectTotal: ngeSelectTotalInfoList
|
||||||
|
} = adapterInfoList.getSelectors();
|
||||||
|
|
||||||
export function selectors<S>(selector: Selector<any, State>) {
|
export function selectors<S>(selector: Selector<any, State>) {
|
||||||
|
const selectInfoList = createSelector(
|
||||||
|
selector,
|
||||||
|
(state: State) => state.infoList
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
infoListProcessing: createSelector(
|
infoListProcessing: createSelector(
|
||||||
selector,
|
selector,
|
||||||
|
@ -26,6 +47,21 @@ export function selectors<S>(selector: Selector<any, State>) {
|
||||||
infoStatus: createSelector(
|
infoStatus: createSelector(
|
||||||
selector,
|
selector,
|
||||||
(state: State) => state.infoStatus
|
(state: State) => state.infoStatus
|
||||||
|
),
|
||||||
|
|
||||||
|
selectAllInfoList: createSelector(
|
||||||
|
selectInfoList,
|
||||||
|
ngeSelectAllInfoList
|
||||||
|
),
|
||||||
|
selectEntitiesInfoList: createSelector(
|
||||||
|
selectInfoList,
|
||||||
|
ngeSelectEntitiesInfoList
|
||||||
|
),
|
||||||
|
selectInfoList: (seq: number) =>
|
||||||
|
createSelector(
|
||||||
|
selectInfoList,
|
||||||
|
ngeSelectEntitiesInfoList,
|
||||||
|
(_, entities) => (!!entities ? entities[seq] : undefined)
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<div>
|
<div>
|
||||||
<div class="room-name">{{ getRoomName(roomInfo) }}</div>
|
<div class="room-name">{{ getRoomName(roomInfo) }}</div>
|
||||||
<div>{{ roomInfo.finalEventDate }}</div>
|
<div>{{ roomInfo.finalEventDate }}</div>
|
||||||
<div>{{ roomInfo.finalEventMessage }}</div>
|
<div>{{ finalEventMessage }}</div>
|
||||||
|
<div *ngIf="roomInfo.noReadCnt > 0">noReadCnt : {{ roomInfo.noReadCnt }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,10 +2,18 @@ import { Component, OnInit, Input } from '@angular/core';
|
||||||
import {
|
import {
|
||||||
RoomInfo,
|
RoomInfo,
|
||||||
UserInfoShort,
|
UserInfoShort,
|
||||||
UserInfo as RoomUserInfo
|
UserInfo as RoomUserInfo,
|
||||||
|
RoomType
|
||||||
} from '@ucap-webmessenger/protocol-room';
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
||||||
|
import { EventType } from '@ucap-webmessenger/protocol-event';
|
||||||
|
import {
|
||||||
|
FileInfo,
|
||||||
|
StickerInfo,
|
||||||
|
MassTextInfo
|
||||||
|
} from '@ucap-webmessenger/ui-chat';
|
||||||
|
import { FileType } from '@ucap-webmessenger/protocol-file';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ucap-room-list-item',
|
selector: 'ucap-room-list-item',
|
||||||
|
@ -20,10 +28,60 @@ export class ListItemComponent implements OnInit {
|
||||||
@Input()
|
@Input()
|
||||||
sessionVerinfo: VersionInfo2Response;
|
sessionVerinfo: VersionInfo2Response;
|
||||||
|
|
||||||
|
finalEventMessage: string;
|
||||||
|
|
||||||
constructor(private logger: NGXLogger) {}
|
constructor(private logger: NGXLogger) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
// this.logger.debug(this.roomInfo);
|
if (this.roomInfo.isTimeRoom) {
|
||||||
|
this.finalEventMessage = '비밀 대화방입니다.';
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
switch (this.roomInfo.finalEventType) {
|
||||||
|
case EventType.File:
|
||||||
|
{
|
||||||
|
let msg = 'Attach File';
|
||||||
|
const contentJson: FileInfo = JSON.parse(
|
||||||
|
this.roomInfo.finalEventMessage
|
||||||
|
);
|
||||||
|
if (contentJson.FileType === FileType.File) {
|
||||||
|
msg = '첨부파일';
|
||||||
|
} else if (contentJson.FileType === FileType.Image) {
|
||||||
|
msg = '이미지';
|
||||||
|
} else if (contentJson.FileType === FileType.Video) {
|
||||||
|
msg = '동영상';
|
||||||
|
}
|
||||||
|
this.finalEventMessage = msg;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EventType.Sticker:
|
||||||
|
{
|
||||||
|
let msg = '스티커';
|
||||||
|
const contentJson: StickerInfo = JSON.parse(
|
||||||
|
this.roomInfo.finalEventMessage
|
||||||
|
);
|
||||||
|
if (contentJson.chat) {
|
||||||
|
msg += ' ' + contentJson.chat;
|
||||||
|
}
|
||||||
|
this.finalEventMessage = msg;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EventType.MassText:
|
||||||
|
{
|
||||||
|
const contentJson: MassTextInfo = JSON.parse(
|
||||||
|
this.roomInfo.finalEventMessage
|
||||||
|
);
|
||||||
|
this.finalEventMessage = contentJson.Content;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
this.finalEventMessage = this.roomInfo.finalEventMessage;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error(e);
|
||||||
|
this.finalEventMessage = this.roomInfo.finalEventMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getRoomName(roomInfo: RoomInfo): string {
|
getRoomName(roomInfo: RoomInfo): string {
|
||||||
|
@ -31,6 +89,10 @@ export class ListItemComponent implements OnInit {
|
||||||
return roomInfo.roomName;
|
return roomInfo.roomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (roomInfo.roomType === RoomType.Mytalk) {
|
||||||
|
return 'MyTalk';
|
||||||
|
}
|
||||||
|
|
||||||
if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) {
|
if (!!this.roomUserInfo && 0 < this.roomUserInfo.length) {
|
||||||
let roomName = '';
|
let roomName = '';
|
||||||
this.roomUserInfo.forEach((roomUserInfo, index) => {
|
this.roomUserInfo.forEach((roomUserInfo, index) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user