Skip to content

Instantly share code, notes, and snippets.

@hieptlccc
Created October 7, 2022 12:00
Show Gist options
  • Save hieptlccc/36c38826ee33f5165b4929a1b8d4d566 to your computer and use it in GitHub Desktop.
Save hieptlccc/36c38826ee33f5165b4929a1b8d4d566 to your computer and use it in GitHub Desktop.
1 on 1 Angular Chat - chat.component.ts
import { Component, OnInit } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { Router } from '@angular/router';
import { CometChat } from '@cometchat-pro/chat';
@Component({
selector: 'app-chat',
templateUrl: './chat.component.html',
styleUrls: ['./chat.component.css'],
})
export class ChatComponent implements OnInit {
theme: string = '';
constructor(private auth: AngularFireAuth, private route: Router) {}
ngOnInit(): void {
CometChat.getLoggedinUser()
.then((user: any) => this.theme = `background-color: ${user.metadata.theme};`)
.catch((error) => console.log('error getting details:', { error }));
}
public logOut(): void {
this.auth
.signOut()
.then(() => this.route.navigate(['login']))
.catch((error) => console.log(error.message));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment