Create Kaleido Desktop, a cinematic Plex client for Windows

Tauri 2 shell with a React/TypeScript interface and libmpv playback composed
beneath the web view (DirectComposition on Windows). Shared code with per-OS
platform modules and configs so macOS and Linux can follow.

- Plex sign-in (browser, plex.tv/link or manual), server selection, Plex Home
- Home, Movies and TV Shows (Discover, Library, Collections), search, people
- Title pages with logos, ratings, cast, extras, seasons and episodes
- Direct play with Plex conversion fallback, tracks, markers, autoplay
- Metadata editing, artwork, fix match, refresh, analyze and deletion
- Resumable offline downloads
- App settings and Plex server administration with a live dashboard
- Signed updater feed and Forgejo CI

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Elijah 2026-10-30 16:26:37 -07:00
commit 00d72e70f4
121 changed files with 25315 additions and 0 deletions

53
src/app/queries.ts Normal file
View file

@ -0,0 +1,53 @@
import { QueryClient, useQuery, type UseQueryOptions } from '@tanstack/react-query';
import * as api from '../plex/api';
import type { Item, Section } from '../plex/types';
import { useServer } from './session';
import { useSettings } from './settings';
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 60_000,
gcTime: 30 * 60_000,
retry: 1,
refetchOnWindowFocus: false,
},
},
});
/** Every key starts with the server so switching servers never mixes caches. */
export function useKey(...parts: unknown[]) {
const server = useServer();
return [server.machineId, ...parts];
}
export function useServerQuery<T>(parts: unknown[], fn: (s: ReturnType<typeof useServer>) => Promise<T>, opts: Partial<UseQueryOptions<T>> = {}) {
const server = useServer();
return useQuery<T>({ queryKey: [server.machineId, ...parts], queryFn: () => fn(server), ...opts } as UseQueryOptions<T>);
}
export const useSections = () => useServerQuery(['sections'], (s) => api.sections(s), { staleTime: 5 * 60_000 });
/** The library a Movies or TV destination shows: the user's choice, else the first. */
export function useSectionFor(kind: 'movie' | 'show'): { section: Section | null; all: Section[]; loading: boolean } {
const { data, isLoading } = useSections();
const chosen = useSettings((s) => (kind === 'movie' ? s.movieSection : s.showSection));
const all = (data ?? []).filter((s) => s.type === kind && !s.hidden);
return { section: all.find((s) => s.id === chosen) ?? all[0] ?? null, all, loading: isLoading };
}
export const useItem = (id: string | undefined, opts: Partial<UseQueryOptions<Item>> = {}) =>
useServerQuery(['item', id], (s) => api.metadata(s, id!), { enabled: !!id, staleTime: 30_000, ...opts });
export const useChildren = (id: string | undefined) => useServerQuery(['children', id], (s) => api.children(s, id!), { enabled: !!id, staleTime: 30_000 });
export const useRelated = (id: string | undefined) => useServerQuery(['related', id], (s) => api.related(s, id!), { enabled: !!id, staleTime: 10 * 60_000 });
/** After a watched-state or metadata change, refresh everything that may show it. */
export function invalidateLibrary() {
queryClient.invalidateQueries({ predicate: (q) => !['sections', 'libraryMeta', 'filterOptions', 'serverPrefs'].includes(String(q.queryKey[1])) });
}
export function invalidateItem(id: string) {
queryClient.invalidateQueries({ predicate: (q) => q.queryKey.includes(id) });
}