First commit
This commit is contained in:
35
src/app/chat/dm-list/dm-list.ts
Normal file
35
src/app/chat/dm-list/dm-list.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {Component, inject, input, OnInit, signal} from '@angular/core';
|
||||
import {ChatService} from '@chatenium/chatenium-sdk/services/chatService';
|
||||
import {IndexedDB} from '../../storage/indexed-db';
|
||||
import {Chat} from '@chatenium/chatenium-sdk/domain/chatService.schema';
|
||||
import {JsonPipe} from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dm-list',
|
||||
imports: [
|
||||
JsonPipe
|
||||
],
|
||||
templateUrl: './dm-list.html',
|
||||
styleUrl: './dm-list.scss',
|
||||
})
|
||||
export class DmList implements OnInit {
|
||||
userid = input<string>("")
|
||||
token = input<string>("")
|
||||
|
||||
indexedDb = inject(IndexedDB)
|
||||
|
||||
service: ChatService | null = null
|
||||
chats = signal<Chat[]>([])
|
||||
chatsStatus = 0
|
||||
|
||||
async ngOnInit() {
|
||||
this.service = new ChatService(this.userid(), this.token(), this.indexedDb.getApi(), () => {})
|
||||
try {
|
||||
this.chats.set(await this.service.get())
|
||||
this.chatsStatus = 1
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
this.chatsStatus = 2
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user