feat: sse for volume status change

This commit is contained in:
Nicolas Meienberger
2025-11-08 11:07:09 +01:00
parent fd3a527164
commit 11dd6f46c8
6 changed files with 23 additions and 6 deletions

View File

@@ -15,7 +15,6 @@ interface FileEntry {
type VolumeFileBrowserProps = {
volumeName: string;
enabled?: boolean;
refetchInterval?: number | false;
withCheckboxes?: boolean;
selectedPaths?: Set<string>;
onSelectionChange?: (paths: Set<string>) => void;
@@ -28,7 +27,6 @@ type VolumeFileBrowserProps = {
export const VolumeFileBrowser = ({
volumeName,
enabled = true,
refetchInterval,
withCheckboxes = false,
selectedPaths,
onSelectionChange,
@@ -46,7 +44,6 @@ export const VolumeFileBrowser = ({
const { data, isLoading, error } = useQuery({
...listFilesOptions({ path: { name: volumeName } }),
enabled,
refetchInterval,
});
useMemo(() => {

View File

@@ -92,6 +92,17 @@ export function useServerEvents() {
});
});
eventSource.addEventListener("volume:status_updated", (e) => {
const data = JSON.parse(e.data) as VolumeEvent;
console.log("[SSE] Volume status updated:", data);
queryClient.invalidateQueries();
handlersRef.current.get("volume:updated")?.forEach((handler) => {
handler(data);
});
});
eventSource.onerror = (error) => {
console.error("[SSE] Connection error:", error);
};

View File

@@ -30,7 +30,6 @@ export const FilesTabContent = ({ volume }: Props) => {
<VolumeFileBrowser
volumeName={volume.name}
enabled={volume.status === "mounted"}
refetchInterval={10000}
className="overflow-auto flex-1 border rounded-md bg-card p-2"
emptyMessage="This volume is empty."
emptyDescription="Files and folders will appear here once you add them."