diff options
| author | Fuwn <[email protected]> | 2026-02-09 21:12:16 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-09 21:12:16 -0800 |
| commit | 3c0b53ccbe40a75d6105f0e22c43a9f46975d9c1 (patch) | |
| tree | 7289ba4e663ed388f0effc9462d845c9120cc785 /apps/web/lib | |
| parent | fix: elevate to AAL2 before password/email change when MFA is enabled (diff) | |
| download | asa.news-3c0b53ccbe40a75d6105f0e22c43a9f46975d9c1.tar.xz asa.news-3c0b53ccbe40a75d6105f0e22c43a9f46975d9c1.zip | |
feat: add per-feed "hide from timeline" option
Diffstat (limited to 'apps/web/lib')
| -rw-r--r-- | apps/web/lib/queries/use-subscription-mutations.ts | 30 | ||||
| -rw-r--r-- | apps/web/lib/queries/use-subscriptions.ts | 4 | ||||
| -rw-r--r-- | apps/web/lib/types/subscription.ts | 1 |
3 files changed, 34 insertions, 1 deletions
diff --git a/apps/web/lib/queries/use-subscription-mutations.ts b/apps/web/lib/queries/use-subscription-mutations.ts index ca52bd2..1570167 100644 --- a/apps/web/lib/queries/use-subscription-mutations.ts +++ b/apps/web/lib/queries/use-subscription-mutations.ts @@ -5,6 +5,36 @@ import { createSupabaseBrowserClient } from "@/lib/supabase/client" import { queryKeys } from "./query-keys" import { notify } from "@/lib/notify" +export function useUpdateSubscriptionHiddenFromTimeline() { + const supabaseClient = createSupabaseBrowserClient() + const queryClient = useQueryClient() + + return useMutation({ + mutationFn: async ({ + subscriptionIdentifier, + hiddenFromTimeline, + }: { + subscriptionIdentifier: string + hiddenFromTimeline: boolean + }) => { + const { error } = await supabaseClient + .from("subscriptions") + .update({ hidden_from_timeline: hiddenFromTimeline }) + .eq("id", subscriptionIdentifier) + + if (error) throw error + }, + onSuccess: (_data, variables) => { + queryClient.invalidateQueries({ queryKey: queryKeys.subscriptions.all }) + queryClient.invalidateQueries({ queryKey: queryKeys.timeline.all }) + notify(variables.hiddenFromTimeline ? "feed hidden from timeline" : "feed visible in timeline") + }, + onError: (error: Error) => { + notify("failed to update visibility: " + error.message) + }, + }) +} + export function useUpdateSubscriptionTitle() { const supabaseClient = createSupabaseBrowserClient() const queryClient = useQueryClient() diff --git a/apps/web/lib/queries/use-subscriptions.ts b/apps/web/lib/queries/use-subscriptions.ts index 2378411..5dc6076 100644 --- a/apps/web/lib/queries/use-subscriptions.ts +++ b/apps/web/lib/queries/use-subscriptions.ts @@ -11,6 +11,7 @@ interface SubscriptionRow { folder_id: string | null custom_title: string | null position: number + hidden_from_timeline: boolean feeds: { title: string | null url: string @@ -39,7 +40,7 @@ export function useSubscriptions() { const [subscriptionsResult, foldersResult] = await Promise.all([ supabaseClient .from("subscriptions") - .select("id, feed_id, folder_id, custom_title, position, feeds(title, url, visibility, consecutive_failures, last_fetch_error, last_fetched_at, fetch_interval_seconds, feed_type)") + .select("id, feed_id, folder_id, custom_title, position, hidden_from_timeline, feeds(title, url, visibility, consecutive_failures, last_fetch_error, last_fetched_at, fetch_interval_seconds, feed_type)") .order("position", { ascending: true }), supabaseClient .from("folders") @@ -65,6 +66,7 @@ export function useSubscriptions() { fetchIntervalSeconds: row.feeds?.fetch_interval_seconds ?? 3600, feedType: row.feeds?.feed_type ?? null, feedVisibility: row.feeds?.visibility ?? "public", + hiddenFromTimeline: row.hidden_from_timeline, })) const folders: Folder[] = ( diff --git a/apps/web/lib/types/subscription.ts b/apps/web/lib/types/subscription.ts index 0dbc8cb..96f314d 100644 --- a/apps/web/lib/types/subscription.ts +++ b/apps/web/lib/types/subscription.ts @@ -18,4 +18,5 @@ export interface Subscription { fetchIntervalSeconds: number feedType: string | null feedVisibility: "public" | "authenticated" + hiddenFromTimeline: boolean } |