feat: Rename ocr-text asset type to text-content across the application
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user