Skip to content

Commit de98814

Browse files
committed
quick nits
1 parent 309eeeb commit de98814

File tree

3 files changed

+1
-108
lines changed

3 files changed

+1
-108
lines changed

web/src/app/chat/message/MemoizedTextComponents.tsx

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,15 @@ import { LoadedOnyxDocument, OnyxDocument } from "@/lib/search/interfaces";
33
import React, { memo } from "react";
44
import isEqual from "lodash/isEqual";
55
import { SourceIcon } from "@/components/SourceIcon";
6-
import { SearchResultIcon } from "@/components/SearchResultIcon";
76
import { WebResultIcon } from "@/components/WebResultIcon";
87

9-
const FALLBACK_ICON = "web.svg";
10-
11-
// Updated error handler
12-
const handleError = (
13-
e: React.SyntheticEvent<HTMLImageElement>,
14-
associatedDoc: OnyxDocument
15-
) => {
16-
// Prevent future error events
17-
e.currentTarget.onerror = null;
18-
19-
// Repoint image source to fallback
20-
e.currentTarget.src = FALLBACK_ICON;
21-
22-
// If you prefer, log fewer times or log once.
23-
// For demonstration, we'll print a single warning:
24-
console.warn(
25-
`Failed to load favicon for document_id=${associatedDoc?.document_id}. Replacing with fallback icon.`
26-
);
27-
};
28-
298
export const MemoizedAnchor = memo(
309
({
3110
docs,
32-
iconMap,
3311
updatePresentingDocument,
3412
children,
3513
}: {
3614
docs?: OnyxDocument[] | null;
37-
iconMap?: Record<string, string>;
3815
updatePresentingDocument: (doc: OnyxDocument) => void;
3916
children: React.ReactNode;
4017
}) => {
@@ -48,26 +25,9 @@ export const MemoizedAnchor = memo(
4825
return <>{children}</>;
4926
}
5027

51-
const effectiveIconURL =
52-
iconMap?.[associatedDoc.document_id] || "globe.svg";
53-
5428
let icon: React.ReactNode = null;
5529
if (associatedDoc.source_type === "web") {
5630
icon = <WebResultIcon url={associatedDoc.link} />;
57-
// (
58-
// <img
59-
// className="!m-0 !p-0 rounded-full"
60-
// height={18}
61-
// onError={(e) => {
62-
// handleError(e, associatedDoc);
63-
// }}
64-
// width={18}
65-
// src={`https://www.google.com/s2/favicons?domain=${
66-
// new URL(associatedDoc.link).hostname
67-
// }`}
68-
// alt="Favicon"
69-
// />
70-
// );
7131
} else {
7232
icon = (
7333
<SourceIcon sourceType={associatedDoc.source_type} iconSize={18} />

web/src/app/chat/message/Messages.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ import SourceCard, {
7272
import remarkMath from "remark-math";
7373
import rehypeKatex from "rehype-katex";
7474
import "katex/dist/katex.min.css";
75-
import { useFaviconPreloader } from "@/hooks/useFaviconPreloader";
7675

7776
const TOOLS_WITH_CUSTOM_HANDLING = [
7877
SEARCH_TOOL_NAME,
@@ -315,20 +314,16 @@ export const AIMessage = ({
315314
[]
316315
);
317316

318-
const { iconMap, handleError } = useFaviconPreloader(docs || []);
319-
320317
const anchorCallback = useCallback(
321318
(props: any) => (
322319
<MemoizedAnchor
323-
handleError={handleError}
324320
updatePresentingDocument={setPresentingDocument!}
325321
docs={docs}
326-
iconMap={iconMap}
327322
>
328323
{props.children}
329324
</MemoizedAnchor>
330325
),
331-
[docs, iconMap]
326+
[docs]
332327
);
333328

334329
const currentMessageInd = messageId

web/src/hooks/useFaviconPreloader.ts

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)