2019-10-18 00:48:38 +00:00
|
|
|
import { UserSelectDialogType } from './../../../types/userselect.dialog.type';
|
2019-09-23 05:23:24 +00:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2019-10-16 08:46:53 +00:00
|
|
|
import { NGXLogger } from 'ngx-logger';
|
|
|
|
import { ucapAnimations, DialogService } from '@ucap-webmessenger/ui';
|
|
|
|
import {
|
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
2019-10-17 00:18:55 +00:00
|
|
|
} from '@app/layouts/messenger/dialogs/chat/create-chat.dialog.component';
|
2019-10-17 06:06:38 +00:00
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
import { Store, select } from '@ngrx/store';
|
|
|
|
|
|
|
|
import * as AppStore from '@app/store';
|
2019-10-17 09:05:44 +00:00
|
|
|
import * as ChatStore from '@app/store/messenger/chat';
|
2019-09-23 05:23:24 +00:00
|
|
|
|
|
|
|
@Component({
|
2019-09-26 02:11:22 +00:00
|
|
|
selector: 'app-layout-messenger-left-side',
|
|
|
|
templateUrl: './left-side.component.html',
|
|
|
|
styleUrls: ['./left-side.component.scss'],
|
2019-09-23 05:23:24 +00:00
|
|
|
animations: ucapAnimations
|
|
|
|
})
|
2019-09-26 02:11:22 +00:00
|
|
|
export class LeftSideComponent implements OnInit {
|
2019-10-17 06:06:38 +00:00
|
|
|
badgeChatUnReadCount$: Observable<number>;
|
|
|
|
|
2019-10-16 08:46:53 +00:00
|
|
|
constructor(
|
2019-10-17 06:06:38 +00:00
|
|
|
private store: Store<any>,
|
2019-10-16 08:46:53 +00:00
|
|
|
private dialogService: DialogService,
|
|
|
|
private logger: NGXLogger
|
|
|
|
) {}
|
2019-09-23 05:23:24 +00:00
|
|
|
|
2019-10-17 06:06:38 +00:00
|
|
|
ngOnInit() {
|
|
|
|
this.badgeChatUnReadCount$ = this.store.pipe(
|
|
|
|
select(AppStore.MessengerSelector.SyncSelector.selectChatUnreadCount)
|
|
|
|
);
|
|
|
|
}
|
2019-10-16 08:46:53 +00:00
|
|
|
|
|
|
|
async onClickNewChat() {
|
|
|
|
const result = await this.dialogService.open<
|
|
|
|
CreateChatDialogComponent,
|
|
|
|
CreateChatDialogData,
|
|
|
|
CreateChatDialogResult
|
|
|
|
>(CreateChatDialogComponent, {
|
2019-10-18 00:48:38 +00:00
|
|
|
width: '600px',
|
2019-10-16 08:46:53 +00:00
|
|
|
height: '500px',
|
|
|
|
data: {
|
2019-10-18 00:48:38 +00:00
|
|
|
type: UserSelectDialogType.NewChat,
|
2019-10-16 08:46:53 +00:00
|
|
|
title: 'New Chat'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2019-10-17 09:05:44 +00:00
|
|
|
if (!!result && !!result.choice && result.choice) {
|
|
|
|
if (!!result.selectedUserList && result.selectedUserList.length > 0) {
|
|
|
|
const userSeqs: number[] = [];
|
|
|
|
result.selectedUserList.map(user => userSeqs.push(user.seq));
|
2019-10-16 08:46:53 +00:00
|
|
|
|
2019-10-17 09:05:44 +00:00
|
|
|
this.store.dispatch(ChatStore.openRoom({ userSeqList: userSeqs }));
|
|
|
|
}
|
|
|
|
}
|
2019-10-16 08:46:53 +00:00
|
|
|
}
|
2019-09-23 05:23:24 +00:00
|
|
|
}
|