feat: Rename ocr-text asset type to text-content across the application

This commit is contained in:
2025-11-30 03:24:24 +01:00
parent 45bdc7ed8e
commit 6519345414
11 changed files with 42 additions and 38 deletions
+8 -8
View File
@@ -1,4 +1,4 @@
import { openOcrTextInNewTab } from '../utils/ocr';
import { openTextContentInNewTab } from '../utils/ocr';
import type {
EnsureAssetUrl,
EnsurePreviewData,
@@ -21,11 +21,11 @@ const resolveDocumentDownloadHref = (document?: Document | null): string | null
return downloadUrl;
};
const hasDocumentOcrAsset = (document?: Document | null, getDocumentAsset?: GetDocumentAsset | null): boolean => {
const hasDocumentTextContentAsset = (document?: Document | null, getDocumentAsset?: GetDocumentAsset | null): boolean => {
if (!document || !getDocumentAsset) {
return false;
}
return Boolean(getDocumentAsset(document, 'ocr-text'));
return Boolean(getDocumentAsset(document, 'text-content'));
};
interface CreateDocumentActionStateArgs {
@@ -43,7 +43,7 @@ export const createDocumentActionState = ({
ensureAssetUrl,
getDocumentAsset,
notifyApiError,
ocrErrorMessage = 'Unable to open OCR text.',
ocrErrorMessage = 'Unable to open text content.',
}: CreateDocumentActionStateArgs) => {
if (!document) {
return {
@@ -54,19 +54,19 @@ export const createDocumentActionState = ({
}
const downloadHref = resolveDocumentDownloadHref(document);
const hasOcr = hasDocumentOcrAsset(document, getDocumentAsset);
const hasOcr = hasDocumentTextContentAsset(document, getDocumentAsset);
const openOcr = hasOcr
? async () => {
try {
const success = await openOcrTextInNewTab({
const success = await openTextContentInNewTab({
document,
ensurePreviewData,
getDocumentAsset,
ensureAssetUrl,
});
if (!success) {
notifyApiError?.(new Error('OCR text URL unavailable.'), ocrErrorMessage);
notifyApiError?.(new Error('Text content URL unavailable.'), ocrErrorMessage);
}
return success;
} catch (error) {
@@ -85,5 +85,5 @@ export const createDocumentActionState = ({
export const documentActionsTestExports = {
resolveDocumentDownloadHref,
hasDocumentOcrAsset,
hasDocumentTextContentAsset,
};