fix(chat): make cached media load on safari
This commit is contained in:
@@ -4,6 +4,8 @@ import type { ChatMediaKind } from "@/data/dto/chat";
|
||||
import { getChatRepository } from "@/data/repositories/chat_repository";
|
||||
import { Result, type Result as ResultT } from "@/utils";
|
||||
|
||||
import { localChatMediaRowToBlob } from "./chat_media_blob";
|
||||
|
||||
export interface ResolveCachedChatMediaBlobInput {
|
||||
messageId: string;
|
||||
kind: ChatMediaKind;
|
||||
@@ -19,7 +21,8 @@ export async function resolveCachedChatMediaBlob(
|
||||
): Promise<ResultT<Blob | null>> {
|
||||
const result = await getChatRepository().getCachedMedia(input);
|
||||
if (Result.isErr(result)) return result;
|
||||
return Result.ok(result.data?.blob ?? null);
|
||||
if (!result.data) return Result.ok(null);
|
||||
return Result.ok(localChatMediaRowToBlob(result.data));
|
||||
}
|
||||
|
||||
export async function cacheRemoteChatMediaBlob(
|
||||
@@ -27,5 +30,7 @@ export async function cacheRemoteChatMediaBlob(
|
||||
): Promise<ResultT<Blob>> {
|
||||
const result = await getChatRepository().cacheRemoteMedia(input);
|
||||
if (Result.isErr(result)) return result;
|
||||
return Result.ok(result.data.blob);
|
||||
const blob = localChatMediaRowToBlob(result.data);
|
||||
if (!blob) return Result.err(new Error("Cached media has no readable bytes."));
|
||||
return Result.ok(blob);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user