2019-10-10 06:53:08 +00:00
|
|
|
import {
|
|
|
|
Component,
|
|
|
|
OnInit,
|
|
|
|
OnDestroy,
|
|
|
|
ViewChild,
|
2019-11-08 04:35:39 +00:00
|
|
|
AfterViewInit,
|
|
|
|
Output,
|
2020-01-03 06:52:19 +00:00
|
|
|
EventEmitter,
|
2020-01-16 09:07:03 +00:00
|
|
|
Inject,
|
2020-01-20 07:40:17 +00:00
|
|
|
ChangeDetectorRef,
|
|
|
|
ChangeDetectionStrategy
|
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,
|
2020-01-10 00:37:29 +00:00
|
|
|
StringUtil,
|
|
|
|
AlertSnackbarComponent,
|
|
|
|
AlertSnackbarData
|
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';
|
2020-01-17 01:41:22 +00:00
|
|
|
import {
|
|
|
|
Observable,
|
|
|
|
Subscription,
|
|
|
|
forkJoin,
|
|
|
|
combineLatest,
|
|
|
|
of,
|
|
|
|
BehaviorSubject
|
|
|
|
} from 'rxjs';
|
2020-01-29 02:45:14 +00:00
|
|
|
|
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,
|
2019-12-23 06:23:27 +00:00
|
|
|
StickerEventJson,
|
2019-12-31 05:36:32 +00:00
|
|
|
MassTextEventJson,
|
2019-12-31 07:10:24 +00:00
|
|
|
TranslationEventJson,
|
|
|
|
MassTranslationEventJson
|
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';
|
2020-01-16 09:07:03 +00:00
|
|
|
import {
|
|
|
|
RoomInfo,
|
|
|
|
UserInfo,
|
|
|
|
RoomType,
|
|
|
|
UserInfoShort
|
|
|
|
} from '@ucap-webmessenger/protocol-room';
|
2020-01-03 06:52:19 +00:00
|
|
|
import { tap, take, map, catchError, finalize } from 'rxjs/operators';
|
2020-01-17 01:41:22 +00:00
|
|
|
import {
|
|
|
|
FormComponent as UCapUiChatFormComponent,
|
|
|
|
MessagesComponent as UCapUiChatMessagesComponent
|
|
|
|
} 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';
|
2020-01-03 06:52:19 +00:00
|
|
|
import { FileUploadItem, FileDownloadItem } from '@ucap-webmessenger/api';
|
2019-11-05 04:46:17 +00:00
|
|
|
import {
|
|
|
|
CommonApiService,
|
|
|
|
FileTalkSaveRequest,
|
2019-12-31 05:36:32 +00:00
|
|
|
FileTalkSaveResponse,
|
2019-12-31 07:10:24 +00:00
|
|
|
TranslationSaveRequest,
|
|
|
|
TranslationSaveResponse
|
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';
|
2020-01-03 06:52:19 +00:00
|
|
|
import { FileUtil, StickerFilesInfo, MimeUtil } from '@ucap-webmessenger/core';
|
2020-01-17 01:41:22 +00:00
|
|
|
|
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-12-19 06:29:18 +00:00
|
|
|
import { environment } from '../../../../environments/environment';
|
2020-01-01 23:44:16 +00:00
|
|
|
import {
|
|
|
|
MassDetailComponent,
|
|
|
|
MassDetailDialogData
|
|
|
|
} from '../dialogs/chat/mass-detail.component';
|
2020-01-03 06:52:19 +00:00
|
|
|
import { NativeService, UCAP_NATIVE_SERVICE } from '@ucap-webmessenger/native';
|
2020-01-07 02:36:25 +00:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2020-01-16 09:07:03 +00:00
|
|
|
import { TranslatePipe } from 'projects/ucap-webmessenger-ui/src/lib/pipes/translate.pipe';
|
2020-01-17 03:28:43 +00:00
|
|
|
import { TranslateService as UiTranslateService } from '@ucap-webmessenger/ui';
|
2020-01-17 01:50:06 +00:00
|
|
|
import { FileProtocolService } from '@ucap-webmessenger/protocol-file';
|
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'],
|
2020-01-20 07:40:17 +00:00
|
|
|
animations: ucapAnimations,
|
|
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
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()
|
2020-01-02 06:58:16 +00:00
|
|
|
openProfile = new EventEmitter<{
|
|
|
|
userSeq: number;
|
|
|
|
}>();
|
2020-01-08 04:21:09 +00:00
|
|
|
@Output()
|
|
|
|
closeRightDrawer = new EventEmitter();
|
2019-11-08 04:35:39 +00:00
|
|
|
|
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-11-05 04:46:17 +00:00
|
|
|
@ViewChild('fileUploadQueue', { static: true })
|
|
|
|
fileUploadQueue: FileUploadQueueComponent;
|
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
@ViewChild('chatMessages', { static: true })
|
|
|
|
chatMessages: UCapUiChatMessagesComponent;
|
|
|
|
|
2019-10-16 09:05:18 +00:00
|
|
|
environmentsInfo: EnvironmentsInfo;
|
|
|
|
|
2019-10-08 05:59:22 +00:00
|
|
|
loginResSubscription: Subscription;
|
2020-01-17 01:41:22 +00:00
|
|
|
loginResSubject = new BehaviorSubject<LoginResponse>(undefined);
|
|
|
|
|
2019-10-08 05:34:37 +00:00
|
|
|
roomInfoSubscription: Subscription;
|
2020-01-17 01:41:22 +00:00
|
|
|
roomInfoSubject = new BehaviorSubject<RoomInfo>(undefined);
|
|
|
|
|
2019-10-22 00:30:23 +00:00
|
|
|
userInfoListSubscription: Subscription;
|
2020-01-17 01:41:22 +00:00
|
|
|
userInfoListSubject = new BehaviorSubject<UserInfo[]>(undefined);
|
|
|
|
|
|
|
|
eventListSubscription: Subscription;
|
|
|
|
eventListSubject = new BehaviorSubject<Info<EventJson>[]>(undefined);
|
|
|
|
eventListNewSubject = new BehaviorSubject<Info<EventJson>[]>(undefined);
|
|
|
|
|
2019-12-04 05:36:15 +00:00
|
|
|
eventInfoStatusSubscription: Subscription;
|
2020-01-17 01:41:22 +00:00
|
|
|
eventInfoStatusSubject = new BehaviorSubject<InfoResponse>(undefined);
|
|
|
|
|
|
|
|
eventRemainedSubscription: Subscription;
|
|
|
|
eventRemainedSubject = new BehaviorSubject<boolean>(false); // 이전대화가 남아 있는지 여부
|
|
|
|
|
2019-10-16 09:05:18 +00:00
|
|
|
sessionVerInfo: VersionInfo2Response;
|
2019-10-08 04:31:33 +00:00
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
baseEventSeq = 0;
|
|
|
|
eventListProcessing$: Observable<boolean>;
|
|
|
|
searchEventListProcessing: boolean;
|
|
|
|
searchEventListProcessingSubscription: Subscription;
|
2019-11-06 10:11:08 +00:00
|
|
|
|
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-12-23 06:23:27 +00:00
|
|
|
/** About Searching */
|
2020-01-07 04:45:34 +00:00
|
|
|
isShowSearchArea = false;
|
2019-12-23 06:23:27 +00:00
|
|
|
moreSearchProcessing = false;
|
|
|
|
searchText = '';
|
2020-01-17 01:41:22 +00:00
|
|
|
searchedListSubject = new BehaviorSubject<Info<EventJson>[]>(undefined);
|
2019-12-23 06:23:27 +00:00
|
|
|
searchedFocusEvent: Info<EventJson>;
|
|
|
|
searchTotalCount = 0;
|
|
|
|
searchCurrentIndex = 0;
|
|
|
|
|
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-12-31 05:36:32 +00:00
|
|
|
/** About Translation */
|
2019-12-31 08:02:04 +00:00
|
|
|
isTranslationProcess = false;
|
2019-12-31 05:36:32 +00:00
|
|
|
isShowTranslation = false;
|
|
|
|
translationSimpleview = false;
|
|
|
|
translationPreview = false;
|
|
|
|
destLocale = 'en'; // default English :: en
|
2019-12-31 07:10:24 +00:00
|
|
|
translationPreviewInfo: {
|
|
|
|
previewInfo: TranslationSaveResponse | null;
|
|
|
|
translationType: EventType.Translation | EventType.MassTranslation;
|
|
|
|
};
|
2019-12-31 05:36:32 +00:00
|
|
|
|
2019-12-19 05:23:11 +00:00
|
|
|
/** About ReadHere */
|
2020-01-17 01:41:22 +00:00
|
|
|
firstCheckReadHere = true;
|
2019-12-19 05:23:11 +00:00
|
|
|
clearReadHere = false;
|
2020-01-07 08:45:43 +00:00
|
|
|
initRoomLastEventSeq: number;
|
2019-12-19 05:23:11 +00:00
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
snackBarPreviewEvent: MatSnackBarRef<SimpleSnackBar>;
|
|
|
|
|
2019-12-17 07:13:38 +00:00
|
|
|
RoomType = RoomType;
|
2019-12-19 07:07:33 +00:00
|
|
|
environment = environment;
|
2019-12-17 07:13:38 +00:00
|
|
|
|
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,
|
2020-01-17 01:50:06 +00:00
|
|
|
private fileProtocolService: FileProtocolService,
|
2019-10-16 09:05:18 +00:00
|
|
|
private clipboardService: ClipboardService,
|
2020-01-17 03:28:43 +00:00
|
|
|
private uiTranslateService: UiTranslateService,
|
2020-01-07 02:36:25 +00:00
|
|
|
private translateService: TranslateService,
|
2020-01-16 09:07:03 +00:00
|
|
|
private changeDetectorRef: ChangeDetectorRef,
|
2019-10-16 09:05:18 +00:00
|
|
|
private dialogService: DialogService,
|
|
|
|
private snackBarService: SnackBarService,
|
2020-01-03 06:52:19 +00:00
|
|
|
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
|
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
|
|
|
|
|
|
|
ngOnInit() {
|
2019-10-08 05:59:22 +00:00
|
|
|
this.loginResSubscription = this.store
|
2020-01-17 01:41:22 +00:00
|
|
|
.pipe(select(AppStore.AccountSelector.AuthenticationSelector.loginRes))
|
|
|
|
.subscribe(loginRes => {
|
|
|
|
this.loginResSubject.next(loginRes);
|
|
|
|
});
|
2019-09-23 05:23:24 +00:00
|
|
|
|
2019-10-08 05:34:37 +00:00
|
|
|
this.roomInfoSubscription = this.store
|
2020-01-17 01:41:22 +00:00
|
|
|
.pipe(select(AppStore.MessengerSelector.RoomSelector.roomInfo))
|
|
|
|
.subscribe(roomInfo => {
|
|
|
|
this.clearView();
|
|
|
|
this.roomInfoSubject.next(roomInfo);
|
|
|
|
});
|
2019-10-08 05:34:37 +00:00
|
|
|
|
2019-10-22 00:30:23 +00:00
|
|
|
this.userInfoListSubscription = this.store
|
2020-01-17 01:41:22 +00:00
|
|
|
.pipe(select(AppStore.MessengerSelector.RoomSelector.selectUserinfolist))
|
|
|
|
.subscribe(userInfoList => {
|
|
|
|
this.userInfoListSubject.next(userInfoList);
|
|
|
|
});
|
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)
|
|
|
|
);
|
|
|
|
|
2020-01-07 04:45:34 +00:00
|
|
|
this.searchEventListProcessingSubscription = this.store
|
|
|
|
.pipe(
|
|
|
|
select(
|
|
|
|
AppStore.MessengerSelector.EventSelector.infoSearchListProcessing
|
2020-01-17 01:41:22 +00:00
|
|
|
)
|
2020-01-07 04:45:34 +00:00
|
|
|
)
|
2020-01-17 01:41:22 +00:00
|
|
|
.subscribe(process => {
|
|
|
|
this.searchEventListProcessing = process;
|
|
|
|
if (!process && this.isShowSearchArea) {
|
|
|
|
this.doSearchTextInEvent(this.searchText);
|
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant('chat.searchEventByTextEnd'),
|
|
|
|
this.translateService.instant('common.messages.confirm'),
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'top',
|
|
|
|
horizontalPosition: 'center'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
2020-01-07 04:45:34 +00:00
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
this.eventRemainedSubscription = this.store
|
|
|
|
.pipe(select(AppStore.MessengerSelector.EventSelector.remainInfo))
|
|
|
|
.subscribe(remained => {
|
|
|
|
this.eventRemainedSubject.next(remained);
|
|
|
|
});
|
2019-10-31 09:12:38 +00:00
|
|
|
|
2019-12-19 05:23:11 +00:00
|
|
|
// [Daesang]
|
|
|
|
this.eventListSubscription = combineLatest([
|
|
|
|
this.store.pipe(
|
|
|
|
select(AppStore.MessengerSelector.EventSelector.selectAllInfoList)
|
|
|
|
),
|
|
|
|
this.store.pipe(select(AppStore.MessengerSelector.RoomSelector.roomInfo))
|
2020-01-17 01:41:22 +00:00
|
|
|
]).subscribe(([infoList, roomInfo]) => {
|
|
|
|
if (
|
|
|
|
!!this.eventListSubject.value &&
|
|
|
|
this.eventListSubject.value.length > 0
|
|
|
|
) {
|
|
|
|
this.eventListNewSubject.next(
|
|
|
|
infoList.filter(info => {
|
2019-12-19 05:23:11 +00:00
|
|
|
if (
|
2020-01-17 01:41:22 +00:00
|
|
|
info.seq <=
|
|
|
|
this.eventListSubject.value[
|
|
|
|
this.eventListSubject.value.length - 1
|
|
|
|
].seq
|
2019-12-19 05:23:11 +00:00
|
|
|
) {
|
2020-01-17 01:41:22 +00:00
|
|
|
return false;
|
2019-12-19 05:23:11 +00:00
|
|
|
}
|
2020-01-17 01:41:22 +00:00
|
|
|
return true;
|
|
|
|
})
|
|
|
|
);
|
2019-12-19 05:23:11 +00:00
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
if (
|
|
|
|
!!infoList &&
|
|
|
|
infoList.length > 0 &&
|
|
|
|
!!roomInfo &&
|
|
|
|
!!roomInfo.lastReadEventSeq &&
|
|
|
|
this.baseEventSeq <= roomInfo.lastReadEventSeq
|
|
|
|
) {
|
|
|
|
// 조회된 내용중에 read here 가 있을 경우.
|
|
|
|
this.firstCheckReadHere = false;
|
|
|
|
}
|
|
|
|
}
|
2019-11-07 04:14:44 +00:00
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
this.eventListSubject.next(infoList);
|
|
|
|
|
|
|
|
if (this.moreSearchProcessing) {
|
|
|
|
const baseseq = this.baseEventSeq;
|
|
|
|
// setTimeout(() => {
|
|
|
|
// this.doSearchTextInEvent(this.searchText, baseseq);
|
|
|
|
// }, 800);
|
|
|
|
this.baseEventSeq = infoList[0].seq;
|
|
|
|
} else {
|
|
|
|
if (!!infoList && infoList.length > 0) {
|
|
|
|
this.baseEventSeq = infoList[0].seq;
|
|
|
|
this.readyToReply();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-10-10 06:53:08 +00:00
|
|
|
|
2019-12-19 05:23:11 +00:00
|
|
|
// // [GROUP]
|
|
|
|
// 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-12-04 05:36:15 +00:00
|
|
|
this.eventInfoStatusSubscription = this.store
|
2020-01-17 01:41:22 +00:00
|
|
|
.pipe(select(AppStore.MessengerSelector.EventSelector.infoStatus))
|
|
|
|
.subscribe(res => {
|
|
|
|
this.eventInfoStatusSubject.next(res);
|
|
|
|
|
|
|
|
if (!!res) {
|
|
|
|
const elist = this.eventListSubject.value;
|
|
|
|
if (res.baseSeq === 0 && elist.length > 0) {
|
|
|
|
this.initRoomLastEventSeq = elist[elist.length - 1].seq;
|
2020-01-07 08:45:43 +00:00
|
|
|
}
|
2020-01-17 01:41:22 +00:00
|
|
|
}
|
|
|
|
});
|
2019-10-29 09:11:31 +00:00
|
|
|
|
2020-01-20 07:40:17 +00:00
|
|
|
if (
|
|
|
|
!!this.roomInfoSubject.value &&
|
|
|
|
!!this.roomInfoSubject.value.isTimeRoom
|
|
|
|
) {
|
|
|
|
this.interval = setInterval(() => {
|
2019-11-01 04:43:49 +00:00
|
|
|
this.store.dispatch(EventStore.infoIntervalClear({}));
|
2020-01-20 07:40:17 +00:00
|
|
|
}, 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();
|
|
|
|
}
|
2020-01-17 01:41:22 +00:00
|
|
|
if (!!this.eventRemainedSubscription) {
|
|
|
|
this.eventRemainedSubscription.unsubscribe();
|
|
|
|
}
|
2020-01-07 04:45:34 +00:00
|
|
|
if (!!this.searchEventListProcessingSubscription) {
|
|
|
|
this.searchEventListProcessingSubscription.unsubscribe();
|
|
|
|
}
|
2019-11-01 04:43:49 +00:00
|
|
|
|
2020-01-20 07:40:17 +00:00
|
|
|
if (!!this.interval) {
|
|
|
|
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() {
|
2020-01-08 04:21:09 +00:00
|
|
|
// Right Drawer closed..
|
|
|
|
this.closeRightDrawer.emit();
|
|
|
|
|
2019-11-25 05:12:49 +00:00
|
|
|
// Sticker Selector Clear..
|
|
|
|
this.isShowStickerSelector = false;
|
|
|
|
this.selectedSticker = undefined;
|
2019-12-19 05:23:11 +00:00
|
|
|
|
2019-12-23 06:23:27 +00:00
|
|
|
// Chat Search Clear..
|
|
|
|
this.onCloseSearchArea();
|
|
|
|
|
2019-12-31 05:36:32 +00:00
|
|
|
// Translate Clear..
|
2019-12-31 08:02:04 +00:00
|
|
|
this.isTranslationProcess = false;
|
2019-12-31 05:36:32 +00:00
|
|
|
this.isShowTranslation = false;
|
|
|
|
this.translationSimpleview = false;
|
|
|
|
this.translationPreview = false;
|
|
|
|
// this.destLocale = 'en'; // default English :: en
|
|
|
|
this.translationPreviewInfo = null;
|
|
|
|
|
|
|
|
// Read here Clear..
|
2020-01-17 01:41:22 +00:00
|
|
|
this.firstCheckReadHere = true;
|
2019-12-23 06:23:15 +00:00
|
|
|
|
2019-12-31 05:36:32 +00:00
|
|
|
// Chat Formfield Clear..
|
2019-12-23 06:23:15 +00:00
|
|
|
if (!!this.chatForm) {
|
|
|
|
this.chatForm.replyForm.reset();
|
|
|
|
}
|
2019-11-25 05:12:49 +00:00
|
|
|
}
|
|
|
|
|
2019-12-17 07:13:38 +00:00
|
|
|
get _roomUserInfos() {
|
2020-01-28 04:26:32 +00:00
|
|
|
if (this.roomInfoSubject.value.roomType === RoomType.Single) {
|
|
|
|
return this.userInfoListSubject.value.filter(roomUserInfo => {
|
|
|
|
return this.loginResSubject.value.userSeq !== roomUserInfo.seq;
|
|
|
|
});
|
|
|
|
} else {
|
2020-01-29 02:45:14 +00:00
|
|
|
return this.userInfoListSubject.value
|
|
|
|
.filter(roomUserInfo => {
|
|
|
|
return (
|
|
|
|
this.loginResSubject.value.userSeq !== roomUserInfo.seq &&
|
|
|
|
roomUserInfo.isJoinRoom
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.sort((a, b) => (a.name < b.name ? -1 : a.name > b.name ? 1 : 0));
|
2020-01-28 04:26:32 +00:00
|
|
|
}
|
2019-10-22 00:30:23 +00:00
|
|
|
}
|
|
|
|
|
2020-01-16 09:07:03 +00:00
|
|
|
getRoomNameByRoomUser(roomUserInfos: (UserInfo | UserInfoShort)[]) {
|
|
|
|
let roomName = new TranslatePipe(
|
|
|
|
this.uiTranslateService,
|
|
|
|
this.changeDetectorRef
|
|
|
|
).transform(roomUserInfos, 'name', ',');
|
|
|
|
|
|
|
|
if (!roomName || roomName.trim().length === 0) {
|
|
|
|
roomName = this.translateService.instant('chat.noRoomUser');
|
|
|
|
}
|
|
|
|
return roomName;
|
|
|
|
}
|
|
|
|
|
2019-11-07 04:14:44 +00:00
|
|
|
/** 대화전송 가능한 방인지 판단 */
|
2019-11-06 08:32:27 +00:00
|
|
|
getEnableSend() {
|
2020-01-17 01:41:22 +00:00
|
|
|
if (!this.roomInfoSubject.value) {
|
2019-11-06 08:32:27 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (
|
2020-01-17 01:41:22 +00:00
|
|
|
[
|
|
|
|
RoomType.Bot,
|
|
|
|
RoomType.Allim,
|
|
|
|
RoomType.Link,
|
|
|
|
RoomType.Allim_Elephant,
|
|
|
|
RoomType.Allim_TMS
|
|
|
|
].some(v => v === this.roomInfoSubject.value.roomType)
|
2019-11-06 08:32:27 +00:00
|
|
|
) {
|
|
|
|
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 (
|
2020-01-17 01:41:22 +00:00
|
|
|
['OPEN_ROOM_USER', 'ADD_MEMBER', 'ADD_GROUP', 'EDIT_ROOM'].some(
|
|
|
|
v => v === menuType
|
|
|
|
)
|
2019-11-21 05:02:11 +00:00
|
|
|
) {
|
|
|
|
if (
|
2020-01-17 01:41:22 +00:00
|
|
|
!this.roomInfoSubject.value ||
|
|
|
|
!this.roomInfoSubject.value.roomType ||
|
|
|
|
[
|
|
|
|
RoomType.Mytalk,
|
|
|
|
RoomType.Allim,
|
|
|
|
RoomType.Bot,
|
|
|
|
RoomType.Link,
|
|
|
|
RoomType.Allim_Elephant,
|
|
|
|
RoomType.Allim_TMS
|
|
|
|
].some(v => v === this.roomInfoSubject.value.roomType)
|
2019-11-21 05:02:11 +00:00
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-22 00:17:47 +00:00
|
|
|
getShowUnreadCount(): boolean {
|
2020-01-17 01:41:22 +00:00
|
|
|
if (
|
|
|
|
!this.roomInfoSubject.value ||
|
|
|
|
this.roomInfoSubject.value === undefined
|
|
|
|
) {
|
2019-11-22 00:17:47 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if (
|
2020-01-17 01:41:22 +00:00
|
|
|
[
|
|
|
|
RoomType.Mytalk,
|
|
|
|
RoomType.Allim,
|
|
|
|
RoomType.Bot,
|
|
|
|
RoomType.Link,
|
|
|
|
RoomType.Allim_Elephant,
|
|
|
|
RoomType.Allim_TMS
|
|
|
|
].some(v => v === this.roomInfoSubject.value.roomType)
|
2019-11-22 00:17:47 +00:00
|
|
|
) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-11-01 06:06:37 +00:00
|
|
|
readyToReply(): void {
|
|
|
|
setTimeout(() => {
|
|
|
|
this.focusReplyInput();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
onScrollupMessages(event: any) {}
|
|
|
|
onYReachStartMessages(event: any) {
|
2019-12-19 05:23:11 +00:00
|
|
|
// 자동 스크롤이 아닌 버튼 방식으로 변경.
|
|
|
|
// this.onMoreEvent(this.baseEventSeq);
|
2019-11-07 04:14:44 +00:00
|
|
|
}
|
2020-01-17 01:41:22 +00:00
|
|
|
onYReachEndMessages(event: any) {
|
|
|
|
this.chatMessages.initEventMore();
|
2019-11-07 04:14:44 +00:00
|
|
|
if (!!this.snackBarPreviewEvent) {
|
|
|
|
this.snackBarPreviewEvent.dismiss();
|
|
|
|
}
|
2019-12-19 05:23:11 +00:00
|
|
|
|
2020-01-03 04:25:00 +00:00
|
|
|
// // clear readHere object.. 정책상 클리어 하지 않도록 함.
|
2020-01-17 01:41:22 +00:00
|
|
|
// if (!this.firstCheckReadHere) {
|
2020-01-03 04:25:00 +00:00
|
|
|
// this.clearReadHere = true;
|
|
|
|
// }
|
2019-11-07 04:14:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** More Event */
|
|
|
|
onMoreEvent(seq: number) {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.info({
|
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
|
|
|
baseSeq: seq,
|
|
|
|
requestCount:
|
|
|
|
environment.productConfig.CommonSetting.eventRequestDefaultCount
|
|
|
|
})
|
|
|
|
);
|
2019-11-07 04:14:44 +00:00
|
|
|
}
|
2019-11-01 06:06:37 +00:00
|
|
|
|
2019-12-31 05:36:32 +00:00
|
|
|
/** Send Event */
|
2020-01-08 03:30:39 +00:00
|
|
|
async onSendMessage(message: string) {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.chatMessages.initEventMore();
|
2019-11-07 04:14:44 +00:00
|
|
|
|
2019-11-25 05:12:49 +00:00
|
|
|
if (!this.selectedSticker) {
|
|
|
|
if (!message || message.trim().length === 0) {
|
2020-01-08 03:30:39 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
data: {
|
|
|
|
title: this.translateService.instant('chat.errors.label'),
|
|
|
|
message: this.translateService.instant(
|
|
|
|
'chat.errors.inputChatMessage'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
2019-11-25 05:12:49 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-10-30 02:12:45 +00:00
|
|
|
}
|
|
|
|
|
2019-12-31 05:36:32 +00:00
|
|
|
if (!!this.isShowTranslation && this.destLocale.trim().length > 0) {
|
|
|
|
/** CASE : Translation */
|
2020-01-23 01:03:48 +00:00
|
|
|
// 번역할 대화 없이 스티커만 전송할 경우.
|
|
|
|
if (!message || message.trim().length === 0) {
|
|
|
|
this.sendMessageOfSticker(message);
|
|
|
|
} else {
|
|
|
|
this.sendMessageOfTranslate(message);
|
2019-12-31 08:02:04 +00:00
|
|
|
}
|
2019-12-31 05:36:32 +00:00
|
|
|
} else if (!!this.selectedSticker) {
|
|
|
|
/** CASE : Sticker */
|
2020-01-23 01:03:48 +00:00
|
|
|
this.sendMessageOfSticker(message);
|
2019-12-19 06:29:18 +00:00
|
|
|
} else if (
|
|
|
|
message.trim().length >
|
|
|
|
environment.productConfig.CommonSetting.masstextLength
|
|
|
|
) {
|
2019-12-31 05:36:32 +00:00
|
|
|
/** CASE : MASS TEXT */
|
2020-01-23 01:03:48 +00:00
|
|
|
this.sendMessageOfMassText(message);
|
2019-10-28 09:03:27 +00:00
|
|
|
} else {
|
2019-12-31 05:36:32 +00:00
|
|
|
/** CASE : Normal Text */
|
2020-01-23 01:03:48 +00:00
|
|
|
this.sendMessageOfNormal(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Send Normal message */
|
|
|
|
sendMessageOfNormal(message: string) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.send({
|
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
|
|
|
eventType: EventType.Character,
|
|
|
|
sentMessage: message
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
/** Send Sticker message */
|
|
|
|
async sendMessageOfSticker(message: string, isCheck: boolean = true) {
|
|
|
|
if (
|
|
|
|
!!isCheck &&
|
|
|
|
!!message &&
|
|
|
|
message.trim().length >
|
|
|
|
environment.productConfig.CommonSetting.masstextLength
|
|
|
|
) {
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
data: {
|
|
|
|
title: this.translateService.instant('chat.errors.label'),
|
|
|
|
message: this.translateService.instant(
|
|
|
|
'chat.errors.maxLengthOfMassText',
|
|
|
|
{
|
|
|
|
maxLength: environment.productConfig.CommonSetting.masstextLength
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return;
|
2019-10-28 09:03:27 +00:00
|
|
|
}
|
2020-01-23 01:03:48 +00:00
|
|
|
|
|
|
|
const stickerJson: StickerEventJson = {
|
|
|
|
name: '스티커',
|
|
|
|
file: this.selectedSticker.index,
|
|
|
|
chat: !!message ? message.trim() : ''
|
|
|
|
};
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.send({
|
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
|
|
|
eventType: EventType.Sticker,
|
|
|
|
sentMessage: JSON.stringify(stickerJson)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
this.isShowStickerSelector = false;
|
|
|
|
this.setStickerHistory(this.selectedSticker);
|
|
|
|
this.selectedSticker = null;
|
|
|
|
}
|
|
|
|
/** Send Masstext message */
|
|
|
|
sendMessageOfMassText(message: string) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.sendMass({
|
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
|
|
|
eventType: EventType.MassText,
|
|
|
|
// sentMessage: message.replace(/\n/gi, '\r\n')
|
2020-01-29 02:45:14 +00:00
|
|
|
sentMessage: StringUtil.escapeHtml(message)
|
2020-01-23 01:03:48 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
/** Send Translation message */
|
|
|
|
sendMessageOfTranslate(message: string) {
|
|
|
|
const destLocale = this.destLocale;
|
|
|
|
const original = message;
|
|
|
|
const roomSeq = this.roomInfoSubject.value.roomSeq;
|
|
|
|
|
|
|
|
if (!!this.isTranslationProcess) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isTranslationProcess = true;
|
|
|
|
this.commonApiService
|
|
|
|
.translationSave({
|
|
|
|
userSeq: this.loginResSubject.value.userSeq,
|
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
|
|
|
token: this.loginResSubject.value.tokenString,
|
|
|
|
roomSeq,
|
|
|
|
original,
|
|
|
|
srcLocale: '',
|
|
|
|
destLocale
|
|
|
|
} as TranslationSaveRequest)
|
|
|
|
.pipe(
|
|
|
|
take(1),
|
|
|
|
map(res => {
|
|
|
|
if (res.statusCode === StatusCode.Success) {
|
|
|
|
let sentMessage = '';
|
|
|
|
let eventType = EventType.Translation;
|
|
|
|
let previewObject: TranslationEventJson | MassTranslationEventJson;
|
|
|
|
|
|
|
|
if (res.translationSeq > 0) {
|
|
|
|
// Mass Text Translation
|
|
|
|
previewObject = res;
|
|
|
|
sentMessage = res.returnJson;
|
|
|
|
eventType = EventType.MassTranslation;
|
|
|
|
} else {
|
|
|
|
// Normal Text Translation
|
|
|
|
previewObject = {
|
|
|
|
locale: destLocale,
|
|
|
|
original,
|
|
|
|
translation: res.translation,
|
|
|
|
stickername: '',
|
|
|
|
stickerfile: !!this.selectedSticker
|
|
|
|
? this.selectedSticker.index
|
|
|
|
: ''
|
|
|
|
};
|
|
|
|
|
|
|
|
sentMessage = JSON.stringify(previewObject);
|
|
|
|
eventType = EventType.Translation;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!this.translationPreview) {
|
|
|
|
// preview
|
|
|
|
this.translationPreviewInfo = {
|
|
|
|
previewInfo: res,
|
|
|
|
translationType: eventType
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
// direct send
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.send({
|
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
|
|
|
req: {
|
|
|
|
roomSeq,
|
|
|
|
eventType,
|
|
|
|
sentMessage
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!!this.translationPreviewInfo) {
|
|
|
|
this.translationPreviewInfo = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!!this.selectedSticker) {
|
|
|
|
this.isShowStickerSelector = false;
|
|
|
|
this.setStickerHistory(this.selectedSticker);
|
|
|
|
this.selectedSticker = null;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
this.logger.error(res);
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
catchError(error => of(this.logger.error(error)))
|
|
|
|
)
|
|
|
|
.subscribe(() => {
|
|
|
|
this.isTranslationProcess = false;
|
|
|
|
});
|
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() {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
RoomStore.updateOnlyAlarm({ roomInfo: this.roomInfoSubject.value })
|
|
|
|
);
|
2019-10-11 06:55:27 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2020-01-08 23:46:04 +00:00
|
|
|
onMassTranslationDetail(params: {
|
|
|
|
message: Info<MassTranslationEventJson>;
|
2020-01-01 23:44:16 +00:00
|
|
|
contentsType: string;
|
|
|
|
}) {
|
2020-01-08 23:46:04 +00:00
|
|
|
this.commonApiService
|
|
|
|
.transMassTalkDownload({
|
2020-01-17 01:41:22 +00:00
|
|
|
userSeq: this.loginResSubject.value.userSeq,
|
2020-01-08 23:46:04 +00:00
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
2020-01-17 01:41:22 +00:00
|
|
|
token: this.loginResSubject.value.tokenString,
|
2020-01-08 23:46:04 +00:00
|
|
|
eventTransSeq: params.message.sentMessageJson.translationSeq.toString()
|
|
|
|
})
|
|
|
|
.pipe(take(1))
|
|
|
|
.subscribe(res => {
|
|
|
|
let contents = '';
|
|
|
|
if (res.statusCode === StatusCode.Success) {
|
|
|
|
contents =
|
|
|
|
params.contentsType === 'T' ? res.translation : res.original;
|
|
|
|
} else {
|
|
|
|
contents =
|
|
|
|
params.contentsType === 'T'
|
|
|
|
? params.message.sentMessageJson.translation
|
|
|
|
: params.message.sentMessageJson.original;
|
2020-01-01 23:44:16 +00:00
|
|
|
}
|
2020-01-08 23:46:04 +00:00
|
|
|
|
|
|
|
this.dialogService.open<MassDetailComponent, MassDetailDialogData>(
|
|
|
|
MassDetailComponent,
|
|
|
|
{
|
|
|
|
disableClose: false,
|
|
|
|
width: '550px',
|
|
|
|
data: {
|
|
|
|
title: this.translateService.instant('chat.detailView'),
|
|
|
|
contents
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
});
|
2020-01-01 23:44:16 +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,
|
2020-01-17 01:41:22 +00:00
|
|
|
token: this.loginResSubject.value.tokenString,
|
|
|
|
userSeq: this.loginResSubject.value.userSeq
|
2019-11-15 01:13:18 +00:00
|
|
|
}
|
2019-10-29 00:07:06 +00:00
|
|
|
});
|
2019-10-14 04:53:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** File Save, Save As */
|
2020-01-03 06:52:19 +00:00
|
|
|
onSave(value: {
|
|
|
|
fileInfo: FileEventJson;
|
|
|
|
fileDownloadItem: FileDownloadItem;
|
|
|
|
type: string;
|
|
|
|
}) {
|
2019-10-14 04:53:22 +00:00
|
|
|
this.logger.debug('fileSave', value);
|
2020-01-03 06:52:19 +00:00
|
|
|
if (value.type === 'saveAs') {
|
2020-01-08 03:30:39 +00:00
|
|
|
this.nativeService
|
|
|
|
.selectSaveFilePath(value.fileInfo.fileName)
|
|
|
|
.then(result => {
|
2020-01-30 02:03:34 +00:00
|
|
|
if (!!result && result.filePath.length > 0) {
|
|
|
|
this.saveFile(value, result.filePath);
|
2020-01-08 03:30:39 +00:00
|
|
|
} else {
|
2020-01-30 02:03:34 +00:00
|
|
|
if (!!result && result.canceled) {
|
|
|
|
// ignore..
|
|
|
|
} else {
|
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.file.errors.failToSpecifyPath'
|
|
|
|
),
|
|
|
|
this.translateService.instant('common.file.errors.label')
|
|
|
|
);
|
|
|
|
}
|
2020-01-08 03:30:39 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(reason => {
|
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.file.errors.failToSpecifyPath'
|
|
|
|
),
|
|
|
|
this.translateService.instant('common.file.errors.label')
|
|
|
|
);
|
2020-01-03 06:52:19 +00:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
this.saveFile(value);
|
|
|
|
}
|
2019-10-14 04:53:22 +00:00
|
|
|
}
|
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');
|
|
|
|
}
|
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
onExistNewMessage(info: Info<EventJson>) {
|
|
|
|
let message = '';
|
|
|
|
|
|
|
|
const senderUser = this.userInfoListSubject.value.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,
|
|
|
|
this.translateService.instant('common.messages.confirm'),
|
|
|
|
{
|
|
|
|
// duration: 3000,
|
|
|
|
verticalPosition: 'bottom',
|
|
|
|
horizontalPosition: 'center',
|
|
|
|
panelClass: ['chat-snackbar-class']
|
|
|
|
}
|
|
|
|
);
|
|
|
|
this.snackBarPreviewEvent.onAction().subscribe(() => {
|
|
|
|
this.chatMessages.initEventMore();
|
|
|
|
this.chatMessages.scrollToBottom();
|
|
|
|
this.snackBarPreviewEvent.dismiss();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-01-03 06:52:19 +00:00
|
|
|
saveFile(
|
|
|
|
value: {
|
|
|
|
fileInfo: FileEventJson;
|
|
|
|
fileDownloadItem: FileDownloadItem;
|
|
|
|
type: string;
|
|
|
|
},
|
|
|
|
savePath?: string
|
|
|
|
) {
|
|
|
|
this.commonApiService
|
|
|
|
.fileTalkDownload({
|
2020-01-17 01:41:22 +00:00
|
|
|
userSeq: this.loginResSubject.value.userSeq,
|
2020-01-03 06:52:19 +00:00
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
2020-01-17 01:41:22 +00:00
|
|
|
token: this.loginResSubject.value.tokenString,
|
2020-01-03 06:52:19 +00:00
|
|
|
attachmentsSeq: value.fileInfo.attachmentSeq,
|
|
|
|
fileDownloadItem: value.fileDownloadItem
|
|
|
|
})
|
|
|
|
.pipe(
|
|
|
|
take(1),
|
|
|
|
map(async rawBlob => {
|
|
|
|
const mimeType = MimeUtil.getMimeFromExtension(
|
|
|
|
FileUtil.getExtension(value.fileInfo.fileName)
|
|
|
|
);
|
|
|
|
const blob = rawBlob.slice(0, rawBlob.size, mimeType);
|
|
|
|
|
|
|
|
FileUtil.fromBlobToBuffer(blob)
|
|
|
|
.then(buffer => {
|
2020-01-17 01:50:06 +00:00
|
|
|
/** download check */
|
2020-01-17 03:29:51 +00:00
|
|
|
this.fileProtocolService
|
|
|
|
.downCheck({
|
|
|
|
seq: value.fileInfo.attachmentSeq
|
|
|
|
})
|
2020-01-17 01:50:06 +00:00
|
|
|
.pipe(take(1))
|
|
|
|
.subscribe();
|
|
|
|
|
2020-01-03 06:52:19 +00:00
|
|
|
this.nativeService
|
|
|
|
.saveFile(buffer, value.fileInfo.fileName, mimeType, savePath)
|
|
|
|
.then(result => {
|
|
|
|
if (!!result) {
|
2020-01-08 03:30:39 +00:00
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.file.results.savedToPath',
|
|
|
|
{
|
|
|
|
path: result
|
|
|
|
}
|
|
|
|
),
|
|
|
|
'',
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'bottom'
|
|
|
|
}
|
|
|
|
);
|
2020-01-03 06:52:19 +00:00
|
|
|
} else {
|
2020-01-10 00:37:29 +00:00
|
|
|
this.snackBarService.openFromComponent<
|
|
|
|
AlertSnackbarComponent,
|
|
|
|
AlertSnackbarData
|
|
|
|
>(AlertSnackbarComponent, {
|
|
|
|
data: {
|
|
|
|
html: this.translateService.instant(
|
|
|
|
'common.file.errors.failToSave'
|
|
|
|
),
|
|
|
|
buttonText: this.translateService.instant(
|
|
|
|
'common.file.errors.label'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
2020-01-03 06:52:19 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(reason => {
|
2020-01-10 00:37:29 +00:00
|
|
|
this.snackBarService.openFromComponent<
|
|
|
|
AlertSnackbarComponent,
|
|
|
|
AlertSnackbarData
|
|
|
|
>(AlertSnackbarComponent, {
|
|
|
|
data: {
|
|
|
|
html: this.translateService.instant(
|
|
|
|
'common.file.errors.failToSave'
|
|
|
|
),
|
|
|
|
buttonText: this.translateService.instant(
|
|
|
|
'common.file.errors.label'
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
2020-01-03 06:52:19 +00:00
|
|
|
});
|
|
|
|
})
|
|
|
|
.catch(reason => {
|
|
|
|
this.logger.error('download', reason);
|
|
|
|
});
|
|
|
|
}),
|
|
|
|
finalize(() => {
|
|
|
|
setTimeout(() => {
|
|
|
|
value.fileDownloadItem.downloadingProgress$ = undefined;
|
|
|
|
}, 1000);
|
|
|
|
})
|
|
|
|
)
|
|
|
|
.subscribe();
|
|
|
|
}
|
|
|
|
|
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 = {
|
2020-01-17 01:41:22 +00:00
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq
|
2019-11-05 05:55:17 +00:00
|
|
|
};
|
|
|
|
|
2019-11-05 04:46:17 +00:00
|
|
|
const allObservables: Observable<FileTalkSaveResponse>[] = [];
|
|
|
|
|
2020-01-09 09:14:00 +00:00
|
|
|
const fileAllowSize =
|
|
|
|
!!this.sessionVerInfo && this.sessionVerInfo.fileAllowSize
|
|
|
|
? this.sessionVerInfo.fileAllowSize
|
|
|
|
: environment.productConfig.CommonSetting.defaultFileAllowSize;
|
|
|
|
|
|
|
|
if (fileAllowSize > 0) {
|
|
|
|
if (
|
|
|
|
fileUploadItems.filter(
|
|
|
|
fui => fui.file.size > fileAllowSize * 1024 * 1024
|
|
|
|
).length
|
|
|
|
) {
|
|
|
|
this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
width: '360px',
|
|
|
|
data: {
|
|
|
|
title: '',
|
|
|
|
message: this.translateService.instant(
|
|
|
|
'common.file.errors.oversize',
|
|
|
|
{
|
|
|
|
maxSize: fileAllowSize
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (!!this.fileUploadQueue) {
|
|
|
|
this.fileUploadQueue.onUploadComplete();
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const checkExt = this.commonApiService.acceptableExtensionForFileTalk(
|
|
|
|
fileUploadItems.map(fui => FileUtil.getExtension(fui.file.name))
|
|
|
|
);
|
|
|
|
if (!checkExt.accept) {
|
|
|
|
if (!!this.fileUploadQueue) {
|
|
|
|
this.fileUploadQueue.onUploadComplete();
|
|
|
|
}
|
|
|
|
|
|
|
|
this.dialogService.open<
|
|
|
|
AlertDialogComponent,
|
|
|
|
AlertDialogData,
|
|
|
|
AlertDialogResult
|
|
|
|
>(AlertDialogComponent, {
|
|
|
|
data: {
|
|
|
|
title: 'Alert',
|
|
|
|
html: `${this.translateService.instant(
|
|
|
|
'common.file.errors.notSupporedType'
|
|
|
|
)} ${
|
|
|
|
checkExt.reject.length > 0
|
|
|
|
? '<br/>(' + checkExt.reject.join(',') + ')'
|
|
|
|
: ''
|
|
|
|
}`
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-11-05 04:46:17 +00:00
|
|
|
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 = {
|
2020-01-17 01:41:22 +00:00
|
|
|
userSeq: this.loginResSubject.value.userSeq,
|
2019-11-05 04:46:17 +00:00
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
2020-01-17 01:41:22 +00:00
|
|
|
token: this.loginResSubject.value.tokenString,
|
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
2019-11-05 04:46:17 +00:00
|
|
|
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);
|
2020-01-08 03:30:39 +00:00
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant('common.file.errors.failToUpload'),
|
|
|
|
this.translateService.instant('common.file.errors.label')
|
|
|
|
);
|
2020-01-09 09:14:00 +00:00
|
|
|
|
|
|
|
if (!!this.fileUploadQueue) {
|
|
|
|
this.fileUploadQueue.onUploadComplete();
|
|
|
|
}
|
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>;
|
2020-01-08 09:27:35 +00:00
|
|
|
type?: string;
|
2019-11-06 04:48:06 +00:00
|
|
|
}) {
|
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,
|
2020-01-17 01:41:22 +00:00
|
|
|
loginRes: this.loginResSubject.value,
|
2020-01-08 09:27:35 +00:00
|
|
|
clicktype: params.type
|
2019-10-16 07:33:19 +00:00
|
|
|
};
|
|
|
|
this.messageContextMenuTrigger.openMenu();
|
|
|
|
}
|
|
|
|
|
2020-01-08 09:27:35 +00:00
|
|
|
async onClickMessageContextMenu(
|
|
|
|
menuType: string,
|
|
|
|
message: Info<EventJson>,
|
|
|
|
clicktype?: string
|
|
|
|
) {
|
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
|
|
|
) {
|
2020-01-10 00:37:29 +00:00
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.clipboard.results.copied'
|
|
|
|
),
|
|
|
|
'확인'
|
|
|
|
);
|
2020-01-08 03:30:39 +00:00
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.clipboard.results.copied'
|
|
|
|
),
|
|
|
|
'',
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'top',
|
|
|
|
horizontalPosition: 'center'
|
|
|
|
}
|
|
|
|
);
|
2019-10-16 09:05:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EventType.MassText:
|
|
|
|
{
|
|
|
|
this.commonApiService
|
|
|
|
.massTalkDownload({
|
2020-01-17 01:41:22 +00:00
|
|
|
userSeq: this.loginResSubject.value.userSeq,
|
2019-10-16 09:05:18 +00:00
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
2020-01-17 01:41:22 +00:00
|
|
|
token: this.loginResSubject.value.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)) {
|
2020-01-08 03:30:39 +00:00
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.clipboard.results.copied'
|
|
|
|
),
|
|
|
|
'',
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'top',
|
|
|
|
horizontalPosition: 'center'
|
|
|
|
}
|
|
|
|
);
|
2019-10-16 09:05:18 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
break;
|
2020-01-08 09:27:35 +00:00
|
|
|
case EventType.Translation:
|
2020-01-14 09:26:09 +00:00
|
|
|
{
|
|
|
|
let trgtStr = '';
|
|
|
|
if (clicktype === 'translation') {
|
|
|
|
// translation
|
|
|
|
trgtStr = (message.sentMessageJson as TranslationEventJson)
|
|
|
|
.translation;
|
|
|
|
} else {
|
|
|
|
// original
|
|
|
|
trgtStr = (message.sentMessageJson as TranslationEventJson)
|
|
|
|
.original;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.clipboardService.copyFromContent(trgtStr)) {
|
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.clipboard.results.copied'
|
|
|
|
),
|
|
|
|
'',
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'top',
|
|
|
|
horizontalPosition: 'center'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2020-01-08 09:27:35 +00:00
|
|
|
case EventType.MassTranslation:
|
|
|
|
{
|
2020-01-08 23:46:04 +00:00
|
|
|
const sentMessageJson: MassTranslationEventJson = message.sentMessageJson as MassTranslationEventJson;
|
|
|
|
this.commonApiService
|
|
|
|
.transMassTalkDownload({
|
2020-01-17 01:41:22 +00:00
|
|
|
userSeq: this.loginResSubject.value.userSeq,
|
2020-01-08 23:46:04 +00:00
|
|
|
deviceType: this.environmentsInfo.deviceType,
|
2020-01-17 01:41:22 +00:00
|
|
|
token: this.loginResSubject.value.tokenString,
|
2020-01-08 23:46:04 +00:00
|
|
|
eventTransSeq: sentMessageJson.translationSeq.toString()
|
|
|
|
})
|
|
|
|
.pipe(take(1))
|
|
|
|
.subscribe(res => {
|
|
|
|
let contents = '';
|
|
|
|
if (res.statusCode === StatusCode.Success) {
|
|
|
|
contents =
|
|
|
|
clicktype === 'translation'
|
|
|
|
? res.translation
|
|
|
|
: res.original;
|
|
|
|
} else {
|
|
|
|
contents =
|
|
|
|
clicktype === 'translation'
|
|
|
|
? sentMessageJson.translation
|
|
|
|
: sentMessageJson.original;
|
|
|
|
}
|
2019-10-16 09:05:18 +00:00
|
|
|
|
2020-01-08 23:46:04 +00:00
|
|
|
if (this.clipboardService.copyFromContent(contents)) {
|
|
|
|
this.snackBarService.open(
|
|
|
|
this.translateService.instant(
|
|
|
|
'common.clipboard.results.copied'
|
|
|
|
),
|
|
|
|
'',
|
|
|
|
{
|
|
|
|
duration: 3000,
|
|
|
|
verticalPosition: 'top',
|
|
|
|
horizontalPosition: 'center'
|
|
|
|
}
|
|
|
|
);
|
2020-01-08 09:27:35 +00:00
|
|
|
}
|
2020-01-08 23:46:04 +00:00
|
|
|
});
|
2020-01-08 09:27:35 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-10-16 09:05:18 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'REPLAY':
|
|
|
|
{
|
2020-01-08 03:30:39 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
|
|
|
>(CreateChatDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
data: {
|
|
|
|
type: UserSelectDialogType.MessageForward,
|
|
|
|
title: this.translateService.instant('chat.forwardEventTo'),
|
2020-01-17 01:41:22 +00:00
|
|
|
ignoreRoom: [this.roomInfoSubject.value]
|
2020-01-08 03:30:39 +00:00
|
|
|
}
|
|
|
|
});
|
2019-10-24 08:04:58 +00:00
|
|
|
|
2020-01-08 03:30:39 +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));
|
|
|
|
}
|
2019-10-24 08:04:58 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
if (!!result.selectedRoom) {
|
|
|
|
roomSeq = result.selectedRoom.roomSeq;
|
|
|
|
}
|
2019-10-24 08:04:58 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
if (userSeqs.length > 0 || roomSeq.trim().length > 0) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.forward({
|
2020-01-17 01:41:22 +00:00
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
2020-01-08 03:30:39 +00:00
|
|
|
req: {
|
|
|
|
roomSeq: '-999',
|
|
|
|
eventType: message.type,
|
|
|
|
sentMessage: message.sentMessage
|
|
|
|
},
|
|
|
|
trgtUserSeqs: userSeqs,
|
|
|
|
trgtRoomSeq: roomSeq
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'REPLAY_TO_ME':
|
|
|
|
{
|
2020-01-17 01:41:22 +00:00
|
|
|
if (this.loginResSubject.value.talkWithMeBotSeq > -1) {
|
2019-10-25 08:51:33 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.forward({
|
2020-01-17 01:41:22 +00:00
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
2019-10-25 08:51:33 +00:00
|
|
|
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
|
|
|
},
|
2020-01-17 01:41:22 +00:00
|
|
|
trgtUserSeqs: [this.loginResSubject.value.talkWithMeBotSeq]
|
2019-10-25 08:51:33 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'DELETE':
|
|
|
|
{
|
2020-01-08 03:30:39 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
|
|
|
ConfirmDialogResult
|
|
|
|
>(ConfirmDialogComponent, {
|
|
|
|
width: '400px',
|
|
|
|
data: {
|
|
|
|
title: this.translateService.instant('chat.removeEvent'),
|
|
|
|
html: this.translateService.instant('chat.confirmRemoveEvent')
|
|
|
|
}
|
|
|
|
});
|
2019-10-24 01:45:28 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.del({
|
2020-01-17 01:41:22 +00:00
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
2020-01-08 03:30:39 +00:00
|
|
|
eventSeq: message.seq
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'RECALL':
|
|
|
|
{
|
2020-01-08 03:30:39 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
ConfirmDialogComponent,
|
|
|
|
ConfirmDialogData,
|
|
|
|
ConfirmDialogResult
|
|
|
|
>(ConfirmDialogComponent, {
|
|
|
|
width: '400px',
|
|
|
|
data: {
|
|
|
|
title: this.translateService.instant('chat.recallEvent'),
|
|
|
|
html: this.translateService.instant('chat.confirmRecallEvent')
|
|
|
|
}
|
|
|
|
});
|
2019-10-24 01:45:28 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.cancel({
|
2020-01-17 01:41:22 +00:00
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
2020-01-08 03:30:39 +00:00
|
|
|
eventSeq: message.seq,
|
|
|
|
deviceType: this.environmentsInfo.deviceType
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2019-10-16 07:33:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-10-24 07:53:21 +00:00
|
|
|
|
2020-01-08 03:30:39 +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;
|
2019-12-23 06:23:27 +00:00
|
|
|
case 'CHAT_SEARCH':
|
|
|
|
{
|
|
|
|
this.onShowToggleSearchArea();
|
|
|
|
}
|
|
|
|
break;
|
2019-11-12 09:10:38 +00:00
|
|
|
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':
|
|
|
|
{
|
2020-01-08 03:30:39 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
|
|
|
>(CreateChatDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
data: {
|
|
|
|
type: UserSelectDialogType.EditChatMember,
|
|
|
|
title: this.translateService.instant('chat.modifyRoomMember'),
|
2020-01-17 01:41:22 +00:00
|
|
|
curRoomUser: this.userInfoListSubject.value.filter(
|
|
|
|
user =>
|
|
|
|
user.seq !== this.loginResSubject.value.userSeq &&
|
|
|
|
user.isJoinRoom
|
2020-01-08 03:30:39 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
});
|
2019-11-01 06:53:54 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
if (!!result && !!result.choice && result.choice) {
|
2020-01-16 06:41:18 +00:00
|
|
|
// include me here..
|
2020-01-17 03:28:43 +00:00
|
|
|
const userSeqs: number[] = this.userInfoListSubject.value
|
2020-01-16 06:41:18 +00:00
|
|
|
.filter(userInfo => userInfo.isJoinRoom)
|
|
|
|
.map(userInfo => userInfo.seq);
|
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
if (
|
|
|
|
!!result.selectedUserList &&
|
|
|
|
result.selectedUserList.length > 0
|
|
|
|
) {
|
|
|
|
result.selectedUserList.forEach(user => {
|
|
|
|
if (userSeqs.indexOf(user.seq) < 0) {
|
|
|
|
userSeqs.push(user.seq);
|
2020-01-07 02:36:25 +00:00
|
|
|
}
|
2020-01-08 03:30:39 +00:00
|
|
|
});
|
|
|
|
}
|
2020-01-07 02:36:25 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
if (userSeqs.length > 0) {
|
|
|
|
// include me
|
2020-01-17 01:41:22 +00:00
|
|
|
userSeqs.push(this.loginResSubject.value.userSeq);
|
2020-01-07 02:36:25 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
RoomStore.inviteOrOpen({
|
|
|
|
req: {
|
|
|
|
divCd: 'Invite',
|
|
|
|
userSeqs
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-11-01 06:53:54 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-11-11 01:53:24 +00:00
|
|
|
case 'ADD_GROUP':
|
|
|
|
{
|
2020-01-08 03:30:39 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
SelectGroupDialogComponent,
|
|
|
|
SelectGroupDialogData,
|
|
|
|
SelectGroupDialogResult
|
|
|
|
>(SelectGroupDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
data: {
|
|
|
|
title: this.translateService.instant('chat.addMemberToGroup')
|
|
|
|
}
|
|
|
|
});
|
2019-11-11 01:53:24 +00:00
|
|
|
|
2020-01-08 03:30:39 +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));
|
2020-01-17 01:41:22 +00:00
|
|
|
this.userInfoListSubject.value
|
2020-01-23 01:03:48 +00:00
|
|
|
.filter(v => v.isJoinRoom)
|
2020-01-08 03:30:39 +00:00
|
|
|
.filter(v => result.group.userSeqs.indexOf(v.seq) < 0)
|
|
|
|
.forEach(user => {
|
|
|
|
trgtUserSeq.push(user.seq);
|
|
|
|
});
|
|
|
|
|
|
|
|
this.store.dispatch(
|
|
|
|
SyncStore.updateGroupMember({
|
|
|
|
oldGroup,
|
|
|
|
trgtUserSeq
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-11-11 01:53:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2019-11-06 04:58:56 +00:00
|
|
|
case 'EDIT_ROOM':
|
|
|
|
{
|
2020-01-08 03:30:39 +00:00
|
|
|
const result = await this.dialogService.open<
|
|
|
|
EditChatRoomDialogComponent,
|
|
|
|
EditChatRoomDialogData,
|
|
|
|
EditChatRoomDialogResult
|
|
|
|
>(EditChatRoomDialogComponent, {
|
|
|
|
width: '600px',
|
|
|
|
data: {
|
|
|
|
title: this.translateService.instant('chat.settingsOfRoom'),
|
2020-01-17 01:41:22 +00:00
|
|
|
roomInfo: this.roomInfoSubject.value
|
2020-01-08 03:30:39 +00:00
|
|
|
}
|
|
|
|
});
|
2019-11-06 04:58:56 +00:00
|
|
|
|
2020-01-08 03:30:39 +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;
|
2019-11-06 04:58:56 +00:00
|
|
|
|
2020-01-08 03:30:39 +00:00
|
|
|
// 방제목 업데이트.
|
|
|
|
this.store.dispatch(
|
|
|
|
RoomStore.update({
|
|
|
|
req: {
|
|
|
|
roomSeq: roomInfo.roomSeq,
|
|
|
|
roomName,
|
|
|
|
receiveAlarm: roomInfo.receiveAlarm,
|
|
|
|
syncAll:
|
|
|
|
roomNameChangeTarget.toUpperCase() === 'ALL' ? true : false
|
2020-01-07 02:36:25 +00:00
|
|
|
}
|
2020-01-08 03:30:39 +00:00
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
if (
|
|
|
|
roomInfo.isTimeRoom &&
|
|
|
|
timeRoomInterval > 0 &&
|
|
|
|
roomInfo.timeRoomInterval !== timeRoomInterval
|
|
|
|
) {
|
|
|
|
this.store.dispatch(
|
|
|
|
RoomStore.updateTimeRoomInterval({
|
|
|
|
roomSeq: roomInfo.roomSeq,
|
|
|
|
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
|
|
|
|
2020-01-02 06:58:16 +00:00
|
|
|
onClickOpenProfile(userSeq: number) {
|
2020-01-21 07:36:30 +00:00
|
|
|
const roomType = this.roomInfoSubject.value.roomType;
|
2019-11-08 04:35:39 +00:00
|
|
|
if (
|
2020-01-21 07:36:30 +00:00
|
|
|
roomType !== RoomType.Allim &&
|
|
|
|
roomType !== RoomType.Bot &&
|
|
|
|
roomType !== RoomType.Link &&
|
|
|
|
roomType !== RoomType.Allim_Elephant &&
|
|
|
|
roomType !== RoomType.Allim_TMS
|
2019-11-08 04:35:39 +00:00
|
|
|
) {
|
2020-01-02 06:58:16 +00:00
|
|
|
this.openProfile.emit({ userSeq });
|
2019-11-08 04:35:39 +00:00
|
|
|
}
|
|
|
|
}
|
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-12-15 23:58:33 +00:00
|
|
|
getStickerHistory(): string[] {
|
|
|
|
return this.localStorageService.get<string[]>(KEY_STICKER_HISTORY);
|
|
|
|
}
|
2019-12-23 06:23:27 +00:00
|
|
|
|
|
|
|
/** About Chat Search */
|
|
|
|
onShowToggleSearchArea() {
|
|
|
|
this.isShowSearchArea = !this.isShowSearchArea;
|
|
|
|
|
|
|
|
if (!this.isShowSearchArea) {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.searchedListSubject.next([]);
|
2019-12-23 06:23:27 +00:00
|
|
|
this.searchedFocusEvent = null;
|
|
|
|
this.searchText = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onCloseSearchArea() {
|
|
|
|
this.isShowSearchArea = false;
|
2020-01-17 01:41:22 +00:00
|
|
|
this.searchedListSubject.next([]);
|
2019-12-23 06:23:27 +00:00
|
|
|
this.searchedFocusEvent = null;
|
|
|
|
this.searchText = '';
|
|
|
|
|
|
|
|
this.moreSearchProcessing = false;
|
|
|
|
this.searchTotalCount = 0;
|
|
|
|
this.searchCurrentIndex = 0;
|
|
|
|
|
|
|
|
this.store.dispatch(EventStore.infoForSearchEnd({}));
|
|
|
|
}
|
|
|
|
onSearchChat(searchText: string, baseSeq?: number) {
|
|
|
|
this.searchText = searchText;
|
|
|
|
|
2020-01-07 04:45:34 +00:00
|
|
|
// CASE :: searching text after retrieve All event Infos.
|
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.infoAll({
|
2020-01-17 01:41:22 +00:00
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
|
|
|
baseSeq: this.eventListSubject.value[0].seq,
|
2020-01-07 04:45:34 +00:00
|
|
|
requestCount:
|
|
|
|
environment.productConfig.CommonSetting.eventRequestDefaultCount * 2
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
// this.doSearchTextInEvent(searchText);
|
|
|
|
}
|
|
|
|
doSearchTextInEvent(searchText: string, baseSeq?: number): void {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.searchedListSubject.next(
|
|
|
|
this.eventListSubject.value.filter(event => {
|
|
|
|
let contents = '';
|
|
|
|
if (event.type === EventType.Character) {
|
|
|
|
contents = event.sentMessage;
|
|
|
|
} else if (
|
|
|
|
event.type === EventType.Sticker &&
|
|
|
|
!!event.sentMessageJson
|
|
|
|
) {
|
|
|
|
contents = (event.sentMessageJson as StickerEventJson).chat;
|
|
|
|
} else if (event.type === EventType.File && !!event.sentMessageJson) {
|
|
|
|
contents = (event.sentMessageJson as FileEventJson).fileName;
|
|
|
|
} else if (
|
|
|
|
event.type === EventType.MassText &&
|
|
|
|
!!event.sentMessageJson
|
|
|
|
) {
|
|
|
|
contents = (event.sentMessageJson as MassTextEventJson).content;
|
|
|
|
} else if (
|
|
|
|
(event.type === EventType.Translation ||
|
|
|
|
event.type === EventType.MassTranslation) &&
|
|
|
|
!!event.sentMessageJson
|
|
|
|
) {
|
|
|
|
contents = (event.sentMessageJson as TranslationEventJson).original;
|
|
|
|
contents += (event.sentMessageJson as TranslationEventJson)
|
|
|
|
.translation;
|
|
|
|
}
|
2019-12-23 06:23:27 +00:00
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
return contents.indexOf(searchText) > -1;
|
|
|
|
})
|
|
|
|
);
|
2019-12-23 06:23:27 +00:00
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
if (
|
|
|
|
!!this.searchedListSubject.value &&
|
|
|
|
this.searchedListSubject.value.length > 0
|
|
|
|
) {
|
|
|
|
this.searchTotalCount = this.searchedListSubject.value.length;
|
2019-12-23 06:23:27 +00:00
|
|
|
|
|
|
|
if (!!baseSeq && baseSeq > 0) {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.searchedListSubject.value.forEach((searched, index) => {
|
2019-12-23 06:23:27 +00:00
|
|
|
if (searched.seq <= baseSeq) {
|
|
|
|
this.searchCurrentIndex = index + 1;
|
|
|
|
this.searchedFocusEvent = searched;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.searchCurrentIndex = this.searchedListSubject.value.length;
|
|
|
|
this.searchedFocusEvent = this.searchedListSubject.value[
|
|
|
|
this.searchedListSubject.value.length - 1
|
2019-12-23 06:23:27 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
this.store.dispatch(EventStore.infoForSearchEnd({}));
|
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
this.chatMessages.gotoPosition(this.searchedFocusEvent.seq);
|
2019-12-23 06:23:27 +00:00
|
|
|
} else {
|
|
|
|
this.searchTotalCount = 0;
|
|
|
|
this.searchCurrentIndex = 0;
|
|
|
|
|
|
|
|
this.searchedFocusEvent = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onPrevSearch() {
|
2020-01-17 01:41:22 +00:00
|
|
|
this.searchedListSubject.value.forEach((event, index) => {
|
2019-12-23 06:23:27 +00:00
|
|
|
if (event.seq === this.searchedFocusEvent.seq && index > 0) {
|
|
|
|
this.searchCurrentIndex = this.searchCurrentIndex - 1;
|
2020-01-17 01:41:22 +00:00
|
|
|
this.searchedFocusEvent = this.searchedListSubject.value[index - 1];
|
|
|
|
this.chatMessages.gotoPosition(this.searchedFocusEvent.seq);
|
2019-12-23 06:23:27 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
onNextSearch() {
|
|
|
|
// let exist = false;
|
|
|
|
// this.searchedList.forEach((event, index) => {
|
|
|
|
// if (
|
|
|
|
// event.seq === this.searchedFocusEvent.seq &&
|
|
|
|
// index < this.searchedList.length - 2 &&
|
|
|
|
// !exist
|
|
|
|
// ) {
|
|
|
|
// exist = true;
|
|
|
|
// this.searchCurrentIndex = this.searchCurrentIndex + 1;
|
|
|
|
// this.searchedFocusEvent = this.searchedList[index + 1];
|
|
|
|
// this.goSearchPosition(this.searchedFocusEvent.seq);
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
|
2020-01-17 01:41:22 +00:00
|
|
|
if (this.searchCurrentIndex < this.searchedListSubject.value.length) {
|
|
|
|
this.searchedFocusEvent = this.searchedListSubject.value[
|
|
|
|
this.searchCurrentIndex
|
|
|
|
];
|
2019-12-27 08:45:50 +00:00
|
|
|
this.searchCurrentIndex = this.searchCurrentIndex + 1;
|
2020-01-17 01:41:22 +00:00
|
|
|
this.chatMessages.gotoPosition(this.searchedFocusEvent.seq);
|
2019-12-27 08:45:50 +00:00
|
|
|
}
|
2019-12-23 06:23:27 +00:00
|
|
|
}
|
|
|
|
onSearchAndPrev() {
|
|
|
|
if (
|
|
|
|
!!this.searchText &&
|
|
|
|
this.searchText.trim().length > 0 &&
|
2020-01-17 01:41:22 +00:00
|
|
|
this.eventRemainedSubject.value
|
2019-12-23 06:23:27 +00:00
|
|
|
) {
|
|
|
|
this.moreSearchProcessing = true;
|
2020-01-20 07:40:17 +00:00
|
|
|
this.chatMessages.storeScrollPosition();
|
2019-12-23 06:23:27 +00:00
|
|
|
|
2020-01-07 04:45:34 +00:00
|
|
|
// Case :: retrieve event infos step by step until include searchtext in event..
|
2019-12-23 06:23:27 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.infoForSearch({
|
|
|
|
req: {
|
2020-01-17 01:41:22 +00:00
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
|
|
|
baseSeq: this.eventListSubject.value[0].seq,
|
2019-12-23 06:23:27 +00:00
|
|
|
requestCount:
|
|
|
|
environment.productConfig.CommonSetting.eventRequestDefaultCount
|
|
|
|
},
|
|
|
|
searchText: this.searchText
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-12-31 05:36:32 +00:00
|
|
|
|
|
|
|
/** About Translation */
|
|
|
|
onShowToggleTranslation() {
|
|
|
|
this.isShowTranslation = !this.isShowTranslation;
|
|
|
|
if (!this.isShowTranslation) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
onChangeTranslationSimpleView(value: boolean) {
|
|
|
|
this.translationSimpleview = value;
|
|
|
|
}
|
|
|
|
onChangeTranslationPreView(value: boolean) {
|
|
|
|
this.translationPreview = value;
|
|
|
|
}
|
|
|
|
onChangeDestLocale(destLocale: string) {
|
|
|
|
this.destLocale = destLocale;
|
|
|
|
}
|
|
|
|
onCancelTranslation() {
|
2019-12-31 08:02:04 +00:00
|
|
|
this.isTranslationProcess = false;
|
2019-12-31 05:36:32 +00:00
|
|
|
this.translationPreviewInfo = null;
|
|
|
|
}
|
2019-12-31 07:10:24 +00:00
|
|
|
onSendTranslationMessage(params: {
|
|
|
|
previewInfo: TranslationSaveResponse | null;
|
|
|
|
translationType: EventType.Translation | EventType.MassTranslation;
|
|
|
|
}) {
|
|
|
|
let sentMessage = '';
|
|
|
|
if (params.translationType === EventType.MassTranslation) {
|
|
|
|
// Mass Text Translation
|
|
|
|
sentMessage = params.previewInfo.returnJson;
|
|
|
|
} else {
|
|
|
|
// Normal Text Translation
|
|
|
|
sentMessage = JSON.stringify({
|
|
|
|
locale: params.previewInfo.destLocale,
|
|
|
|
original: params.previewInfo.original,
|
|
|
|
translation: params.previewInfo.translation,
|
|
|
|
stickername: '',
|
|
|
|
stickerfile: !!this.selectedSticker ? this.selectedSticker.index : ''
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-12-31 05:36:32 +00:00
|
|
|
this.store.dispatch(
|
|
|
|
EventStore.send({
|
2020-01-17 01:41:22 +00:00
|
|
|
senderSeq: this.loginResSubject.value.userSeq,
|
2019-12-31 05:36:32 +00:00
|
|
|
req: {
|
2020-01-17 01:41:22 +00:00
|
|
|
roomSeq: this.roomInfoSubject.value.roomSeq,
|
2019-12-31 07:10:24 +00:00
|
|
|
eventType: params.translationType,
|
|
|
|
sentMessage
|
2019-12-31 05:36:32 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2019-12-31 08:02:04 +00:00
|
|
|
this.isTranslationProcess = false;
|
2019-12-31 05:36:32 +00:00
|
|
|
this.translationPreviewInfo = null;
|
|
|
|
}
|
2019-09-23 05:23:24 +00:00
|
|
|
}
|