next-ucap-messenger/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/left-side.component.ts

61 lines
1.8 KiB
TypeScript
Raw Normal View History

import { UserSelectDialogType } from './../../../types/userselect.dialog.type';
import { Component, OnInit } from '@angular/core';
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';
import { Observable } from 'rxjs';
import { Store, select } from '@ngrx/store';
import * as AppStore from '@app/store';
import * as ChatStore from '@app/store/messenger/chat';
@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'],
animations: ucapAnimations
})
2019-09-26 02:11:22 +00:00
export class LeftSideComponent implements OnInit {
badgeChatUnReadCount$: Observable<number>;
constructor(
private store: Store<any>,
private dialogService: DialogService,
private logger: NGXLogger
) {}
ngOnInit() {
this.badgeChatUnReadCount$ = this.store.pipe(
select(AppStore.MessengerSelector.SyncSelector.selectChatUnreadCount)
);
}
async onClickNewChat() {
const result = await this.dialogService.open<
CreateChatDialogComponent,
CreateChatDialogData,
CreateChatDialogResult
>(CreateChatDialogComponent, {
width: '600px',
height: '500px',
data: {
type: UserSelectDialogType.NewChat,
title: 'New Chat'
}
});
if (!!result && !!result.choice && result.choice) {
if (!!result.selectedUserList && result.selectedUserList.length > 0) {
const userSeqs: number[] = [];
result.selectedUserList.map(user => userSeqs.push(user.seq));
this.store.dispatch(ChatStore.openRoom({ userSeqList: userSeqs }));
}
}
}
}