chat list is modified
This commit is contained in:
parent
0703e2807a
commit
fdf1c14b7e
|
@ -1,3 +1,4 @@
|
||||||
<div *ngFor="let room of roomList$ | async" (click)="onSelectedRoom(room)">
|
<div *ngFor="let room of roomList" (click)="onSelectedRoom(room)">
|
||||||
{{ room.finalEventMessage }}
|
<div class="room-name">{{ getRoomName(room) }}</div>
|
||||||
|
<div class="room-name">{{ room.finalEventMessage }}</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
.room-name {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
|
@ -1,11 +1,16 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, OnDestroy } from '@angular/core';
|
||||||
import { ucapAnimations } from '@ucap-webmessenger/ui';
|
import { ucapAnimations } from '@ucap-webmessenger/ui';
|
||||||
import { NGXLogger } from 'ngx-logger';
|
import { NGXLogger } from 'ngx-logger';
|
||||||
import { Store, select } from '@ngrx/store';
|
import { Store, select } from '@ngrx/store';
|
||||||
import { Observable } from 'rxjs';
|
import { Subscription } from 'rxjs';
|
||||||
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
import {
|
||||||
|
RoomInfo,
|
||||||
|
UserInfoShort,
|
||||||
|
UserInfo as RoomUserInfo
|
||||||
|
} from '@ucap-webmessenger/protocol-room';
|
||||||
import * as AppStore from '@app/store';
|
import * as AppStore from '@app/store';
|
||||||
import * as ChatStore from '@app/store/messenger/chat';
|
import * as ChatStore from '@app/store/messenger/chat';
|
||||||
|
import { tap } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-layout-chat-left-sidenav-chat',
|
selector: 'app-layout-chat-left-sidenav-chat',
|
||||||
|
@ -13,18 +18,78 @@ import * as ChatStore from '@app/store/messenger/chat';
|
||||||
styleUrls: ['./chat.component.scss'],
|
styleUrls: ['./chat.component.scss'],
|
||||||
animations: ucapAnimations
|
animations: ucapAnimations
|
||||||
})
|
})
|
||||||
export class ChatComponent implements OnInit {
|
export class ChatComponent implements OnInit, OnDestroy {
|
||||||
roomList$: Observable<RoomInfo[]>;
|
roomList: RoomInfo[];
|
||||||
|
roomUserInfoMap: {
|
||||||
|
[param: string]: {
|
||||||
|
userInfoShortList: UserInfoShort[];
|
||||||
|
userInfoList: RoomUserInfo[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
roomSubscription: Subscription;
|
||||||
|
|
||||||
constructor(private store: Store<any>, private logger: NGXLogger) {}
|
constructor(private store: Store<any>, private logger: NGXLogger) {}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.roomList$ = this.store.pipe(
|
this.roomSubscription = this.store
|
||||||
select(AppStore.MessengerSelector.SyncSelector.roomList)
|
.pipe(
|
||||||
);
|
select(AppStore.MessengerSelector.SyncSelector.room),
|
||||||
|
tap(room => {
|
||||||
|
this.roomList = room.roomList;
|
||||||
|
this.roomUserInfoMap = room.roomUserInfoMap;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.subscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnDestroy(): void {
|
||||||
|
if (!!this.roomSubscription) {
|
||||||
|
this.roomSubscription.unsubscribe();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onSelectedRoom(roomInfo: RoomInfo) {
|
onSelectedRoom(roomInfo: RoomInfo) {
|
||||||
this.store.dispatch(ChatStore.selectedRoom({ roomSeq: roomInfo.roomSeq }));
|
this.store.dispatch(ChatStore.selectedRoom({ roomSeq: roomInfo.roomSeq }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRoomName(roomInfo: RoomInfo): string {
|
||||||
|
if (!!roomInfo.roomName && '' !== roomInfo.roomName.trim()) {
|
||||||
|
return roomInfo.roomName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!!this.roomUserInfoMap[roomInfo.roomSeq].userInfoList &&
|
||||||
|
0 < this.roomUserInfoMap[roomInfo.roomSeq].userInfoList.length
|
||||||
|
) {
|
||||||
|
let roomName = '';
|
||||||
|
this.roomUserInfoMap[roomInfo.roomSeq].userInfoList.forEach(
|
||||||
|
(roomUserInfo, index) => {
|
||||||
|
if (0 === index) {
|
||||||
|
roomName = roomName.concat('', roomUserInfo.name);
|
||||||
|
} else {
|
||||||
|
roomName = roomName.concat(',', roomUserInfo.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return roomName;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
!!this.roomUserInfoMap[roomInfo.roomSeq].userInfoShortList &&
|
||||||
|
0 < this.roomUserInfoMap[roomInfo.roomSeq].userInfoShortList.length
|
||||||
|
) {
|
||||||
|
let roomName = '';
|
||||||
|
this.roomUserInfoMap[roomInfo.roomSeq].userInfoShortList.forEach(
|
||||||
|
(roomUserInfo, index) => {
|
||||||
|
if (0 === index) {
|
||||||
|
roomName = roomName.concat('', roomUserInfo.name);
|
||||||
|
} else {
|
||||||
|
roomName = roomName.concat(',', roomUserInfo.name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return roomName;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,15 @@
|
||||||
import { createAction, props } from '@ngrx/store';
|
import { createAction, props } from '@ngrx/store';
|
||||||
|
import { Info } from '@ucap-webmessenger/protocol-event';
|
||||||
|
|
||||||
export const selectedRoom = createAction(
|
export const selectedRoom = createAction(
|
||||||
'[Messenger::Chat] selectedRoom',
|
'[Messenger::Chat] selectedRoom',
|
||||||
props<{ roomSeq: string }>()
|
props<{ roomSeq: string }>()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const newEventMessage = createAction(
|
||||||
|
'[Messenger::Chat] newEventMessage',
|
||||||
|
props<{
|
||||||
|
roomSeq: string;
|
||||||
|
info: Info;
|
||||||
|
}>()
|
||||||
|
);
|
||||||
|
|
|
@ -143,6 +143,8 @@ export class Effects {
|
||||||
if (roomInfo.roomSeq === action.roomSeq) {
|
if (roomInfo.roomSeq === action.roomSeq) {
|
||||||
this.store.dispatch(appendInfoList({ info: action.info }));
|
this.store.dispatch(appendInfoList({ info: action.info }));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.store.dispatch(ChatStore.newEventMessage(action));
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,6 +2,9 @@ import { createReducer, on } from '@ngrx/store';
|
||||||
import { initialState } from './state';
|
import { initialState } from './state';
|
||||||
import { buddy2Success, group2Success, roomSuccess } from './actions';
|
import { buddy2Success, group2Success, roomSuccess } from './actions';
|
||||||
|
|
||||||
|
import * as ChatStore from '@app/store/messenger/chat';
|
||||||
|
import { RoomInfo } from '@ucap-webmessenger/protocol-room';
|
||||||
|
|
||||||
export const reducer = createReducer(
|
export const reducer = createReducer(
|
||||||
initialState,
|
initialState,
|
||||||
on(buddy2Success, (state, action) => {
|
on(buddy2Success, (state, action) => {
|
||||||
|
@ -27,5 +30,25 @@ export const reducer = createReducer(
|
||||||
roomUserInfoMap: action.roomUserInfoMap,
|
roomUserInfoMap: action.roomUserInfoMap,
|
||||||
roomSyncDate: action.syncDate
|
roomSyncDate: action.syncDate
|
||||||
};
|
};
|
||||||
|
}),
|
||||||
|
|
||||||
|
on(ChatStore.newEventMessage, (state, action) => {
|
||||||
|
const roomList: RoomInfo[] = [];
|
||||||
|
|
||||||
|
state.roomList.forEach((roomInfo, index) => {
|
||||||
|
if (roomInfo.roomSeq === action.roomSeq) {
|
||||||
|
roomList.push({
|
||||||
|
...roomInfo,
|
||||||
|
finalEventMessage: action.info.sentMessage
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
roomList.push(roomInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
roomList
|
||||||
|
};
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
|
@ -60,9 +60,14 @@ export function selectors<S>(selector: Selector<any, State>) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
roomList: createSelector(
|
room: createSelector(
|
||||||
selector,
|
selector,
|
||||||
(state: State) => state.roomList
|
(state: State) => {
|
||||||
|
return {
|
||||||
|
roomList: state.roomList,
|
||||||
|
roomUserInfoMap: state.roomUserInfoMap
|
||||||
|
};
|
||||||
|
}
|
||||||
),
|
),
|
||||||
roomSyncDate: createSelector(
|
roomSyncDate: createSelector(
|
||||||
selector,
|
selector,
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
export enum RoomType {
|
export enum RoomType {
|
||||||
// S: 1: 1 대화
|
/** S: 1: 1 대화 */
|
||||||
Single = 'S',
|
Single = 'S',
|
||||||
// M: 멀티대화
|
/** M: 멀티대화 */
|
||||||
Multi = 'M',
|
Multi = 'M',
|
||||||
// B: Bot대화
|
/** B: Bot대화 */
|
||||||
Bot = 'B',
|
Bot = 'B',
|
||||||
// A: 알림방
|
/** A: 알림방 */
|
||||||
Allim = 'A',
|
Allim = 'A',
|
||||||
|
|
||||||
// // X: 확장대화 deprecated
|
// // X: 확장대화 deprecated
|
||||||
|
@ -13,9 +13,9 @@ export enum RoomType {
|
||||||
// // N: 공지대화 deprecated
|
// // N: 공지대화 deprecated
|
||||||
// Notice = 'N',
|
// Notice = 'N',
|
||||||
|
|
||||||
// L: 링크(Legacy)
|
/** L: 링크(Legacy) */
|
||||||
Link = 'L',
|
Link = 'L',
|
||||||
// K: MyTalk(나와의 대화)
|
/** K: MyTalk(나와의 대화) */
|
||||||
Mytalk = 'K'
|
Mytalk = 'K'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,3 +23,32 @@ export enum RoomExitType {
|
||||||
// A 만 사용하고 있고, 서버에서도 달리 처리하지는 않음, 하지만 추후 사용성을 위해 생성.
|
// A 만 사용하고 있고, 서버에서도 달리 처리하지는 않음, 하지만 추후 사용성을 위해 생성.
|
||||||
All = 'A'
|
All = 'A'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isGroupRoom(roomType: RoomType): boolean {
|
||||||
|
return RoomType.Multi === roomType;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isSendRoom(roomType: RoomType): boolean {
|
||||||
|
return (
|
||||||
|
RoomType.Single === roomType ||
|
||||||
|
RoomType.Multi === roomType ||
|
||||||
|
RoomType.Mytalk === roomType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isFunctionRoom(roomType: RoomType): boolean {
|
||||||
|
return (
|
||||||
|
RoomType.Single === roomType ||
|
||||||
|
RoomType.Multi === roomType ||
|
||||||
|
RoomType.Mytalk === roomType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isReadCountRoom(roomType: RoomType): boolean {
|
||||||
|
return (
|
||||||
|
RoomType.Single === roomType ||
|
||||||
|
RoomType.Multi === roomType ||
|
||||||
|
RoomType.Bot === roomType ||
|
||||||
|
RoomType.Allim === roomType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user