2019-10-10 06:53:08 +00:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
OnDestroy,
|
|
|
|
ViewChild,
|
2019-11-01 06:06:37 +00:00
|
|
|
ElementRef,
|
2019-11-08 04:35:39 +00:00
|
|
|
AfterViewInit,
|
|
|
|
Output,
|
2019-11-15 01:13:18 +00:00
|
|
|
EventEmitter
|
2019-10-10 06:53:08 +00:00
|
|
|
} from '@angular/core';
|
2019-10-16 09:05:18 +00:00
|
|
|
import {
|
|
|
|
ucapAnimations,
|
|
|
|
SnackBarService,
|
|
|
|
ClipboardService,
|
2019-10-24 01:45:28 +00:00
|
|
|
DialogService,
|
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
2019-10-30 02:12:45 +00:00
|
|
|
ConfirmDialogResult,
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
2019-11-05 04:46:17 +00:00
|
|
|
AlertDialogResult,
|
2019-11-09 04:35:24 +00:00
|
|
|
FileUploadQueueComponent,
|
2019-11-15 01:13:18 +00:00
|
|
|
StringUtil
|
2019-10-16 09:05:18 +00:00
|
|
|
} from '@ucap-webmessenger/ui';
|
2019-10-08 04:31:33 +00:00
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
import { NGXLogger } from 'ngx-logger';
|
2019-11-05 04:46:17 +00:00
|
|
|
import { Observable, Subscription, forkJoin, of } from 'rxjs';
|
2019-10-16 07:33:19 +00:00
|
|
|
import {
|
|
|
|
Info,
|
|
|
|
EventType,
|
|
|
|
isRecalled,
|
|
|
|
isCopyable,
|
2019-10-29 09:11:31 +00:00
|
|
|
isRecallable,
|
2019-12-04 05:36:15 +00:00
|
|
|
isForwardable,
|
2019-11-06 04:48:06 +00:00
|
|
|
InfoResponse,
|
2019-11-06 07:24:51 +00:00
|
|
|
EventJson,
|
2019-11-25 05:12:49 +00:00
|
|
|
FileEventJson,
|
|
|
|
StickerEventJson
|
2019-10-16 07:33:19 +00:00
|
|
|
} from '@ucap-webmessenger/protocol-event';
|
2019-10-08 04:31:33 +00:00
|
|
|
|
|
|
|
import * as AppStore from '@app/store';
|
2019-10-08 05:34:37 +00:00
|
|
|
import * as EventStore from '@app/store/messenger/event';
|
2019-10-11 09:03:01 +00:00
|
|
|
import * as ChatStore from '@app/store/messenger/chat';
|
2019-10-11 06:55:27 +00:00
|
|
|
import * as RoomStore from '@app/store/messenger/room';
|
2019-11-11 01:53:24 +00:00
|
|
|
import * as SyncStore from '@app/store/messenger/sync';
|
2019-10-08 04:31:33 +00:00
|
|
|
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
|
2019-11-25 06:48:43 +00:00
|
|
|
import {
|
|
|
|
SessionStorageService,
|
|
|
|
LocalStorageService
|
|
|
|
} from '@ucap-webmessenger/web-storage';
|
2019-10-24 08:04:58 +00:00
|
|
|
import {
|
|
|
|
EnvironmentsInfo,
|
|
|
|
KEY_ENVIRONMENTS_INFO,
|
2019-11-11 05:31:26 +00:00
|
|
|
UserSelectDialogType,
|
2019-11-25 06:48:43 +00:00
|
|
|
RightDrawer,
|
|
|
|
KEY_STICKER_HISTORY
|
2019-10-24 08:04:58 +00:00
|
|
|
} from '@app/types';
|
2019-10-22 00:30:23 +00:00
|
|
|
import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room';
|
2019-11-05 04:46:17 +00:00
|
|
|
import { tap, take, map, catchError } from 'rxjs/operators';
|
2019-11-01 06:06:37 +00:00
|
|
|
import {
|
|
|
|
FileInfo,
|
2019-11-15 01:13:18 +00:00
|
|
|
FormComponent as UCapUiChatFormComponent
|
2019-11-01 06:06:37 +00:00
|
|
|
} from '@ucap-webmessenger/ui-chat';
|
2019-12-13 05:38:42 +00:00
|
|
|
import { KEY_VER_INFO } from '@app/types';
|
2019-10-15 05:58:11 +00:00
|
|
|
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
|
2019-11-07 04:14:44 +00:00
|
|
|
import {
|
|
|
|
MatMenuTrigger,
|
|
|
|
MatSnackBarRef,
|
2019-11-15 01:13:18 +00:00
|
|
|
SimpleSnackBar
|
2019-11-07 04:14:44 +00:00
|
|
|
} from '@angular/material';
|
2019-12-03 09:59:11 +00:00
|
|
|
import { FileUploadItem } from '@ucap-webmessenger/api';
|
2019-11-05 04:46:17 +00:00
|
|
|
import {
|
|
|
|
CommonApiService,
|
|
|
|
FileTalkSaveRequest,
|
2019-11-15 01:13:18 +00:00
|
|
|
FileTalkSaveResponse
|
2019-11-05 04:46:17 +00:00
|
|
|
} from '@ucap-webmessenger/api-common';
|
2019-10-17 00:18:55 +00:00
|
|
|
import {
|
2019-10-24 08:04:58 +00:00
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
2019-11-15 01:13:18 +00:00
|
|
|
CreateChatDialogResult
|
2019-10-24 08:04:58 +00:00
|
|
|
} from '../dialogs/chat/create-chat.dialog.component';
|
2019-10-29 00:07:06 +00:00
|
|
|
import {
|
2019-11-06 04:48:06 +00:00
|
|
|
FileViewerDialogComponent,
|
|
|
|
FileViewerDialogData,
|
2019-11-15 01:13:18 +00:00
|
|
|
FileViewerDialogResult
|
2019-11-06 04:48:06 +00:00
|
|
|
} from '@app/layouts/common/dialogs/file-viewer.dialog.component';
|
2019-12-09 07:52:43 +00:00
|
|
|
import { CONST, FileUtil, StickerFilesInfo } from '@ucap-webmessenger/core';
|
2019-10-29 02:39:34 +00:00
|
|
|
import { PerfectScrollbarComponent } from 'ngx-perfect-scrollbar';
|
2019-11-05 04:46:17 +00:00
|
|
|
import { StatusCode } from '@ucap-webmessenger/api';
|
2019-11-06 04:58:56 +00:00
|
|
|
import {
|
|
|
|
EditChatRoomDialogComponent,
|
|
|
|
EditChatRoomDialogResult,
|
2019-11-15 01:13:18 +00:00
|
|
|
EditChatRoomDialogData
|
2019-11-06 04:58:56 +00:00
|
|
|
} from '../dialogs/chat/edit-chat-room.dialog.component';
|
2019-11-11 05:31:26 +00:00
|
|
|
import {
|
|
|
|
SelectGroupDialogComponent,
|
|
|
|
SelectGroupDialogResult,
|
2019-11-15 01:13:18 +00:00
|
|
|
SelectGroupDialogData
|
2019-11-11 05:31:26 +00:00
|
|
|
} from '../dialogs/group/select-group.dialog.component';
|
2019-11-11 01:53:24 +00:00
|
|
|
import { GroupDetailData } from '@ucap-webmessenger/protocol-sync';
|
2019-09-23 05:23:24 +00:00
|
|
|
|
|
|
|
@Component({
|
2019-09-26 02:11:22 +00:00
|
|
|
selector: 'app-layout-messenger-messages',
|
2019-09-23 05:23:24 +00:00
|
|
|
templateUrl: './messages.component.html',
|
|
|
|
styleUrls: ['./messages.component.scss'],
|
2019-11-15 01:13:18 +00:00
|
|
|
animations: ucapAnimations
|
2019-09-23 05:23:24 +00:00
|
|
|
})
|
2019-11-01 06:06:37 +00:00
|
|
|
export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
|
2019-11-08 04:35:39 +00:00
|
|
|
@Output()
|
|
|
|
openProfile = new EventEmitter<UserInfo>();
|
|
|
|
|
2019-10-10 06:53:08 +00:00
|
|
|
@ViewChild('messageBoxContainer', { static: true })
|
|
|
|
private messageBoxContainer: ElementRef;
|
|
|
|
|
2019-11-06 08:32:27 +00:00
|
|
|
@ViewChild('chatForm', { static: false })
|
2019-11-01 06:06:37 +00:00
|
|
|
private chatForm: UCapUiChatFormComponent;
|
|
|
|
|
2019-10-16 07:33:19 +00:00
|
|
|
@ViewChild('messageContextMenuTrigger', { static: true })
|
|
|
|
messageContextMenuTrigger: MatMenuTrigger;
|
|
|
|
messageContextMenuPosition = { x: '0px', y: '0px' };
|
|
|
|
|
2019-10-29 02:39:34 +00:00
|
|
|
@ViewChild('psChatContent', { static: true })
|
|
|
|
psChatContent: PerfectScrollbarComponent;
|
|
|
|
|
2019-11-05 04:46:17 +00:00
|
|
|
@ViewChild('fileUploadQueue', { static: true })
|
|
|
|
fileUploadQueue: FileUploadQueueComponent;
|
|
|
|
|
2019-10-16 09:05:18 +00:00
|
|
|
environmentsInfo: EnvironmentsInfo;
|
|
|
|
|
2019-10-08 05:59:22 +00:00
|
|
|
loginRes: LoginResponse;
|
|
|
|
loginResSubscription: Subscription;
|
2019-11-07 04:14:44 +00:00
|
|
|
eventList: Info<EventJson>[];
|
|
|
|
eventListNew: Info<EventJson>[];
|
|
|
|
eventListSubscription: Subscription;
|
2019-10-31 09:12:38 +00:00
|
|
|
baseEventSeq = 0;
|
2019-10-08 05:34:37 +00:00
|
|
|
roomInfo: RoomInfo;
|
|
|
|
roomInfoSubscription: Subscription;
|
2019-10-22 00:30:23 +00:00
|
|
|
userInfoList: UserInfo[];
|
|
|
|
userInfoListSubscription: Subscription;
|
2019-10-08 06:25:00 +00:00
|
|
|
eventListProcessing$: Observable<boolean>;
|
2019-12-04 05:36:15 +00:00
|
|
|
eventInfoStatus: InfoResponse;
|
|
|
|
eventInfoStatusSubscription: Subscription;
|
2019-10-16 09:05:18 +00:00
|
|
|
sessionVerInfo: VersionInfo2Response;
|
2019-10-08 04:31:33 +00:00
|
|
|
|
2019-11-06 10:11:08 +00:00
|
|
|
eventRemain$: Observable<boolean>;
|
|
|
|
eventRemain = false; // 이전대화가 남아 있는지 여부
|
|
|
|
eventMorePosition = 0; // 이전대화를 불러올 경우 현재 스크롤 포지션 유지를 위한 값. 0 이면 초기로딩.
|
|
|
|
scrollUpinit = false; // ps 에서 초기 로딩시 scroll reach start 이벤트 발생 버그를 우회하기 위한 init 값으로 scrollUp 에 의해 true 로 된다.
|
|
|
|
|
2019-10-16 07:33:19 +00:00
|
|
|
isRecalledMessage = isRecalled;
|
|
|
|
isCopyableMessage = isCopyable;
|
|
|
|
isRecallableMessage = isRecallable;
|
2019-12-04 05:36:15 +00:00
|
|
|
isForwardableMessage = isForwardable;
|
2019-10-16 07:33:19 +00:00
|
|
|
|
2019-11-01 04:43:49 +00:00
|
|
|
/** Timer 대화방의 대화 삭제를 위한 interval */
|
|
|
|
interval: any;
|
|
|
|
|
2019-11-25 05:12:49 +00:00
|
|
|
/** About Sticker */
|
2019-11-20 09:04:24 +00:00
|
|
|
isShowStickerSelector = false;
|
2019-11-25 05:12:49 +00:00
|
|
|
selectedSticker: StickerFilesInfo;
|
2019-11-20 09:04:24 +00:00
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
snackBarPreviewEvent: MatSnackBarRef<SimpleSnackBar>;
|
|
|
|
|
2019-10-08 04:31:33 +00:00
|
|
|
constructor(
|
|
|
|
private store: Store<any>,
|
|
|
|
private sessionStorageService: SessionStorageService,
|
2019-11-25 06:48:43 +00:00
|
|
|
private localStorageService: LocalStorageService,
|
2019-10-16 09:05:18 +00:00
|
|
|
private commonApiService: CommonApiService,
|
|
|
|
private clipboardService: ClipboardService,
|
|
|
|
private dialogService: DialogService,
|
|
|
|
private snackBarService: SnackBarService,
|
2019-10-08 04:31:33 +00:00
|
|
|
private logger: NGXLogger
|
2019-10-16 09:05:18 +00:00
|
|
|
) {
|
|
|
|
this.sessionVerInfo = this.sessionStorageService.get<VersionInfo2Response>(
|
|
|
|
KEY_VER_INFO
|
|
|
|
);
|
|
|
|
|
|
|
|
this.environmentsInfo = this.sessionStorageService.get<EnvironmentsInfo>(
|
|
|
|
KEY_ENVIRONMENTS_INFO
|
|
|
|
);
|
|
|
|
}
|
2019-10-08 04:31:33 +00:00
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
setEventMoreInit() {
|
|
|
|
// 방정보가 바뀌면 이전대화 보기 관련 값들을 초기화 한다.
|
|
|
|
this.scrollUpinit = false;
|
|
|
|
this.eventMorePosition = 0;
|
|
|
|
}
|
|
|
|
|
2019-10-08 04:31:33 +00:00
|
|
|
ngOnInit() {
|
2019-10-08 05:59:22 +00:00
|
|
|
this.loginResSubscription = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.AccountSelector.AuthenticationSelector.loginRes),
|
|
|
|
tap(loginRes => {
|
|
|
|
this.loginRes = loginRes;
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
2019-09-23 05:23:24 +00:00
|
|
|
|
2019-10-08 05:34:37 +00:00
|
|
|
this.roomInfoSubscription = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.MessengerSelector.RoomSelector.roomInfo),
|
|
|
|
tap(roomInfo => {
|
|
|
|
this.roomInfo = roomInfo;
|
2019-11-25 06:48:43 +00:00
|
|
|
this.clearView();
|
2019-11-07 04:14:44 +00:00
|
|
|
this.setEventMoreInit();
|
2019-10-08 05:34:37 +00:00
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
|
|
|
|
2019-10-22 00:30:23 +00:00
|
|
|
this.userInfoListSubscription = this.store
|
|
|
|
.pipe(
|
2019-10-30 07:22:49 +00:00
|
|
|
select(AppStore.MessengerSelector.RoomSelector.selectUserinfolist),
|
2019-10-22 00:30:23 +00:00
|
|
|
tap(userInfoList => {
|
|
|
|
this.userInfoList = userInfoList;
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
2019-10-11 02:40:35 +00:00
|
|
|
|
2019-10-08 06:25:00 +00:00
|
|
|
this.eventListProcessing$ = this.store.pipe(
|
|
|
|
select(AppStore.MessengerSelector.EventSelector.infoListProcessing)
|
|
|
|
);
|
|
|
|
|
2019-10-31 09:12:38 +00:00
|
|
|
this.eventRemain$ = this.store.pipe(
|
|
|
|
select(AppStore.MessengerSelector.EventSelector.remainInfo),
|
|
|
|
tap(remainInfo => {
|
|
|
|
this.eventRemain = remainInfo;
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
this.eventListSubscription = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.MessengerSelector.EventSelector.selectAllInfoList),
|
|
|
|
tap(infoList => {
|
|
|
|
if (!!this.eventList && this.eventList.length > 0) {
|
|
|
|
this.eventListNew = infoList.filter(info => {
|
|
|
|
if (info.seq <= this.eventList[this.eventList.length - 1].seq) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
this.eventList = infoList;
|
|
|
|
|
|
|
|
if (!!infoList && infoList.length > 0) {
|
|
|
|
this.baseEventSeq = infoList[0].seq;
|
|
|
|
this.readyToReply();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
2019-10-10 06:53:08 +00:00
|
|
|
|
2019-12-04 05:36:15 +00:00
|
|
|
this.eventInfoStatusSubscription = this.store
|
|
|
|
.pipe(
|
|
|
|
select(AppStore.MessengerSelector.EventSelector.infoStatus),
|
|
|
|
tap(res => (this.eventInfoStatus = res))
|
|
|
|
)
|
|
|
|
.subscribe();
|
2019-10-29 09:11:31 +00:00
|
|
|
|
2019-11-01 04:43:49 +00:00
|
|
|
this.interval = setInterval(() => {
|
2019-11-05 04:46:17 +00:00
|
|
|
if (!!this.roomInfo && !!this.roomInfo.isTimeRoom) {
|
2019-11-01 04:43:49 +00:00
|
|
|
this.store.dispatch(EventStore.infoIntervalClear({}));
|
|
|
|
}
|
|
|
|
}, 1000);
|
2019-10-08 04:31:33 +00:00
|
|
|
}
|
2019-09-23 05:23:24 +00:00
|
|
|
|
2019-10-08 05:34:37 +00:00
|
|
|
ngOnDestroy(): void {
|
2019-10-08 05:59:22 +00:00
|
|
|
if (!!this.loginResSubscription) {
|
|
|
|
this.loginResSubscription.unsubscribe();
|
|
|
|
}
|
2019-10-08 05:34:37 +00:00
|
|
|
if (!!this.roomInfoSubscription) {
|
|
|
|
this.roomInfoSubscription.unsubscribe();
|
|
|
|
}
|
2019-10-22 00:30:23 +00:00
|
|
|
if (!!this.userInfoListSubscription) {
|
|
|
|
this.userInfoListSubscription.unsubscribe();
|
|
|
|
}
|
2019-11-07 04:14:44 +00:00
|
|
|
if (!!this.eventListSubscription) {
|
|
|
|
this.eventListSubscription.unsubscribe();
|
|
|
|
}
|
2019-12-04 05:36:15 +00:00
|
|
|
if (!!this.eventInfoStatusSubscription) {
|
|
|
|
this.eventInfoStatusSubscription.unsubscribe();
|
|
|
|
}
|
2019-11-01 04:43:49 +00:00
|
|
|
|
|
|
|
clearInterval(this.interval);
|
2019-10-08 05:34:37 +00:00
|
|
|
}
|
|
|
|
|
2019-11-01 06:06:37 +00:00
|
|
|
ngAfterViewInit(): void {
|
2019-11-06 10:11:08 +00:00
|
|
|
// this.readyToReply();
|
2019-10-10 06:53:08 +00:00
|
|
|
}
|
|
|
|
|
2019-11-25 05:12:49 +00:00
|
|
|
/**
|
|
|
|
* 채팅방의 여러 팝업들을 닫아준다.
|
|
|
|
*/
|
|
|
|
clearView() {
|
|
|
|
// Sticker Selector Clear..
|
|
|
|
this.isShowStickerSelector = false;
|
|
|
|
this.selectedSticker = undefined;
|
|
|
|
}
|
|
|
|
|
2019-10-22 00:30:23 +00:00
|
|
|
getRoomName() {
|
|
|
|
if (!this.roomInfo || !this.userInfoList) {
|
|
|
|
return '대화방명을 가져오고 있습니다..';
|
|
|
|
}
|
|
|
|
|
2019-11-06 08:32:27 +00:00
|
|
|
switch (this.roomInfo.roomType) {
|
|
|
|
case RoomType.Mytalk:
|
|
|
|
return 'MyTalk';
|
|
|
|
case RoomType.Bot:
|
|
|
|
case RoomType.Allim:
|
|
|
|
return this.userInfoList
|
2019-12-09 07:52:43 +00:00
|
|
|
.filter(user => user.seq !== this.loginRes.userSeq && user.isJoinRoom)
|
2019-11-06 08:32:27 +00:00
|
|
|
.map(user => user.name);
|
|
|
|
}
|
|
|
|
|
2019-10-22 00:30:23 +00:00
|
|
|
if (!!this.roomInfo.roomName && '' !== this.roomInfo.roomName.trim()) {
|
|
|
|
return this.roomInfo.roomName;
|
|
|
|
} else {
|
|
|
|
return this.userInfoList
|
|
|
|
.filter(user => {
|
|
|
|
if (this.roomInfo.roomType === RoomType.Single) {
|
|
|
|
return user.seq !== this.loginRes.userSeq;
|
|
|
|
} else {
|
2019-12-09 07:52:43 +00:00
|
|
|
return user.isJoinRoom;
|
2019-10-22 00:30:23 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0))
|
|
|
|
.map(user => user.name)
|
|
|
|
.join(',');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
/** 대화전송 가능한 방인지 판단 */
|
2019-11-06 08:32:27 +00:00
|
|
|
getEnableSend() {
|
|
|
|
if (!this.roomInfo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
|
|
|
this.roomInfo.roomType === RoomType.Bot ||
|
|
|
|
this.roomInfo.roomType === RoomType.Allim ||
|
|
|
|
this.roomInfo.roomType === RoomType.Link
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-10-31 06:05:59 +00:00
|
|
|
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 '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-21 05:02:11 +00:00
|
|
|
getShowContextMenu(menuType: string) {
|
|
|
|
if (
|
|
|
|
menuType === 'OPEN_ROOM_USER' ||
|
|
|
|
menuType === 'ADD_MEMBER' ||
|
|
|
|
menuType === 'ADD_GROUP' ||
|
|
|
|
menuType === 'EDIT_ROOM'
|
|
|
|
) {
|
|
|
|
if (
|
2019-11-21 06:01:41 +00:00
|
|
|
!this.roomInfo ||
|
|
|
|
!this.roomInfo.roomType ||
|
2019-11-21 05:02:11 +00:00
|
|
|
this.roomInfo.roomType === RoomType.Mytalk ||
|
|
|
|
this.roomInfo.roomType === RoomType.Allim ||
|
|
|
|
this.roomInfo.roomType === RoomType.Bot ||
|
|
|
|
this.roomInfo.roomType === RoomType.Link
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-22 00:17:47 +00:00
|
|
|
getShowUnreadCount(): boolean {
|
|
|
|
if (!this.roomInfo || this.roomInfo === undefined) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
this.roomInfo.roomType === RoomType.Mytalk ||
|
|
|
|
this.roomInfo.roomType === RoomType.Bot ||
|
|
|
|
this.roomInfo.roomType === RoomType.Allim
|
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-01 06:06:37 +00:00
|
|
|
readyToReply(): void {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.focusReplyInput();
|
|
|
|
this.scrollToBottom();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
focusReplyInput(): void {
|
|
|
|
setTimeout(() => {
|
2019-11-06 08:32:27 +00:00
|
|
|
if (!!this.chatForm) {
|
|
|
|
this.chatForm.focus();
|
|
|
|
}
|
2019-11-01 06:06:37 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
/** Scroll Handler */
|
2019-11-01 06:06:37 +00:00
|
|
|
scrollToBottom(speed?: number): void {
|
2019-11-06 10:11:08 +00:00
|
|
|
if (this.eventMorePosition > 0) {
|
|
|
|
if (this.psChatContent.directiveRef) {
|
|
|
|
this.psChatContent.directiveRef.update();
|
|
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
this.psChatContent.directiveRef.scrollToTop(
|
|
|
|
this.psChatContent.directiveRef.elementRef.nativeElement
|
|
|
|
.scrollHeight - this.eventMorePosition,
|
|
|
|
speed
|
|
|
|
);
|
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
this.eventMorePosition = 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (this.scrollUpinit) {
|
|
|
|
if (!!this.eventListNew && this.eventListNew.length > 0) {
|
|
|
|
let message = '';
|
|
|
|
const info = this.eventListNew[this.eventListNew.length - 1];
|
|
|
|
const senderUser = this.userInfoList.filter(
|
|
|
|
user => user.seq === info.senderSeq
|
|
|
|
);
|
|
|
|
if (!!senderUser && senderUser.length > 0) {
|
|
|
|
message += `${senderUser[0].name} : `;
|
|
|
|
}
|
|
|
|
message += StringUtil.convertFinalEventMessage(
|
|
|
|
info.type,
|
|
|
|
info.sentMessageJson || info.sentMessage
|
|
|
|
);
|
|
|
|
|
|
|
|
this.snackBarPreviewEvent = this.snackBarService.open(message, 'GO', {
|
|
|
|
// duration: 3000,
|
|
|
|
verticalPosition: 'bottom',
|
|
|
|
horizontalPosition: 'center',
|
2019-11-15 01:13:18 +00:00
|
|
|
panelClass: ['chat-snackbar-class']
|
2019-11-07 04:14:44 +00:00
|
|
|
});
|
|
|
|
this.snackBarPreviewEvent.onAction().subscribe(() => {
|
|
|
|
this.setEventMoreInit();
|
|
|
|
this.scrollToBottom();
|
|
|
|
this.snackBarPreviewEvent.dismiss();
|
2019-11-06 10:11:08 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
speed = speed || 0;
|
|
|
|
if (this.psChatContent.directiveRef) {
|
|
|
|
this.psChatContent.directiveRef.update();
|
2019-11-01 06:06:37 +00:00
|
|
|
|
2019-11-06 10:11:08 +00:00
|
|
|
setTimeout(() => {
|
|
|
|
this.psChatContent.directiveRef.scrollToBottom(0, speed);
|
|
|
|
});
|
|
|
|
}
|
2019-11-01 06:06:37 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-07 04:14:44 +00:00
|
|
|
onScrollup(event: any) {
|
|
|
|
this.scrollUpinit = true;
|
|
|
|
}
|
|
|
|
onScrollReachStart(event: any) {
|
|
|
|
this.onMoreEvent(this.baseEventSeq);
|
|
|
|
}
|
|
|
|
onScrollReachEnd(event: any) {
|
|
|
|
this.setEventMoreInit();
|
|
|
|
if (!!this.snackBarPreviewEvent) {
|
|
|
|
this.snackBarPreviewEvent.dismiss();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** More Event */
|
|
|
|
onMoreEvent(seq: number) {
|
|
|
|
if (this.scrollUpinit && this.eventRemain) {
|
|
|
|
this.eventMorePosition = this.psChatContent.directiveRef.elementRef.nativeElement.scrollHeight;
|
|
|
|
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.info({
|
|
|
|
roomSeq: this.roomInfo.roomSeq,
|
|
|
|
baseSeq: seq,
|
2019-11-15 01:13:18 +00:00
|
|
|
requestCount: CONST.EVENT_INFO_READ_COUNT
|
2019-11-07 04:14:44 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-11-01 06:06:37 +00:00
|
|
|
|
2019-10-30 02:12:45 +00:00
|
|
|
async onSendMessage(message: string) {
|
2019-11-07 04:14:44 +00:00
|
|
|
this.setEventMoreInit();
|
|
|
|
|
2019-11-25 05:12:49 +00:00
|
|
|
if (!this.selectedSticker) {
|
|
|
|
if (!message || message.trim().length === 0) {
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
data: {
|
|
|
|
title: 'Alert',
|
|
|
|
message: `대화내용을 입력해주세요.`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
2019-10-30 02:12:45 +00:00
|
|
|
}
|
|
|
|
|
2019-11-25 05:12:49 +00:00
|
|
|
if (!!this.selectedSticker) {
|
|
|
|
// Send Sticker
|
2019-11-27 06:40:09 +00:00
|
|
|
if (!!message && message.trim().length > CONST.MASSTEXT_LEN) {
|
2019-11-25 05:12:49 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
data: {
|
|
|
|
title: 'Alert',
|
|
|
|
message: `스티커를 포함할 경우 ${CONST.MASSTEXT_LEN}자 이상 보낼 수 없습니다.`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const stickerJson: StickerEventJson = {
|
|
|
|
name: '스티커',
|
|
|
|
file: this.selectedSticker.index,
|
2019-11-27 06:40:09 +00:00
|
|
|
chat: !!message ? message.trim() : ''
|
2019-11-25 05:12:49 +00:00
|
|
|
};
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.send({
|
|
|
|
senderSeq: this.loginRes.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: this.roomInfo.roomSeq,
|
|
|
|
eventType: EventType.Sticker,
|
|
|
|
sentMessage: JSON.stringify(stickerJson)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
this.isShowStickerSelector = false;
|
2019-11-25 06:48:43 +00:00
|
|
|
this.setStickerHistory(this.selectedSticker);
|
2019-11-25 05:12:49 +00:00
|
|
|
} else if (message.trim().length > CONST.MASSTEXT_LEN) {
|
2019-10-28 09:03:27 +00:00
|
|
|
// MASS TEXT
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.sendMass({
|
|
|
|
senderSeq: this.loginRes.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: this.roomInfo.roomSeq,
|
|
|
|
eventType: EventType.MassText,
|
|
|
|
// sentMessage: message.replace(/\n/gi, '\r\n')
|
2019-11-15 01:13:18 +00:00
|
|
|
sentMessage: message
|
|
|
|
}
|
2019-10-28 09:03:27 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.send({
|
|
|
|
senderSeq: this.loginRes.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: this.roomInfo.roomSeq,
|
|
|
|
eventType: EventType.Character,
|
2019-11-15 01:13:18 +00:00
|
|
|
sentMessage: message
|
|
|
|
}
|
2019-10-28 09:03:27 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-08 05:34:37 +00:00
|
|
|
}
|
2019-10-10 06:53:08 +00:00
|
|
|
|
2019-10-11 06:55:27 +00:00
|
|
|
onClickReceiveAlarm() {
|
|
|
|
this.store.dispatch(RoomStore.updateOnlyAlarm({ roomInfo: this.roomInfo }));
|
|
|
|
}
|
|
|
|
|
2019-10-11 09:03:01 +00:00
|
|
|
/** MassText Detail View */
|
|
|
|
onMassDetail(value: number) {
|
|
|
|
this.store.dispatch(
|
|
|
|
ChatStore.selectedMassDetail({
|
2019-11-15 01:13:18 +00:00
|
|
|
massEventSeq: value
|
2019-10-11 09:03:01 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-14 04:53:22 +00:00
|
|
|
|
2019-11-07 06:46:02 +00:00
|
|
|
async onFileViewer(fileInfo: FileEventJson) {
|
2019-10-29 00:07:06 +00:00
|
|
|
const result = await this.dialogService.open<
|
2019-11-06 04:48:06 +00:00
|
|
|
FileViewerDialogComponent,
|
|
|
|
FileViewerDialogData,
|
|
|
|
FileViewerDialogResult
|
|
|
|
>(FileViewerDialogComponent, {
|
2019-10-29 00:07:06 +00:00
|
|
|
position: {
|
2019-11-22 08:35:00 +00:00
|
|
|
top: '50px'
|
2019-10-29 00:07:06 +00:00
|
|
|
},
|
2019-10-29 09:19:41 +00:00
|
|
|
maxWidth: '100vw',
|
|
|
|
maxHeight: '100vh',
|
2019-11-22 08:35:00 +00:00
|
|
|
height: 'calc(100% - 50px)',
|
2019-10-29 00:07:06 +00:00
|
|
|
width: '100%',
|
2019-10-29 09:19:41 +00:00
|
|
|
hasBackdrop: false,
|
2019-11-06 04:48:06 +00:00
|
|
|
panelClass: 'app-dialog-full',
|
2019-11-06 07:24:51 +00:00
|
|
|
data: {
|
|
|
|
fileInfo,
|
|
|
|
downloadUrl: this.sessionVerInfo.downloadUrl,
|
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
|
|
|
token: this.loginRes.tokenString,
|
2019-11-15 01:13:18 +00:00
|
|
|
userSeq: this.loginRes.userSeq
|
|
|
|
}
|
2019-10-29 00:07:06 +00:00
|
|
|
});
|
2019-10-14 04:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** File Save, Save As */
|
|
|
|
onSave(value: { fileInfo: FileInfo; type: string }) {
|
|
|
|
this.logger.debug('fileSave', value);
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
|
2019-10-31 08:09:38 +00:00
|
|
|
onFileDragEnter(items: DataTransferItemList) {
|
2019-11-25 05:12:49 +00:00
|
|
|
this.clearView();
|
2019-10-31 08:09:38 +00:00
|
|
|
this.logger.debug('onFileDragEnter', items);
|
2019-10-21 04:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onFileDragOver() {
|
|
|
|
this.logger.debug('onFileDragOver');
|
|
|
|
}
|
|
|
|
|
|
|
|
onFileDragLeave() {
|
|
|
|
this.logger.debug('onFileDragLeave');
|
|
|
|
}
|
|
|
|
|
2019-11-07 09:08:00 +00:00
|
|
|
async onFileSelected(fileUploadItems: FileUploadItem[]) {
|
2019-11-05 04:46:17 +00:00
|
|
|
this.logger.debug('onFileSelected', fileUploadItems);
|
2019-11-25 05:12:49 +00:00
|
|
|
this.clearView();
|
2019-11-05 04:46:17 +00:00
|
|
|
|
2019-11-05 05:55:17 +00:00
|
|
|
const info = {
|
|
|
|
senderSeq: this.loginRes.userSeq,
|
2019-11-15 01:13:18 +00:00
|
|
|
roomSeq: this.roomInfo.roomSeq
|
2019-11-05 05:55:17 +00:00
|
|
|
};
|
|
|
|
|
2019-11-05 04:46:17 +00:00
|
|
|
const allObservables: Observable<FileTalkSaveResponse>[] = [];
|
|
|
|
|
|
|
|
for (const fileUploadItem of fileUploadItems) {
|
2019-11-07 09:08:00 +00:00
|
|
|
let thumbnail: File;
|
|
|
|
if (
|
|
|
|
-1 !==
|
|
|
|
[
|
|
|
|
'3gp',
|
|
|
|
'avi',
|
|
|
|
'm4v',
|
|
|
|
'mkv',
|
|
|
|
'mov',
|
|
|
|
'mp4',
|
|
|
|
'mpeg',
|
|
|
|
'mpg',
|
|
|
|
'rv',
|
|
|
|
'ts',
|
|
|
|
'webm',
|
2019-11-15 01:13:18 +00:00
|
|
|
'wmv'
|
2019-11-07 09:08:00 +00:00
|
|
|
].indexOf(FileUtil.getExtension(fileUploadItem.file.name))
|
|
|
|
) {
|
|
|
|
thumbnail = await FileUtil.thumbnail(fileUploadItem.file);
|
|
|
|
this.logger.debug('thumbnail', thumbnail);
|
|
|
|
}
|
|
|
|
|
2019-11-05 04:46:17 +00:00
|
|
|
const req: FileTalkSaveRequest = {
|
|
|
|
userSeq: this.loginRes.userSeq,
|
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
|
|
|
token: this.loginRes.tokenString,
|
|
|
|
roomSeq: this.roomInfo.roomSeq,
|
|
|
|
file: fileUploadItem.file,
|
|
|
|
fileName: fileUploadItem.file.name,
|
2019-11-07 09:08:00 +00:00
|
|
|
thumb: thumbnail,
|
2019-11-15 01:13:18 +00:00
|
|
|
fileUploadItem
|
2019-11-05 04:46:17 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
allObservables.push(
|
|
|
|
this.commonApiService
|
|
|
|
.fileTalkSave(req, this.sessionVerInfo.uploadUrl)
|
|
|
|
.pipe(
|
|
|
|
map(res => {
|
|
|
|
if (!res) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (StatusCode.Success === res.statusCode) {
|
|
|
|
return res;
|
|
|
|
} else {
|
|
|
|
throw res;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
)
|
|
|
|
);
|
2019-10-21 04:36:58 +00:00
|
|
|
}
|
|
|
|
|
2019-11-05 04:46:17 +00:00
|
|
|
forkJoin(allObservables)
|
|
|
|
.pipe(take(1))
|
|
|
|
.subscribe(
|
|
|
|
resList => {
|
|
|
|
for (const res of resList) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.send({
|
2019-11-05 05:55:17 +00:00
|
|
|
senderSeq: info.senderSeq,
|
2019-11-05 04:46:17 +00:00
|
|
|
req: {
|
2019-11-05 05:55:17 +00:00
|
|
|
roomSeq: info.roomSeq,
|
2019-11-05 04:46:17 +00:00
|
|
|
eventType: EventType.File,
|
2019-11-15 01:13:18 +00:00
|
|
|
sentMessage: res.returnJson
|
|
|
|
}
|
2019-11-05 04:46:17 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
},
|
2019-11-05 05:55:17 +00:00
|
|
|
error => {
|
|
|
|
this.logger.debug('onFileSelected error', error);
|
2019-11-15 08:55:05 +00:00
|
|
|
this.fileUploadQueue.onUploadComplete();
|
|
|
|
|
|
|
|
this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
data: {
|
|
|
|
title: 'Alert',
|
|
|
|
html: `파일전송에 실패하였습니다.<br/>계속 문제 발생 시 관리자에게 문의하세요.`
|
|
|
|
}
|
|
|
|
});
|
2019-11-05 05:55:17 +00:00
|
|
|
},
|
2019-11-05 04:46:17 +00:00
|
|
|
() => {
|
|
|
|
this.fileUploadQueue.onUploadComplete();
|
|
|
|
}
|
|
|
|
);
|
2019-10-21 04:36:58 +00:00
|
|
|
}
|
|
|
|
|
2019-11-06 04:48:06 +00:00
|
|
|
onContextMenuMessage(params: {
|
|
|
|
event: MouseEvent;
|
|
|
|
message: Info<EventJson>;
|
|
|
|
}) {
|
2019-10-16 07:33:19 +00:00
|
|
|
params.event.preventDefault();
|
|
|
|
params.event.stopPropagation();
|
|
|
|
|
|
|
|
this.messageContextMenuPosition.x = params.event.clientX + 'px';
|
|
|
|
this.messageContextMenuPosition.y = params.event.clientY + 'px';
|
|
|
|
this.messageContextMenuTrigger.menu.focusFirstItem('mouse');
|
|
|
|
this.messageContextMenuTrigger.menuData = {
|
|
|
|
message: params.message,
|
2019-11-15 01:13:18 +00:00
|
|
|
loginRes: this.loginRes
|
2019-10-16 07:33:19 +00:00
|
|
|
};
|
|
|
|
this.messageContextMenuTrigger.openMenu();
|
|
|
|
}
|
|
|
|
|
2019-11-06 04:48:06 +00:00
|
|
|
async onClickMessageContextMenu(menuType: string, message: Info<EventJson>) {
|
2019-10-16 07:33:19 +00:00
|
|
|
switch (menuType) {
|
|
|
|
case 'COPY':
|
|
|
|
{
|
2019-10-16 09:05:18 +00:00
|
|
|
switch (message.type) {
|
|
|
|
case EventType.Character:
|
|
|
|
{
|
|
|
|
if (
|
2019-11-06 04:48:06 +00:00
|
|
|
this.clipboardService.copyFromContent(
|
|
|
|
(message as Info<string>).sentMessage
|
|
|
|
)
|
2019-10-16 09:05:18 +00:00
|
|
|
) {
|
|
|
|
this.snackBarService.open('클립보드에 복사되었습니다.', '', {
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'top',
|
2019-11-15 01:13:18 +00:00
|
|
|
horizontalPosition: 'center'
|
2019-10-16 09:05:18 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EventType.MassText:
|
|
|
|
{
|
|
|
|
this.commonApiService
|
|
|
|
.massTalkDownload({
|
|
|
|
userSeq: this.loginRes.userSeq,
|
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
|
|
|
token: this.loginRes.tokenString,
|
2019-11-15 01:13:18 +00:00
|
|
|
eventMassSeq: message.seq
|
2019-10-16 09:05:18 +00:00
|
|
|
})
|
|
|
|
.pipe(take(1))
|
|
|
|
.subscribe(res => {
|
|
|
|
if (this.clipboardService.copyFromContent(res.content)) {
|
|
|
|
this.snackBarService.open(
|
|
|
|
'클립보드에 복사되었습니다.',
|
|
|
|
'',
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'top',
|
2019-11-15 01:13:18 +00:00
|
|
|
horizontalPosition: 'center'
|
2019-10-16 09:05:18 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'REPLAY':
|
|
|
|
{
|
2019-10-16 09:05:18 +00:00
|
|
|
const result = await this.dialogService.open<
|
2019-10-24 08:04:58 +00:00
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
|
|
|
>(CreateChatDialogComponent, {
|
|
|
|
width: '600px',
|
2019-10-16 09:05:18 +00:00
|
|
|
data: {
|
2019-10-24 08:04:58 +00:00
|
|
|
type: UserSelectDialogType.MessageForward,
|
|
|
|
title: 'MessageForward',
|
2019-11-15 01:13:18 +00:00
|
|
|
ignoreRoom: [this.roomInfo]
|
|
|
|
}
|
2019-10-16 09:05:18 +00:00
|
|
|
});
|
2019-10-24 08:04:58 +00:00
|
|
|
|
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
const userSeqs: number[] = [];
|
|
|
|
let roomSeq = '';
|
|
|
|
if (
|
|
|
|
!!result.selectedUserList &&
|
|
|
|
result.selectedUserList.length > 0
|
|
|
|
) {
|
|
|
|
result.selectedUserList.map(user => userSeqs.push(user.seq));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!result.selectedRoom) {
|
|
|
|
roomSeq = result.selectedRoom.roomSeq;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (userSeqs.length > 0 || roomSeq.trim().length > 0) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.forward({
|
|
|
|
senderSeq: this.loginRes.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: '-999',
|
|
|
|
eventType: message.type,
|
2019-11-15 01:13:18 +00:00
|
|
|
sentMessage: message.sentMessage
|
2019-10-24 08:04:58 +00:00
|
|
|
},
|
|
|
|
trgtUserSeqs: userSeqs,
|
2019-11-15 01:13:18 +00:00
|
|
|
trgtRoomSeq: roomSeq
|
2019-10-24 08:04:58 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'REPLAY_TO_ME':
|
|
|
|
{
|
2019-10-25 08:51:33 +00:00
|
|
|
if (this.loginRes.talkWithMeBotSeq > -1) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.forward({
|
|
|
|
senderSeq: this.loginRes.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: '-999',
|
|
|
|
eventType: message.type,
|
2019-11-15 01:13:18 +00:00
|
|
|
sentMessage: message.sentMessage
|
2019-10-25 08:51:33 +00:00
|
|
|
},
|
2019-11-15 01:13:18 +00:00
|
|
|
trgtUserSeqs: [this.loginRes.talkWithMeBotSeq]
|
2019-10-25 08:51:33 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'DELETE':
|
|
|
|
{
|
2019-10-17 00:18:55 +00:00
|
|
|
const result = await this.dialogService.open<
|
2019-10-24 01:45:28 +00:00
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
|
|
|
ConfirmDialogResult
|
|
|
|
>(ConfirmDialogComponent, {
|
2019-11-21 07:13:49 +00:00
|
|
|
width: '400px',
|
2019-10-17 00:18:55 +00:00
|
|
|
data: {
|
2019-10-24 01:45:28 +00:00
|
|
|
title: 'Delete',
|
2019-11-15 01:13:18 +00:00
|
|
|
html: `선택한 메시지를 삭제하시겠습니까?<br/>삭제된 메시지는 내 대화방에서만 적용되며 상대방의 대화방에서는 삭제되지 않습니다.`
|
|
|
|
}
|
2019-10-17 00:18:55 +00:00
|
|
|
});
|
2019-10-24 01:45:28 +00:00
|
|
|
|
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.del({
|
|
|
|
roomSeq: this.roomInfo.roomSeq,
|
2019-11-15 01:13:18 +00:00
|
|
|
eventSeq: message.seq
|
2019-10-24 01:45:28 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'RECALL':
|
|
|
|
{
|
2019-10-17 00:18:55 +00:00
|
|
|
const result = await this.dialogService.open<
|
2019-10-24 01:45:28 +00:00
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
|
|
|
ConfirmDialogResult
|
|
|
|
>(ConfirmDialogComponent, {
|
2019-11-21 07:13:49 +00:00
|
|
|
width: '400px',
|
2019-10-17 00:18:55 +00:00
|
|
|
data: {
|
2019-10-24 01:45:28 +00:00
|
|
|
title: 'ReCall',
|
2019-11-15 01:13:18 +00:00
|
|
|
html: `해당 대화를 회수하시겠습니까?<br/>상대방 대화창에서도 회수됩니다.`
|
|
|
|
}
|
2019-10-17 00:18:55 +00:00
|
|
|
});
|
2019-10-24 01:45:28 +00:00
|
|
|
|
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.cancel({
|
|
|
|
roomSeq: this.roomInfo.roomSeq,
|
|
|
|
eventSeq: message.seq,
|
2019-11-15 01:13:18 +00:00
|
|
|
deviceType: this.environmentsInfo.deviceType
|
2019-10-24 01:45:28 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-10-24 07:53:21 +00:00
|
|
|
|
2019-11-01 06:53:54 +00:00
|
|
|
async onClickContextMenu(menuType: string) {
|
2019-10-24 07:53:21 +00:00
|
|
|
switch (menuType) {
|
2019-11-11 05:31:26 +00:00
|
|
|
case 'OPEN_ALBUM_LIST':
|
|
|
|
{
|
|
|
|
this.store.dispatch(
|
|
|
|
ChatStore.selectedRightDrawer({
|
2019-11-15 01:13:18 +00:00
|
|
|
req: RightDrawer.AlbumBox
|
2019-11-11 05:31:26 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'OPEN_FILE_LIST':
|
|
|
|
{
|
|
|
|
this.store.dispatch(
|
|
|
|
ChatStore.selectedRightDrawer({
|
2019-11-15 01:13:18 +00:00
|
|
|
req: RightDrawer.FileBox
|
2019-11-12 09:10:38 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'OPEN_ROOM_USER':
|
|
|
|
{
|
|
|
|
this.store.dispatch(
|
|
|
|
ChatStore.selectedRightDrawer({
|
2019-11-15 01:13:18 +00:00
|
|
|
req: RightDrawer.RoomUser
|
2019-11-11 05:31:26 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
2019-11-01 06:53:54 +00:00
|
|
|
case 'ADD_MEMBER':
|
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
|
|
|
>(CreateChatDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
data: {
|
|
|
|
type: UserSelectDialogType.EditChatMember,
|
2019-11-04 02:36:58 +00:00
|
|
|
title: 'Edit Chat Member',
|
|
|
|
curRoomUser: this.userInfoList.filter(
|
2019-12-09 07:52:43 +00:00
|
|
|
user => user.seq !== this.loginRes.userSeq && user.isJoinRoom
|
2019-11-15 01:13:18 +00:00
|
|
|
)
|
|
|
|
}
|
2019-11-01 06:53:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!!result && !!result.choice && result.choice) {
|
2019-12-09 07:52:43 +00:00
|
|
|
const userSeqs: number[] = this.userInfoList.map(userInfo => {
|
|
|
|
if (userInfo.isJoinRoom) {
|
|
|
|
return userInfo.seq;
|
|
|
|
}
|
|
|
|
});
|
2019-11-01 06:53:54 +00:00
|
|
|
if (
|
|
|
|
!!result.selectedUserList &&
|
|
|
|
result.selectedUserList.length > 0
|
|
|
|
) {
|
2019-11-21 08:43:20 +00:00
|
|
|
result.selectedUserList.forEach(user => {
|
|
|
|
if (userSeqs.indexOf(user.seq) < 0) {
|
|
|
|
userSeqs.push(user.seq);
|
|
|
|
}
|
2019-11-04 02:36:58 +00:00
|
|
|
});
|
2019-11-01 06:53:54 +00:00
|
|
|
}
|
|
|
|
|
2019-11-04 02:36:58 +00:00
|
|
|
if (userSeqs.length > 0) {
|
|
|
|
// include me
|
|
|
|
userSeqs.push(this.loginRes.userSeq);
|
2019-11-01 06:53:54 +00:00
|
|
|
|
2019-11-04 02:36:58 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
RoomStore.inviteOrOpen({
|
|
|
|
req: {
|
|
|
|
divCd: 'Invite',
|
2019-11-15 01:13:18 +00:00
|
|
|
userSeqs
|
|
|
|
}
|
2019-11-04 02:36:58 +00:00
|
|
|
})
|
|
|
|
);
|
2019-11-01 06:53:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-11-11 01:53:24 +00:00
|
|
|
case 'ADD_GROUP':
|
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
SelectGroupDialogComponent,
|
|
|
|
SelectGroupDialogData,
|
|
|
|
SelectGroupDialogResult
|
|
|
|
>(SelectGroupDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
data: {
|
2019-11-15 01:13:18 +00:00
|
|
|
title: 'Group Select'
|
|
|
|
}
|
2019-11-11 01:53:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
if (!!result.group) {
|
|
|
|
const oldGroup: GroupDetailData = result.group;
|
|
|
|
const trgtUserSeq: number[] = [];
|
|
|
|
result.group.userSeqs.map(seq => trgtUserSeq.push(seq));
|
|
|
|
this.userInfoList
|
|
|
|
.filter(v => result.group.userSeqs.indexOf(v.seq) < 0)
|
|
|
|
.forEach(user => {
|
|
|
|
trgtUserSeq.push(user.seq);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.store.dispatch(
|
|
|
|
SyncStore.updateGroupMember({
|
|
|
|
oldGroup,
|
2019-11-15 01:13:18 +00:00
|
|
|
trgtUserSeq
|
2019-11-11 01:53:24 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-11-06 04:58:56 +00:00
|
|
|
case 'EDIT_ROOM':
|
|
|
|
{
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
EditChatRoomDialogComponent,
|
|
|
|
EditChatRoomDialogData,
|
|
|
|
EditChatRoomDialogResult
|
|
|
|
>(EditChatRoomDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
data: {
|
|
|
|
title: 'Edit Chat Room',
|
2019-11-15 01:13:18 +00:00
|
|
|
roomInfo: this.roomInfo
|
|
|
|
}
|
2019-11-06 04:58:56 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
const roomName: string = result.roomName;
|
|
|
|
const roomNameChangeTarget: string = result.roomNameChangeTarget;
|
|
|
|
const timeRoomInterval: number = result.timeRoomInterval;
|
|
|
|
const roomInfo: RoomInfo = result.roomInfo;
|
|
|
|
|
|
|
|
// 방제목 업데이트.
|
|
|
|
this.store.dispatch(
|
|
|
|
RoomStore.update({
|
|
|
|
req: {
|
|
|
|
roomSeq: roomInfo.roomSeq,
|
|
|
|
roomName,
|
|
|
|
receiveAlarm: roomInfo.receiveAlarm,
|
|
|
|
syncAll:
|
2019-11-15 01:13:18 +00:00
|
|
|
roomNameChangeTarget.toUpperCase() === 'ALL' ? true : false
|
|
|
|
}
|
2019-11-06 04:58:56 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
if (
|
|
|
|
roomInfo.isTimeRoom &&
|
|
|
|
timeRoomInterval > 0 &&
|
|
|
|
roomInfo.timeRoomInterval !== timeRoomInterval
|
|
|
|
) {
|
|
|
|
this.store.dispatch(
|
|
|
|
RoomStore.updateTimeRoomInterval({
|
|
|
|
roomSeq: roomInfo.roomSeq,
|
2019-11-15 01:13:18 +00:00
|
|
|
timerInterval: timeRoomInterval
|
2019-11-06 04:58:56 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2019-10-24 07:53:21 +00:00
|
|
|
case 'CLOSE_ROOM':
|
|
|
|
{
|
|
|
|
this.store.dispatch(ChatStore.clearSelectedRoom());
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-11-08 04:35:39 +00:00
|
|
|
|
|
|
|
onClickOpenProfile(userInfo: UserInfo) {
|
|
|
|
if (
|
|
|
|
this.roomInfo.roomType !== RoomType.Allim &&
|
|
|
|
this.roomInfo.roomType !== RoomType.Bot
|
|
|
|
) {
|
|
|
|
this.openProfile.emit(userInfo);
|
|
|
|
}
|
|
|
|
}
|
2019-11-25 05:12:49 +00:00
|
|
|
|
|
|
|
/** About Sticker */
|
|
|
|
onShowToggleStickerSelector() {
|
|
|
|
this.isShowStickerSelector = !this.isShowStickerSelector;
|
2019-11-28 00:26:08 +00:00
|
|
|
if (!this.isShowStickerSelector) {
|
|
|
|
this.selectedSticker = null;
|
|
|
|
}
|
2019-11-25 05:12:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onSelectedSticker(stickerInfo: StickerFilesInfo) {
|
|
|
|
this.selectedSticker = stickerInfo;
|
|
|
|
}
|
2019-11-25 06:48:43 +00:00
|
|
|
setStickerHistory(sticker: StickerFilesInfo) {
|
|
|
|
const history = this.localStorageService.get<string[]>(KEY_STICKER_HISTORY);
|
|
|
|
|
|
|
|
if (!!history && history.length > 0) {
|
|
|
|
const stickers: string[] = [];
|
|
|
|
[sticker.index, ...history.filter(hist => hist !== sticker.index)].map(
|
|
|
|
(s, i) => {
|
|
|
|
if (i < 10) {
|
|
|
|
stickers.push(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
this.localStorageService.set<string[]>(KEY_STICKER_HISTORY, stickers);
|
|
|
|
} else {
|
|
|
|
this.localStorageService.set<string[]>(KEY_STICKER_HISTORY, [
|
|
|
|
sticker.index
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|
2019-09-23 05:23:24 +00:00
|
|
|
}
|