This commit is contained in:
병준 박 2019-10-31 17:09:47 +09:00
commit 9853438691
10 changed files with 161 additions and 30 deletions

View File

@ -59,7 +59,7 @@ export class LeftSideComponent implements OnInit {
];
}
async onClickNewChat() {
async onClickNewChat(type: string = 'NORMAL') {
const result = await this.dialogService.open<
CreateChatDialogComponent,
CreateChatDialogData,
@ -69,7 +69,7 @@ export class LeftSideComponent implements OnInit {
height: '500px',
data: {
type: UserSelectDialogType.NewChat,
title: 'New Chat'
title: type === 'TIMER' ? 'New Timer Chat' : 'New Chat'
}
});
@ -78,7 +78,13 @@ export class LeftSideComponent implements OnInit {
const userSeqs: number[] = [];
result.selectedUserList.map(user => userSeqs.push(user.seq));
this.store.dispatch(ChatStore.openRoom({ userSeqList: userSeqs }));
if (type === 'NORMAL') {
this.store.dispatch(ChatStore.openRoom({ userSeqList: userSeqs }));
} else if (type === 'TIMER') {
this.store.dispatch(
ChatStore.openRoom({ userSeqList: userSeqs, isTimeRoom: true })
);
}
}
}
}
@ -134,11 +140,12 @@ export class LeftSideComponent implements OnInit {
switch (btn.divisionType) {
case 'NEW_CHAT':
{
this.onClickNewChat();
this.onClickNewChat('NORMAL');
}
break;
case 'NEW_TIMER_CHAT':
{
this.onClickNewChat('TIMER');
}
break;
}

View File

@ -18,6 +18,9 @@
<div class="room-name">
{{ getRoomName() }}
</div>
<div *ngIf="!!roomInfo && roomInfo.isTimeRoom">
<mat-icon>timer</mat-icon> {{ getConvertTimer(roomInfo.timeRoomInterval) }}
</div>
<div class="room-option">
<button
*ngIf="!!roomInfo"

View File

@ -200,6 +200,18 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewChecked {
}
}
getConvertTimer(timerInterval: number, unit: number = 1) {
if (timerInterval >= 0 && timerInterval < 60 * unit) {
return Math.floor((timerInterval / 1) * unit) + ' 초';
} else if (timerInterval >= 60 * unit && timerInterval < 3600 * unit) {
return Math.floor(((timerInterval / 1) * unit) / 60) + ' 분';
} else if (timerInterval >= 3600 * unit && timerInterval <= 86400 * unit) {
return Math.floor(((timerInterval / 1) * unit) / 60 / 60) + ' 시간';
} else {
return '';
}
}
selectContact() {}
async onSendMessage(message: string) {

View File

@ -41,5 +41,5 @@ export const massTalkDownloadFailure = createAction(
export const openRoom = createAction(
'[Messenger::Chat] Open Room',
props<{ userSeqList: number[] }>()
props<{ userSeqList: number[]; isTimeRoom?: boolean }>()
);

View File

@ -13,7 +13,9 @@ import {
OpenRequest,
OpenResponse,
ExitRequest,
ExitResponse
ExitResponse,
Open3Request,
Open3Response
} from '@ucap-webmessenger/protocol-room';
import { ReadNotification } from '@ucap-webmessenger/protocol-event';
@ -87,19 +89,32 @@ export const open = createAction(
'[Messenger::Room] Open',
props<{ req: OpenRequest }>()
);
export const openSuccess = createAction(
'[Messenger::Room] Open Success',
props<{
res: OpenResponse;
}>()
);
export const openFailure = createAction(
'[Messenger::Room] Open Failure',
props<{ error: any }>()
);
export const openTimer = createAction(
'[Messenger::Room] Open Timer',
props<{ req: Open3Request }>()
);
export const openTimerSuccess = createAction(
'[Messenger::Room] Open Timer Success',
props<{
res: Open3Response;
}>()
);
export const openTimerFailure = createAction(
'[Messenger::Room] Open Timer Failure',
props<{ error: any }>()
);
export const exit = createAction(
'[Messenger::Room] Exit',
props<ExitRequest>()

View File

@ -29,7 +29,8 @@ import {
UserData,
UpdateResponse,
OpenResponse,
ExitResponse
ExitResponse,
Open3Response
} from '@ucap-webmessenger/protocol-room';
import * as ChatStore from '@app/store/messenger/chat';
@ -51,7 +52,10 @@ import {
openFailure,
exit,
exitSuccess,
exitFailure
exitFailure,
openTimer,
openTimerSuccess,
openTimerFailure
} from './actions';
import { SessionStorageService } from '@ucap-webmessenger/web-storage';
import { LoginInfo, KEY_LOGIN_INFO } from '@app/types';
@ -168,7 +172,6 @@ export class Effects {
})
)
);
openSuccess$ = createEffect(() =>
this.actions$.pipe(
ofType(openSuccess),
@ -178,6 +181,29 @@ export class Effects {
)
);
openTimer$ = createEffect(() =>
this.actions$.pipe(
ofType(openTimer),
map(action => action.req),
exhaustMap(req => {
return this.roomProtocolService.open3(req).pipe(
map((res: Open3Response) => {
return openTimerSuccess({ res });
}),
catchError(error => of(openTimerFailure({ error })))
);
})
)
);
openTimerSuccess$ = createEffect(() =>
this.actions$.pipe(
ofType(openTimerSuccess),
map(action => {
return ChatStore.selectedRoom({ roomSeq: action.res.roomSeq });
})
)
);
exit$ = createEffect(() =>
this.actions$.pipe(
ofType(exit),

View File

@ -1,4 +1,4 @@
import { GroupProtocolService } from './../../../../../../ucap-webmessenger-protocol-group/src/lib/services/group-protocol.service';
import { openTimer } from './../room/actions';
import { Injectable } from '@angular/core';
import { Actions, ofType, createEffect } from '@ngrx/effects';
@ -87,6 +87,7 @@ import {
} from '@ucap-webmessenger/protocol-room';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import {
GroupProtocolService,
AddResponse as GroupAddResponse,
UpdateResponse as GroupUpdateResponse,
DelResponse as GroupDelResponse
@ -299,6 +300,12 @@ export class Effects {
state.account.authentication.loginRes as LoginResponse
)
),
this.store.pipe(
select(
(state: any) =>
state.messenger.sync.room.entities as Dictionary<RoomInfo>
)
),
this.store.pipe(
select(
(state: any) =>
@ -316,7 +323,7 @@ export class Effects {
)
)
),
tap(([action, loginRes, roomUsers, roomUserShorts]) => {
tap(([action, loginRes, roomInfos, roomUsers, roomUserShorts]) => {
const userSeqList = [...action.userSeqList, loginRes.userSeq];
let roomSeq = null;
@ -325,6 +332,20 @@ export class Effects {
const element = roomUsers[key];
if (userSeqList.length === element.userInfos.length) {
roomSeq = key;
if (!!action.isTimeRoom && action.isTimeRoom) {
// 타이머 방
if (!roomInfos[key].isTimeRoom) {
roomSeq = null;
continue;
}
} else {
// 일반 방
if (roomInfos[key].isTimeRoom) {
roomSeq = null;
continue;
}
}
// user check
for (const roomUserInfo of element.userInfos) {
if (-1 === userSeqList.indexOf(roomUserInfo.seq)) {
roomSeq = null;
@ -340,6 +361,20 @@ export class Effects {
const element = roomUserShorts[key];
if (userSeqList.length === element.userInfos.length) {
roomSeq = key;
if (!!action.isTimeRoom && action.isTimeRoom) {
// 타이머 방
if (!roomInfos[key].isTimeRoom) {
roomSeq = null;
continue;
}
} else {
// 일반 방
if (roomInfos[key].isTimeRoom) {
roomSeq = null;
continue;
}
}
// user check
for (const roomUserDetailData of element.userInfos) {
if (-1 === userSeqList.indexOf(roomUserDetailData.seq)) {
roomSeq = null;
@ -362,11 +397,27 @@ export class Effects {
return;
}
this.store.dispatch(
RoomStore.open({
req: { divCd: 'DivCode', userSeqs: userSeqList }
})
);
if (!!action.isTimeRoom && action.isTimeRoom) {
// 타이머 방
this.store.dispatch(
RoomStore.openTimer({
req: {
divCd: 'DivCodeT',
roomName: '',
isTimerRoom: true,
timerRoomInterval: 24 * 60 * 60, // 24h default
userSeqs: userSeqList
}
})
);
} else {
// 일반 방
this.store.dispatch(
RoomStore.open({
req: { divCd: 'DivCode', userSeqs: userSeqList }
})
);
}
})
),
{ dispatch: false }

View File

@ -181,7 +181,16 @@ export const reducer = createReducer(
on(RoomStore.exitSuccess, (state, action) => {
return {
...state,
room: adapterRoom.removeOne(action.res.roomSeq, { ...state.room })
room: adapterRoom.removeOne(action.res.roomSeq, { ...state.room }),
roomUser: adapterRoomUser.removeOne(action.res.roomSeq, {
...state.roomUser
}),
roomUserShort: adapterRoomUserShort.removeOne(action.res.roomSeq, {
...state.roomUserShort
}),
chatUnreadCount:
state.chatUnreadCount -
state.room.entities[action.res.roomSeq].noReadCnt
};
}),

View File

@ -123,17 +123,23 @@ export const encodeOpen3: ProtocolEncoder<Open3Request> = (
req: Open3Request
) => {
const bodyList: PacketBody[] = [];
let roomName: string = req.roomName.trim();
if (roomName.length === 0) {
roomName = ' ';
}
bodyList.push({ type: PacketBodyValue.String, value: req.divCd });
bodyList.push({ type: PacketBodyValue.String, value: req.roomName.trim() });
bodyList.push({
type: PacketBodyValue.String,
value: req.isTimerRoom === true ? 'Y' : 'N'
});
bodyList.push({
type: PacketBodyValue.Integer,
value: req.isTimerRoom !== true ? 0 : req.timerRoomInterval
});
bodyList.push(
{ type: PacketBodyValue.String, value: req.divCd },
{ type: PacketBodyValue.String, value: roomName },
{
type: PacketBodyValue.String,
value: req.isTimerRoom === true ? 'Y' : 'N'
},
{
type: PacketBodyValue.Integer,
value: req.isTimerRoom !== true ? 0 : req.timerRoomInterval
}
);
for (const userSeq of req.userSeqs) {
bodyList.push({ type: PacketBodyValue.Integer, value: userSeq });
}

View File

@ -44,7 +44,9 @@
</mat-checkbox>
</dd>
</dl>
<!-- <span class="noti">1</span> -->
<span *ngIf="roomInfo.isTimeRoom">
<mat-icon>timer</mat-icon>
</span>
<span
class="notiBadge"
*ngIf="roomInfo.noReadCnt > 0"