feat: poll in-flight requests on native + refresh after submit (#369)
Native RequestsViewModel gains poll-while-approved (silent reloads, paused when nothing in-flight) for parity with the web auto-poll, and the SSE collector now reloads silently instead of flashing the loading spinner. Web discover submit invalidates qk.myRequests() so a new request appears on /requests immediately.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
import { pageTitle } from '$lib/branding';
|
||||
import { createLidarrSearchQuery } from '$lib/api/lidarr';
|
||||
import { createRequest } from '$lib/api/requests';
|
||||
import { qk } from '$lib/api/queries';
|
||||
import { useQueryClient } from '@tanstack/svelte-query';
|
||||
import DiscoverResultCard from '$lib/components/DiscoverResultCard.svelte';
|
||||
import DiscoverTabs from '$lib/components/DiscoverTabs.svelte';
|
||||
import ApiErrorBanner from '$lib/components/ApiErrorBanner.svelte';
|
||||
@@ -12,6 +14,8 @@
|
||||
LidarrSearchResult
|
||||
} from '$lib/api/types';
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
// Local input is the source of truth for the discover query — Shell's global
|
||||
// SearchInput targets /search, not /discover. We debounce by 250ms before
|
||||
// pushing into `debouncedQ`, which is what the query factory observes.
|
||||
@@ -87,6 +91,8 @@
|
||||
const next = new Set(optimisticRequested);
|
||||
next.add(r.mbid);
|
||||
optimisticRequested = next;
|
||||
// Surface the new request on /requests right away (+ start its poll) (#369).
|
||||
queryClient.invalidateQueries({ queryKey: qk.myRequests() });
|
||||
} catch {
|
||||
// Swallow for v1: error toasts land in a later UX pass. The card stays
|
||||
// in 'requestable' so the user can retry.
|
||||
|
||||
Reference in New Issue
Block a user