Created
October 7, 2022 12:00
-
-
Save hieptlccc/36c38826ee33f5165b4929a1b8d4d566 to your computer and use it in GitHub Desktop.
1 on 1 Angular Chat - chat.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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