mirror of
https://github.com/richard-loafle/fuse-angular.git
synced 2025-04-16 21:35:13 +00:00
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { ObservableMedia } from '@angular/flex-layout';
|
|
|
|
import { fuseAnimations } from '@fuse/animations';
|
|
import { FuseMatSidenavHelperService } from '@fuse/directives/fuse-mat-sidenav/fuse-mat-sidenav.service';
|
|
|
|
import { ChatService } from '../../../chat.service';
|
|
|
|
@Component({
|
|
selector : 'fuse-chat-chats-sidenav',
|
|
templateUrl: './chats.component.html',
|
|
styleUrls : ['./chats.component.scss'],
|
|
animations : fuseAnimations
|
|
})
|
|
export class FuseChatChatsSidenavComponent implements OnInit
|
|
{
|
|
user: any;
|
|
chats: any[];
|
|
contacts: any[];
|
|
chatSearch: any;
|
|
searchText = '';
|
|
|
|
constructor(
|
|
private chatService: ChatService,
|
|
private fuseMatSidenavService: FuseMatSidenavHelperService,
|
|
public media: ObservableMedia
|
|
)
|
|
{
|
|
this.chatSearch = {
|
|
name: ''
|
|
};
|
|
}
|
|
|
|
ngOnInit()
|
|
{
|
|
this.user = this.chatService.user;
|
|
this.chats = this.chatService.chats;
|
|
this.contacts = this.chatService.contacts;
|
|
|
|
this.chatService.onChatsUpdated.subscribe(updatedChats => {
|
|
this.chats = updatedChats;
|
|
});
|
|
|
|
this.chatService.onUserUpdated.subscribe(updatedUser => {
|
|
this.user = updatedUser;
|
|
});
|
|
}
|
|
|
|
getChat(contact)
|
|
{
|
|
this.chatService.getChat(contact);
|
|
|
|
if ( !this.media.isActive('gt-md') )
|
|
{
|
|
this.fuseMatSidenavService.getSidenav('chat-left-sidenav').toggle();
|
|
}
|
|
}
|
|
|
|
setUserStatus(status)
|
|
{
|
|
this.chatService.setUserStatus(status);
|
|
}
|
|
|
|
changeLeftSidenavView(view)
|
|
{
|
|
this.chatService.onLeftSidenavViewChanged.next(view);
|
|
}
|
|
|
|
logout()
|
|
{
|
|
console.log('logout triggered');
|
|
}
|
|
}
|