Files
spacedrive/packages/interface/src/hooks/useAdapterIcons.ts
James Pine 907ab4e267 Add archive sources UI with full Rust integration
- Create core/src/data/ module with SourceManager wrapping sd-archive Engine
- Add Sources to GroupType and Source to ItemType enums
- Add default Sources group to new library creation
- Register source operations: create, list, get, delete, sync, list_items
- Register adapter operations: list, config, update
- Add bundled adapter sync from workspace adapters/ directory
- Add adapter update system with BLAKE3 change detection and backup/rollback
- Frontend: Sources home, source detail with virtualized list, adapters screen
- Frontend: SourcesGroup sidebar, SpaceGroup dispatch, spaceItemUtils
- Frontend: TopBar integration (path bar, search, sync, actions menu)
- Frontend: Tab title sync, adapter icon lookup hook
- Regenerate TypeScript types

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 03:24:53 -07:00

24 lines
576 B
TypeScript

import { useLibraryQuery } from "../contexts/SpacedriveContext";
import { useCallback } from "react";
/**
* Hook that provides adapter icon lookup by adapter ID.
* Fetches the adapters list once and caches via React Query.
*/
export function useAdapterIcons() {
const { data: adapters } = useLibraryQuery({
type: "adapters.list",
input: {},
});
const getIcon = useCallback(
(adapterId: string): string | null => {
if (!adapters) return null;
return adapters.find((a) => a.id === adapterId)?.icon_svg ?? null;
},
[adapters],
);
return { getIcon };
}