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";
|
import { cacheKeys } from "@/lib/query-client/cache-keys";
|
||||||
|
|
||||||
export const activeSearchSpaceIdAtom = atom<string | null>(null);
|
export const activeSearchSpaceIdAtom = atom<string | null>(null);
|
||||||
|
export const activeWorkspaceIdAtom = activeSearchSpaceIdAtom;
|
||||||
|
|
||||||
export const searchSpacesQueryParamsAtom = atom<GetSearchSpacesRequest["queryParams"]>({
|
export const searchSpacesQueryParamsAtom = atom<GetSearchSpacesRequest["queryParams"]>({
|
||||||
skip: 0,
|
skip: 0,
|
||||||
|
|
|
||||||
|
|
@ -118,40 +118,37 @@ const UserTextPart: FC = () => {
|
||||||
if (segment.type === "text") {
|
if (segment.type === "text") {
|
||||||
return <span key={`txt-${segment.start}`}>{segment.value}</span>;
|
return <span key={`txt-${segment.start}`}>{segment.value}</span>;
|
||||||
}
|
}
|
||||||
const isFolder = segment.doc.kind === "folder";
|
const doc = segment.doc;
|
||||||
const isConnector = segment.doc.kind === "connector";
|
const icon =
|
||||||
const isThread = segment.doc.kind === "thread";
|
doc.kind === "folder" ? (
|
||||||
const icon = isFolder ? (
|
<FolderIcon className="size-3.5" />
|
||||||
<FolderIcon className="size-3.5" />
|
) : doc.kind === "thread" ? (
|
||||||
) : isThread ? (
|
<MessageSquare className="size-3.5" />
|
||||||
<MessageSquare className="size-3.5" />
|
) : doc.kind === "connector" ? (
|
||||||
) : isConnector ? (
|
(getConnectorIcon(doc.connector_type, "size-3.5") ?? <Plug className="size-3.5" />)
|
||||||
(getConnectorIcon(segment.doc.connector_type, "size-3.5") ?? (
|
) : (
|
||||||
<Plug className="size-3.5" />
|
getConnectorIcon(doc.document_type ?? "UNKNOWN", "size-3.5")
|
||||||
))
|
);
|
||||||
) : (
|
|
||||||
getConnectorIcon(segment.doc.document_type ?? "UNKNOWN", "size-3.5")
|
|
||||||
);
|
|
||||||
return (
|
return (
|
||||||
<MentionChip
|
<MentionChip
|
||||||
key={`mention-${getMentionDocKey(segment.doc)}-${segment.start}`}
|
key={`mention-${getMentionDocKey(doc)}-${segment.start}`}
|
||||||
icon={icon}
|
icon={icon}
|
||||||
label={segment.doc.title}
|
label={doc.title}
|
||||||
tooltip={
|
tooltip={
|
||||||
isFolder
|
doc.kind === "folder"
|
||||||
? `Folder: ${segment.doc.title}`
|
? `Folder: ${doc.title}`
|
||||||
: isThread
|
: doc.kind === "thread"
|
||||||
? `Chat: ${segment.doc.title}`
|
? `Chat: ${doc.title}`
|
||||||
: isConnector
|
: doc.kind === "connector"
|
||||||
? `Connector account: ${segment.doc.title}`
|
? `Connector account: ${doc.title}`
|
||||||
: segment.doc.title
|
: doc.title
|
||||||
}
|
}
|
||||||
onClick={
|
onClick={
|
||||||
isThread
|
doc.kind === "thread"
|
||||||
? () => handleOpenThread(segment.doc.id)
|
? () => handleOpenThread(doc.id)
|
||||||
: isFolder || isConnector
|
: doc.kind === "folder" || doc.kind === "connector"
|
||||||
? undefined
|
? undefined
|
||||||
: () => handleOpenDoc(segment.doc.id, segment.doc.title)
|
: () => handleOpenDoc(doc.id, doc.title)
|
||||||
}
|
}
|
||||||
className="mx-0.5"
|
className="mx-0.5"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue