download url

This commit is contained in:
2025-11-22 00:28:11 +01:00
parent dd7dae5f9d
commit c50372af06
6 changed files with 35 additions and 51 deletions
+4 -4
View File
@@ -13,14 +13,14 @@ export type DocumentLike = OcrDocumentLike;
const asyncFalse = async () => false;
const resolveDocumentDownloadHref = (document?: DocumentLike | null, resolveApiPath?: ResolveApiPath | null): string | null => {
if (!document || !resolveApiPath) {
if (!document) {
return null;
}
const downloadPath = (document.current_version as { download_path?: string | null } | null)?.download_path;
if (!downloadPath) {
const downloadUrl = (document.current_version as { download?: { url: string } | null } | null)?.download?.url;
if (!downloadUrl) {
return null;
}
return resolveApiPath(downloadPath);
return resolveApiPath ? resolveApiPath(downloadUrl) : downloadUrl;
};
const hasDocumentOcrAsset = (document?: DocumentLike | null, getDocumentAsset?: GetDocumentAsset | null): boolean => {