diff --git a/frontend/src/api/client.js b/frontend/src/api/client.js
index 697024e..cebe4cc 100644
--- a/frontend/src/api/client.js
+++ b/frontend/src/api/client.js
@@ -105,6 +105,7 @@ export const EmailApi = {
unstar: (id) => api.post(`/email/${id}/unstar`),
trash: (id) => api.post(`/email/${id}/trash`),
untrash: (id) => api.post(`/email/${id}/untrash`),
+ unsubscribe:(id) => api.post(`/email/${id}/unsubscribe`).then((r) => r.data),
};
export const ExportApi = {
diff --git a/frontend/src/components/EmailRow.jsx b/frontend/src/components/EmailRow.jsx
index ef2be84..8fc63fb 100644
--- a/frontend/src/components/EmailRow.jsx
+++ b/frontend/src/components/EmailRow.jsx
@@ -32,6 +32,22 @@ export default function EmailRow({ email: initial, onRemove }) {
}
};
+ const handleUnsub = async (e) => {
+ e.stopPropagation();
+ if (acting) return;
+ setActing(true);
+ try {
+ const res = await EmailApi.unsubscribe(email.id);
+ if (res.method === 'mailto') {
+ window.location.href = res.target;
+ } else {
+ setEmail((prev) => ({ ...prev, _unsubDone: true }));
+ }
+ } finally {
+ setActing(false);
+ }
+ };
+
const handleTrash = async (e) => {
e.stopPropagation();
if (acting) return;
@@ -84,6 +100,14 @@ export default function EmailRow({ email: initial, onRemove }) {
? act(EmailApi.unstar, { isStarred: false })
: act(EmailApi.star, { isStarred: true })}
>⭐
+ {email.hasListUnsubscribe && (
+
+ )}