fix: delete label without mailboxId caused 404 error on non-default mailbox

This commit is contained in:
killerprojecte
2026-06-22 21:08:11 +08:00
parent c8dff253cc
commit 3eebc1c358
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -108,7 +108,7 @@ export const api = {
const query = payload.mailboxId ? `?mailboxId=${encodeURIComponent(payload.mailboxId)}` : "" const query = payload.mailboxId ? `?mailboxId=${encodeURIComponent(payload.mailboxId)}` : ""
return request<MailLabel>(`/api/mail/labels${query}`, { method: "POST", body: JSON.stringify({ name: payload.name, color: payload.color || "" }) }) return request<MailLabel>(`/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) => { messages: (folder: string, q = "", cursor = "", mailboxId?: string) => {
const params = new URLSearchParams({ folder, q, cursor }) const params = new URLSearchParams({ folder, q, cursor })
if (mailboxId) params.set("mailboxId", mailboxId) if (mailboxId) params.set("mailboxId", mailboxId)
+1 -1
View File
@@ -236,7 +236,7 @@ export function MailPage() {
onSettled: () => qc.invalidateQueries({ queryKey: ["labels"] }), onSettled: () => qc.invalidateQueries({ queryKey: ["labels"] }),
}) })
const deleteLabel = useMutation({ const deleteLabel = useMutation({
mutationFn: (id: string) => api.deleteLabel(id), mutationFn: (id: string) => api.deleteLabel(id, activeMailboxId),
onMutate: async (id) => { onMutate: async (id) => {
await qc.cancelQueries({ queryKey: ["labels"] }) await qc.cancelQueries({ queryKey: ["labels"] })
await qc.cancelQueries({ queryKey: ["messages"] }) await qc.cancelQueries({ queryKey: ["messages"] })