fix: delete label without mailboxId caused 404 error on non-default mailbox
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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"] })
|
||||||
|
|||||||
Reference in New Issue
Block a user