mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-08-26 01:02:02 +00:00
- Added `document_id` to artifact listing for improved metadata association. - Introduced `ArtifactFormatIcon` and `ArtifactFormatLabel` components for better visual representation of artifact formats. - Updated various components to utilize new format handling, ensuring consistent display across the application. - Refactored artifact-related schemas and hooks to accommodate new format data. - Enhanced unit tests to cover new functionality and ensure robustness.
15 lines
554 B
TypeScript
15 lines
554 B
TypeScript
"use client";
|
|
|
|
import { useQuery } from "@tanstack/react-query";
|
|
import { useMemo } from "react";
|
|
import { artifactListQueryOptions } from "./artifact-query";
|
|
import type { ArtifactListItem } from "./model";
|
|
|
|
export function useArtifactsByDocument(workspaceId: number): ReadonlyMap<number, ArtifactListItem> {
|
|
const { data = [] } = useQuery({
|
|
...artifactListQueryOptions(workspaceId),
|
|
enabled: Number.isFinite(workspaceId) && workspaceId > 0,
|
|
});
|
|
|
|
return useMemo(() => new Map(data.map((artifact) => [artifact.document_id, artifact])), [data]);
|
|
}
|