This commit is contained in:
2025-11-14 02:35:17 +01:00
parent 6f4ff68062
commit a3c5494bf7
53 changed files with 269 additions and 340 deletions
+8 -10
View File
@@ -157,7 +157,7 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
);
const hasOcr = useMemo(() => {
if (!document || typeof getDocumentAsset !== 'function') {
if (!document || !getDocumentAsset) {
return false;
}
return Boolean(getDocumentAsset(document, 'ocr-text'));
@@ -191,7 +191,7 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
);
const loadOcrContent = useCallback(async ({ signal }: { signal?: AbortSignal } = {}) => {
if (!document || !hasOcr || typeof getDocumentAsset !== 'function') {
if (!document || !hasOcr || !getDocumentAsset) {
return '';
}
@@ -204,7 +204,7 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
const asset = getDocumentAsset(document, 'ocr-text');
let url = updateUrl();
if (!url && document.id && asset?.id && typeof ensureAssetUrl === 'function') {
if (!url && document.id && asset?.id && ensureAssetUrl) {
await ensureAssetUrl(document.id, asset, { start: 1, limit: 1 });
if (signal?.aborted) {
throw new DOMException('Aborted', 'AbortError');
@@ -274,7 +274,7 @@ const DocumentViewerPanel: React.FC<DocumentViewerPanelProps> = ({
}, [previewEntry?.url, document?.id]);
useEffect(() => {
if (typeof hydrateDocument === 'function' && document?.id) {
if (hydrateDocument && document?.id) {
hydrateDocument(document.id);
}
}, [hydrateDocument, document?.id]);
@@ -318,7 +318,7 @@ const panelRef = useRef<HTMLDivElement | HTMLFormElement | HTMLElement | null>(n
);
const breadcrumbs = useMemo(() => {
if (!document || typeof resolveFolderPath !== 'function') {
if (!document || !resolveFolderPath) {
return [];
}
const folderSegments = resolveFolderPath(document.folder_id);
@@ -397,7 +397,7 @@ const panelRef = useRef<HTMLDivElement | HTMLFormElement | HTMLElement | null>(n
canZoom: Boolean(zoomDisplay),
});
const collapseButton = isSidebarVariant && typeof onCollapsePanel === 'function'
const collapseButton = isSidebarVariant && onCollapsePanel
? (
<button
type="button"
@@ -411,7 +411,7 @@ const panelRef = useRef<HTMLDivElement | HTMLFormElement | HTMLElement | null>(n
)
: null;
const maximizeButton = isSidebarVariant && typeof onMaximizePanel === 'function'
const maximizeButton = isSidebarVariant && onMaximizePanel
? (
<button
type="button"
@@ -587,9 +587,7 @@ export const createDocumentViewerSurface = ({
return null;
}
const sidebarToggle = typeof renderSidebarToggle === 'function'
? renderSidebarToggle()
: null;
const sidebarToggle = renderSidebarToggle ? renderSidebarToggle() : null;
return {
key: 'preview',