TagSpaces is an offline, open source, document manager with tagging support
chore: small optimizations and logs cleanup
Ilian Sapundshiev1e097586b492
diff --git a/src/main/protocol.ts b/src/main/protocol.tsindex 06e873787..19c25e6a9 100644--- a/src/main/protocol.ts+++ b/src/main/protocol.ts@@ -43,7 +43,7 @@ const initialize = () => {return null;}- protocol.handle(mediaProtocol, (request: any) => {+ protocol.handle(mediaProtocol, async (request: any) => {// Get the file path from the URL without the trailing slashlet filepath = request.url.slice(`${mediaProtocol}://`.length)@@ -53,6 +53,17 @@ const initialize = () => {filepath = filepath.replace(/#/g, '%23');const pathname = normalize(fileURLToPath(`file://${filepath}`)); //pathToFileURL(filepath).toString();const asFileUrl = pathToFileURL(pathname).toString();++ // Pre-check existence: net.fetch on a missing file yields ERR_UNEXPECTED+ // which Chromium logs to the dev console and JS can't intercept. A plain+ // 404 is handled silently by <img> / fetch callers. Common case: missing+ // thumbnail sidecars under .ts/*.jpg.+ try {+ await fs.promises.access(pathname);+ } catch {+ return new Response('', { status: 404 });+ }+console.log('protocol handler: Fetch file param ' +filepath +diff --git a/src/renderer/components/TsIconButton.tsx b/src/renderer/components/TsIconButton.tsxindex 86df163b9..7ae17e85e 100644--- a/src/renderer/components/TsIconButton.tsx+++ b/src/renderer/components/TsIconButton.tsx@@ -20,7 +20,7 @@ import AppConfig from '-/AppConfig';import TooltipTS from '-/components/Tooltip';import { isDesktopMode } from '-/reducers/settings';import IconButton, { IconButtonProps } from '@mui/material/IconButton';-import React, { useMemo } from 'react';+import React from 'react';import { useSelector } from 'react-redux';export type TSIconButtonProps = IconButtonProps & {@@ -28,36 +28,31 @@ export type TSIconButtonProps = IconButtonProps & {keyBinding?: string;};-const TsIconButton: React.FC<TSIconButtonProps> = ({- sx,- keyBinding,- tooltip,- disabled,- ...restProps-}) => {- const desktopMode = useSelector(isDesktopMode);+const TsIconButton = React.forwardRef<HTMLButtonElement, TSIconButtonProps>(+ ({ sx, keyBinding, tooltip, disabled, ...restProps }, ref) => {+ const desktopMode = useSelector(isDesktopMode);- // Memoize the icon button for performance- const iconButton = useMemo(- () => (+ const iconButton = (<IconButton+ ref={ref}size={desktopMode ? 'medium' : 'large'}sx={{ borderRadius: AppConfig.defaultCSSRadius, ...sx }}disabled={disabled}{...restProps}/>- ),- [desktopMode, sx, disabled, restProps],- );-- if (tooltip && !disabled) {- return (- <TooltipTS keyBinding={keyBinding} title={tooltip}>- {iconButton}- </TooltipTS>);- }- return iconButton;-};++ if (tooltip && !disabled) {+ return (+ <TooltipTS keyBinding={keyBinding} title={tooltip}>+ {iconButton}+ </TooltipTS>+ );+ }+ return iconButton;+ },+);++TsIconButton.displayName = 'TsIconButton';export default TsIconButton;