diff options
| author | Fuwn <[email protected]> | 2026-02-08 00:06:53 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-08 00:06:53 -0800 |
| commit | 2f3acb221af8cac85d3653ce8e7c7c30eb73ea77 (patch) | |
| tree | 92ceab132fb4b6583cfaff46f5ac1adaed0a7d9e /apps/web/lib | |
| parent | fix: enforce same-origin on all service worker cache routes (diff) | |
| download | asa.news-2f3acb221af8cac85d3653ce8e7c7c30eb73ea77.tar.xz asa.news-2f3acb221af8cac85d3653ce8e7c7c30eb73ea77.zip | |
feat: display folders above ungrouped feeds in sidebar, add delete-all-custom-feeds to danger zone
Diffstat (limited to 'apps/web/lib')
| -rw-r--r-- | apps/web/lib/queries/use-custom-feed-mutations.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/apps/web/lib/queries/use-custom-feed-mutations.ts b/apps/web/lib/queries/use-custom-feed-mutations.ts index 0afa19c..66c2a19 100644 --- a/apps/web/lib/queries/use-custom-feed-mutations.ts +++ b/apps/web/lib/queries/use-custom-feed-mutations.ts @@ -98,6 +98,36 @@ export function useUpdateCustomFeed() { }) } +export function useDeleteAllCustomFeeds() { + const supabaseClient = createSupabaseBrowserClient() + const queryClient = useQueryClient() + + return useMutation({ + mutationFn: async () => { + const { + data: { user }, + } = await supabaseClient.auth.getUser() + + if (!user) throw new Error("not authenticated") + + const { error } = await supabaseClient + .from("custom_feeds") + .delete() + .eq("user_id", user.id) + + if (error) throw error + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: queryKeys.customFeeds.all }) + queryClient.invalidateQueries({ queryKey: queryKeys.userProfile.all }) + notify("all custom feeds deleted") + }, + onError: (error: Error) => { + notify("failed to delete custom feeds: " + error.message) + }, + }) +} + export function useDeleteCustomFeed() { const supabaseClient = createSupabaseBrowserClient() const queryClient = useQueryClient() |