feat(media): implement caching for chat media and update components to use cached media
This commit is contained in:
@@ -32,13 +32,34 @@ export interface LocalMessageRow {
|
||||
sessionId: string;
|
||||
}
|
||||
|
||||
export type LocalChatMediaKind = "image" | "audio";
|
||||
|
||||
export interface LocalChatMediaRow {
|
||||
cacheKey: string;
|
||||
ownerKey: string;
|
||||
messageId: string;
|
||||
kind: LocalChatMediaKind;
|
||||
remoteUrl: string;
|
||||
blob: Blob;
|
||||
mimeType: string;
|
||||
byteSize: number;
|
||||
createdAt: number;
|
||||
updatedAt: number;
|
||||
lastAccessedAt: number;
|
||||
}
|
||||
|
||||
export class LocalChatDB extends Dexie {
|
||||
messages!: Table<LocalMessageRow, number>;
|
||||
media!: Table<LocalChatMediaRow, string>;
|
||||
|
||||
constructor(dbName: string = "cozsweet-chat") {
|
||||
super(dbName);
|
||||
this.version(1).stores({
|
||||
messages: "++dbId",
|
||||
});
|
||||
this.version(2).stores({
|
||||
messages: "++dbId",
|
||||
media: "cacheKey, ownerKey, messageId, kind, remoteUrl, updatedAt, lastAccessedAt",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user