From 3eebc1c3583b4963c9e4fa9b8b081a87d439daab Mon Sep 17 00:00:00 2001 From: killerprojecte Date: Mon, 22 Jun 2026 21:08:11 +0800 Subject: [PATCH] fix: delete label without mailboxId caused 404 error on non-default mailbox --- apps/web/src/lib/api.ts | 2 +- apps/web/src/pages/mail.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/lib/api.ts b/apps/web/src/lib/api.ts index a56f3ae..15a6698 100644 --- a/apps/web/src/lib/api.ts +++ b/apps/web/src/lib/api.ts @@ -108,7 +108,7 @@ export const api = { const query = payload.mailboxId ? `?mailboxId=${encodeURIComponent(payload.mailboxId)}` : "" return request(`/api/mail/labels${query}`, { method: "POST", body: JSON.stringify({ name: payload.name, color: payload.color || "" }) }) }, - deleteLabel: (id: string) => request<{ labels: MailLabel[] }>(`/api/mail/labels/${id}`, { method: "DELETE" }), + deleteLabel: (id: string, mailboxId?: string) => request<{ labels: MailLabel[] }>(`/api/mail/labels/${id}${mailboxId ? `?mailboxId=${encodeURIComponent(mailboxId)}` : ""}`, { method: "DELETE" }), messages: (folder: string, q = "", cursor = "", mailboxId?: string) => { const params = new URLSearchParams({ folder, q, cursor }) if (mailboxId) params.set("mailboxId", mailboxId) diff --git a/apps/web/src/pages/mail.tsx b/apps/web/src/pages/mail.tsx index 32e32e5..7586302 100644 --- a/apps/web/src/pages/mail.tsx +++ b/apps/web/src/pages/mail.tsx @@ -236,7 +236,7 @@ export function MailPage() { onSettled: () => qc.invalidateQueries({ queryKey: ["labels"] }), }) const deleteLabel = useMutation({ - mutationFn: (id: string) => api.deleteLabel(id), + mutationFn: (id: string) => api.deleteLabel(id, activeMailboxId), onMutate: async (id) => { await qc.cancelQueries({ queryKey: ["labels"] }) await qc.cancelQueries({ queryKey: ["messages"] })