fix: add optional chaining to prevent runtime errors in various components

This commit is contained in:
Danny Avila 2025-04-27 01:40:49 -04:00
parent 670f9b8daf
commit bd3f5f1e77
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
5 changed files with 5 additions and 5 deletions

View file

@ -150,7 +150,7 @@ export const a: React.ElementType = memo(({ href, children }: TAnchorProps) => {
return (
<a
href={filepath.startsWith('files/') ? `/api/${filepath}` : `/api/files/${filepath}`}
href={filepath?.startsWith('files/') ? `/api/${filepath}` : `/api/files/${filepath}`}
{...props}
>
{children}

View file

@ -63,7 +63,6 @@ export default function EndpointIcon({
isCreatedByUser={false}
chatGptLabel={undefined}
modelLabel={undefined}
jailbreak={undefined}
/>
);
}

View file

@ -24,7 +24,7 @@ export default function GroupSidePanel({
} & ReturnType<typeof usePromptGroupsNav>) {
const location = useLocation();
const isSmallerScreen = useMediaQuery('(max-width: 1024px)');
const isChatRoute = useMemo(() => location.pathname.startsWith('/c/'), [location.pathname]);
const isChatRoute = useMemo(() => location.pathname?.startsWith('/c/'), [location.pathname]);
return (
<div

View file

@ -8,7 +8,7 @@ export default function PanelFileCell({ row }: { row: Row<TFile | undefined> })
const file = row.original;
return (
<div className="flex w-full items-center gap-2">
{file?.type.startsWith('image') === true ? (
{file?.type?.startsWith('image') === true ? (
<ImagePreview
url={file.filepath}
className="h-10 w-10 flex-shrink-0"

View file

@ -33,7 +33,8 @@ const ModelParameters: React.FC<ModelParametersProps> = ({
const rangeRef = useRef<HTMLInputElement>(null);
const id = `model-parameter-${ariaLabel.toLowerCase().replace(/\s+/g, '-')}`;
const displayLabel = label.startsWith('com_') ? localize(label as TranslationKeys) : label;
const displayLabel =
label && label.startsWith('com_') ? localize(label as TranslationKeys) : label;
const getDecimalPlaces = (num: number) => {
const match = ('' + num).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);