mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
realtime
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { z } from "zod";
|
||||
import { EntityTable } from 'Dexie';
|
||||
|
||||
export const AttachmentTableSchema = z.object({
|
||||
id: z.string(),
|
||||
$id: z.string(),
|
||||
messageId: z.string(),
|
||||
file: z.string(),
|
||||
})
|
||||
|
||||
export type AttachmentTable = z.infer<typeof AttachmentTableSchema>
|
||||
export type DexieAttachmentsTableSchema = EntityTable<AttachmentTable, '$id'>;
|
||||
export const AttachmentTableColumn = '++$id, id, messageId, file'
|
||||
@@ -1,5 +1,6 @@
|
||||
import { z } from "zod";
|
||||
import { nativeEnum, z } from "zod";
|
||||
import { EntityTable } from 'Dexie';
|
||||
import { MessageAttachmentFileType, MessageAttachmentSource } from "src/app/module/chat/data/dto/message/messageOutputDTO";
|
||||
|
||||
export const MessageTable = z.object({
|
||||
$id: z.number().optional(),
|
||||
@@ -25,7 +26,14 @@ export const MessageTable = z.object({
|
||||
sender: z.object({}),
|
||||
}).array().optional(),
|
||||
info: z.array(z.object({})).optional(),
|
||||
attachments: z.array(z.object({})).optional()
|
||||
attachments: z.array(z.object({
|
||||
fileType: z.nativeEnum(MessageAttachmentFileType),
|
||||
source: z.nativeEnum(MessageAttachmentSource),
|
||||
file: z.string().optional(),
|
||||
fileName: z.string().optional(),
|
||||
applicationId: z.string().optional(),
|
||||
docId: z.string().optional()
|
||||
})).optional()
|
||||
})
|
||||
|
||||
export type MessageTable = z.infer<typeof MessageTable>
|
||||
|
||||
@@ -5,6 +5,7 @@ import { DexieMembersTableSchema, MemberTableColumn } from './schema/members';
|
||||
import { DexieRoomsTableSchema, RoomTableColumn } from './schema/room';
|
||||
import { DexieTypingsTableSchema, TypingTableColumn } from './schema/typing';
|
||||
import { MessageEntity } from '../../../domain/entity/message';
|
||||
import { AttachmentTable, AttachmentTableColumn, DexieAttachmentsTableSchema } from './schema/attachment';
|
||||
// import DexieMemory from 'dexie-in-memory';
|
||||
|
||||
// Database declaration (move this to its own module also)
|
||||
@@ -12,14 +13,16 @@ export const chatDatabase = new Dexie('chat-database-infra') as Dexie & {
|
||||
message: DexieMessageTable,
|
||||
members: DexieMembersTableSchema,
|
||||
room: DexieRoomsTableSchema,
|
||||
typing: DexieTypingsTableSchema
|
||||
typing: DexieTypingsTableSchema,
|
||||
attachment: DexieAttachmentsTableSchema,
|
||||
};
|
||||
|
||||
chatDatabase.version(1).stores({
|
||||
message: messageTableColumn,
|
||||
members: MemberTableColumn,
|
||||
room: RoomTableColumn,
|
||||
typing: TypingTableColumn
|
||||
typing: TypingTableColumn,
|
||||
attachment: AttachmentTableColumn
|
||||
});
|
||||
|
||||
chatDatabase.message.mapToClass(MessageEntity)
|
||||
|
||||
@@ -15,12 +15,12 @@ const { App } = Plugins;
|
||||
const SignalRInputSchema = z.object({
|
||||
method: z.string(),
|
||||
data: z.object({
|
||||
requestId: z.string()
|
||||
})
|
||||
requestId: z.string(),
|
||||
}).catchall(z.unknown()), // Allows any additional properties with unknown values
|
||||
})
|
||||
|
||||
|
||||
export type ISignalRInput = z.infer<typeof SignalRInputSchema>
|
||||
export type ISignalRInput = z.infer<typeof SignalRInputSchema>;
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -92,6 +92,7 @@ export class SignalRService {
|
||||
})
|
||||
|
||||
this.connection.getMessageDelete().subscribe((data) => {
|
||||
console.log('delete middleware', data)
|
||||
this.messageDelete.next(data)
|
||||
})
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ export class SignalRConnection {
|
||||
console.log('DeleteMessage', _message)
|
||||
this.messageDelete.next(_message);
|
||||
this.sendDataSubject.next({
|
||||
method: 'ReceiveMessage',
|
||||
method: 'DeleteMessage',
|
||||
data: _message
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user