messge status

This commit is contained in:
Peter Maquiran
2024-06-11 08:37:52 +01:00
parent 1bfe617bfd
commit f3232c835d
3 changed files with 24 additions and 12 deletions
@@ -1,13 +1,8 @@
import { Injectable } from '@angular/core';
import { AddMemberToRoomInputDTO } from '../../dto/room/addMemberToRoomInputDto';
import { RoomListOutPutDTO } from '../../dto/room/roomListOutputDTO';
import { Dexie, EntityTable, liveQuery } from 'Dexie';
import { err, ok } from 'neverthrow';
import { Observable } from 'rxjs';
import { RoomOutPutDTO } from '../../dto/room/roomOutputDTO';
import { z } from 'zod';
import { MessageInputDTO } from '../../dto/message/messageInputDtO';
import { SessionStore } from 'src/app/store/session.service';
const tableSchema = z.object({
@@ -24,10 +19,12 @@ const tableSchema = z.object({
wxUserId: z.number(),
wxFullName: z.string(),
wxeMail: z.string(),
userPhoto: z.string()
})
userPhoto: z.string(),
}),
sending: z.boolean().optional()
})
export type TableMessage = z.infer<typeof tableSchema>
// Database declaration (move this to its own module also)
@@ -49,6 +46,20 @@ export class MessageLocalDataSourceService {
constructor() {}
async sendMessage(data: MessageInputDTO) {
(data as TableMessage).sending = true
try {
const result = await messageDataSource.message.add(data)
return ok(result as string)
} catch (e) {
return err(false)
}
}
async createMessage(data: MessageInputDTO) {
try {
@@ -62,7 +73,7 @@ export class MessageLocalDataSourceService {
}
async update(data: TableMessage) {
async update(data: TableMessage ) {
try {
const result = await messageDataSource.message.update(data.id, data)