Re-implemented DmStore in V3
This commit is contained in:
@@ -1,17 +1,31 @@
|
|||||||
import { Injectable, signal } from '@angular/core';
|
import { Injectable, signal, WritableSignal } from '@angular/core';
|
||||||
import { Contact } from 'chatenium-sdk-preview';
|
import { MessagesViewModel } from './chat/elements/messages/messages-viewmodel';
|
||||||
|
import { MessageBoxViewModel } from './chat/elements/message-box/message-box-viewmodel';
|
||||||
|
import {WrappedDMHandler, DirectMessagingApi, Contact, Message} from "chatenium-sdk-preview"
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root',
|
providedIn: 'root',
|
||||||
})
|
})
|
||||||
export class CacheService {
|
export class CacheService {
|
||||||
contacts = signal<Contact[]>([])
|
contacts = signal<Contact[]>([]);
|
||||||
contactsState = signal<LoadState>(LoadState.CLEAN_LOADING)
|
contactsState = signal<LoadState>(LoadState.CLEAN_LOADING);
|
||||||
|
|
||||||
|
dms = signal<Record<string, DmStorage>>({});
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LoadState {
|
export enum LoadState {
|
||||||
CLEAN_LOADING,
|
CLEAN_LOADING,
|
||||||
CACHE_UPDATING,
|
CACHE_UPDATING,
|
||||||
LOADED,
|
LOADED,
|
||||||
ERROR
|
ERROR,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface DmStorage {
|
||||||
|
handler: WrappedDMHandler<DirectMessagingApi>;
|
||||||
|
messages: WritableSignal<Message[]>;
|
||||||
|
messagesState: WritableSignal<LoadState>;
|
||||||
|
messagesVm: MessagesViewModel;
|
||||||
|
chatData: WritableSignal<Contact>;
|
||||||
|
messageBox: MessageBoxViewModel;
|
||||||
|
wsListener: (action: string, message: string) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user