mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-08 22:22:17 +02:00
feat(search-space): introduce activeWorkspaceIdAtom and refactor user-message component for improved readability
- Added activeWorkspaceIdAtom as a reference to activeSearchSpaceIdAtom. - Refactored the UserTextPart component in user-message.tsx to simplify icon determination and tooltip logic, enhancing code clarity and maintainability.
This commit is contained in:
parent
dec4cd9a0d
commit
e92b7a34ed
2 changed files with 25 additions and 27 deletions
|
|
@ -5,6 +5,7 @@ import { searchSpacesApiService } from "@/lib/apis/search-spaces-api.service";
|
|||
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||
|
||||
export const activeSearchSpaceIdAtom = atom<string | null>(null);
|
||||
export const activeWorkspaceIdAtom = activeSearchSpaceIdAtom;
|
||||
|
||||
export const searchSpacesQueryParamsAtom = atom<GetSearchSpacesRequest["queryParams"]>({
|
||||
skip: 0,
|
||||
|
|
|
|||
|
|
@ -118,40 +118,37 @@ const UserTextPart: FC = () => {
|
|||
if (segment.type === "text") {
|
||||
return <span key={`txt-${segment.start}`}>{segment.value}</span>;
|
||||
}
|
||||
const isFolder = segment.doc.kind === "folder";
|
||||
const isConnector = segment.doc.kind === "connector";
|
||||
const isThread = segment.doc.kind === "thread";
|
||||
const icon = isFolder ? (
|
||||
<FolderIcon className="size-3.5" />
|
||||
) : isThread ? (
|
||||
<MessageSquare className="size-3.5" />
|
||||
) : isConnector ? (
|
||||
(getConnectorIcon(segment.doc.connector_type, "size-3.5") ?? (
|
||||
<Plug className="size-3.5" />
|
||||
))
|
||||
) : (
|
||||
getConnectorIcon(segment.doc.document_type ?? "UNKNOWN", "size-3.5")
|
||||
);
|
||||
const doc = segment.doc;
|
||||
const icon =
|
||||
doc.kind === "folder" ? (
|
||||
<FolderIcon className="size-3.5" />
|
||||
) : doc.kind === "thread" ? (
|
||||
<MessageSquare className="size-3.5" />
|
||||
) : doc.kind === "connector" ? (
|
||||
(getConnectorIcon(doc.connector_type, "size-3.5") ?? <Plug className="size-3.5" />)
|
||||
) : (
|
||||
getConnectorIcon(doc.document_type ?? "UNKNOWN", "size-3.5")
|
||||
);
|
||||
return (
|
||||
<MentionChip
|
||||
key={`mention-${getMentionDocKey(segment.doc)}-${segment.start}`}
|
||||
key={`mention-${getMentionDocKey(doc)}-${segment.start}`}
|
||||
icon={icon}
|
||||
label={segment.doc.title}
|
||||
label={doc.title}
|
||||
tooltip={
|
||||
isFolder
|
||||
? `Folder: ${segment.doc.title}`
|
||||
: isThread
|
||||
? `Chat: ${segment.doc.title}`
|
||||
: isConnector
|
||||
? `Connector account: ${segment.doc.title}`
|
||||
: segment.doc.title
|
||||
doc.kind === "folder"
|
||||
? `Folder: ${doc.title}`
|
||||
: doc.kind === "thread"
|
||||
? `Chat: ${doc.title}`
|
||||
: doc.kind === "connector"
|
||||
? `Connector account: ${doc.title}`
|
||||
: doc.title
|
||||
}
|
||||
onClick={
|
||||
isThread
|
||||
? () => handleOpenThread(segment.doc.id)
|
||||
: isFolder || isConnector
|
||||
doc.kind === "thread"
|
||||
? () => handleOpenThread(doc.id)
|
||||
: doc.kind === "folder" || doc.kind === "connector"
|
||||
? undefined
|
||||
: () => handleOpenDoc(segment.doc.id, segment.doc.title)
|
||||
: () => handleOpenDoc(doc.id, doc.title)
|
||||
}
|
||||
className="mx-0.5"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue