diff options
| author | Fuwn <[email protected]> | 2026-02-12 01:28:18 -0800 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-02-12 01:52:32 -0800 |
| commit | 6d8f7ea8b30e229cc0662db8dc3438828feb6880 (patch) | |
| tree | 9e9270f6f7d6d3cb9c11fb5393eb44e1a44ad418 /apps/web/lib/queries/use-subscription-mutations.ts | |
| parent | fix: invalidate unread counts when toggling individual entry read state (diff) | |
| download | asa.news-6d8f7ea8b30e229cc0662db8dc3438828feb6880.tar.xz asa.news-6d8f7ea8b30e229cc0662db8dc3438828feb6880.zip | |
feat: add drag-and-drop reordering for feeds, folders, and custom feeds
Diffstat (limited to 'apps/web/lib/queries/use-subscription-mutations.ts')
| -rw-r--r-- | apps/web/lib/queries/use-subscription-mutations.ts | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/apps/web/lib/queries/use-subscription-mutations.ts b/apps/web/lib/queries/use-subscription-mutations.ts index 1570167..df4fe32 100644 --- a/apps/web/lib/queries/use-subscription-mutations.ts +++ b/apps/web/lib/queries/use-subscription-mutations.ts @@ -80,9 +80,24 @@ export function useMoveSubscriptionToFolder() { sourceFolderName?: string folderName?: string }) => { + let query = supabaseClient + .from("subscriptions") + .select("position") + .order("position", { ascending: false }) + .limit(1) + + if (folderIdentifier) { + query = query.eq("folder_id", folderIdentifier) + } else { + query = query.is("folder_id", null) + } + + const { data: maxRow } = await query.maybeSingle() + const nextPosition = (maxRow?.position ?? 0) + 1000 + const { error } = await supabaseClient .from("subscriptions") - .update({ folder_id: folderIdentifier }) + .update({ folder_id: folderIdentifier, position: nextPosition }) .eq("id", subscriptionIdentifier) if (error) throw error |