Show upload progress and fix credit concurrency user scope

- Replace image upload POST with XHR progress tracking
- Keep upload state until Convex sync completes
- Pass owner userId through image generation to decrement concurrency correctly
This commit is contained in:
Matthias
2026-04-01 20:18:01 +02:00
parent 8988428fc9
commit 3926940c5a
3 changed files with 112 additions and 22 deletions

View File

@@ -833,15 +833,18 @@ export const incrementUsage = internalMutation({
* (commit/release übernehmen das bei aktivierten Credits).
*/
export const decrementConcurrency = internalMutation({
args: {},
handler: async (ctx) => {
const user = await requireAuth(ctx);
args: {
userId: v.optional(v.string()),
},
handler: async (ctx, args) => {
const resolvedUserId =
args.userId ?? (await requireAuth(ctx)).userId;
const today = new Date().toISOString().split("T")[0];
const usage = await ctx.db
.query("dailyUsage")
.withIndex("by_user_date", (q) =>
q.eq("userId", user.userId).eq("date", today)
q.eq("userId", resolvedUserId).eq("date", today)
)
.unique();