summaryrefslogtreecommitdiff
path: root/apps/web/lib/queries/use-folder-mutations.ts
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 01:28:18 -0800
committerFuwn <[email protected]>2026-02-12 01:52:32 -0800
commit6d8f7ea8b30e229cc0662db8dc3438828feb6880 (patch)
tree9e9270f6f7d6d3cb9c11fb5393eb44e1a44ad418 /apps/web/lib/queries/use-folder-mutations.ts
parentfix: invalidate unread counts when toggling individual entry read state (diff)
downloadasa.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-folder-mutations.ts')
-rw-r--r--apps/web/lib/queries/use-folder-mutations.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/web/lib/queries/use-folder-mutations.ts b/apps/web/lib/queries/use-folder-mutations.ts
index 4bc1247..cc84580 100644
--- a/apps/web/lib/queries/use-folder-mutations.ts
+++ b/apps/web/lib/queries/use-folder-mutations.ts
@@ -17,10 +17,20 @@ export function useCreateFolder() {
if (!user) throw new Error("not authenticated")
+ const { data: maxRow } = await supabaseClient
+ .from("folders")
+ .select("position")
+ .eq("user_id", user.id)
+ .order("position", { ascending: false })
+ .limit(1)
+ .maybeSingle()
+
+ const nextPosition = (maxRow?.position ?? 0) + 1000
+
const { error } = await supabaseClient.from("folders").insert({
user_id: user.id,
name,
- position: 0,
+ position: nextPosition,
})
if (error) throw error