Start implementing direct messaging and continued developing the chatnav
This commit is contained in:
56
src/app/chat/dm/dm.ts
Normal file
56
src/app/chat/dm/dm.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import {Component, inject, OnInit} from '@angular/core';
|
||||
import {DmStorage, ServiceManager} from '../../service-manager';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {DMService} from '@chatenium/chatenium-sdk/services/dmService';
|
||||
import {IndexedDB} from '../../storage/indexed-db';
|
||||
import {Navbar} from '../elements/navbar/navbar';
|
||||
import {Oimg} from '../elements/oimg/oimg';
|
||||
import {TuiButton, TuiIcon} from '@taiga-ui/core';
|
||||
import {MessageBox} from '../elements/message-box/message-box';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dm',
|
||||
imports: [
|
||||
Navbar,
|
||||
Oimg,
|
||||
TuiButton,
|
||||
TuiIcon,
|
||||
MessageBox
|
||||
],
|
||||
templateUrl: './dm.html',
|
||||
styleUrl: './dm.scss',
|
||||
})
|
||||
export class Dm implements OnInit {
|
||||
serviceManager = inject(ServiceManager)
|
||||
route = inject(ActivatedRoute)
|
||||
indexedDb = inject(IndexedDB)
|
||||
|
||||
chatid = ""
|
||||
|
||||
get store(): DmStorage {
|
||||
return this.serviceManager.dmServices()[this.chatid]
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.route.params.subscribe(params => {
|
||||
const chatid = params['chatid']
|
||||
this.chatid = chatid
|
||||
console.log(this.serviceManager.chats())
|
||||
const session = this.serviceManager.currentSession();
|
||||
const chatData = this.serviceManager.chats().find(chat => chat.chatid == chatid)
|
||||
|
||||
if (!this.serviceManager.dmServices()[chatid] && session != null && chatData != null) {
|
||||
this.serviceManager.dmServices()[chatid] = {
|
||||
service: new DMService(
|
||||
session.userData.userid,
|
||||
session.token,
|
||||
chatid,
|
||||
this.indexedDb.getApi(),
|
||||
() => {}
|
||||
),
|
||||
chatData: chatData
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user