tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
27
pulls
pipelines
add unsubscribe action
awarm.space
11 months ago
caad7c2f
ed1d92f3
+15
-1
2 changed files
expand all
collapse all
unified
split
actions
unsubscribeFromPublication.ts
app
lish
[handle]
[publication]
CallToActionButton.tsx
+14
actions/unsubscribeFromPublication.ts
···
1
1
+
"use server";
2
2
+
import { supabaseServerClient } from "supabase/serverClient";
3
3
+
import { getIdentityData } from "./getIdentityData";
4
4
+
5
5
+
export async function unsubscribeFromPublication(publication: string) {
6
6
+
let identity = await getIdentityData();
7
7
+
if (!identity || !identity.email) return null;
8
8
+
//This is an email relation!!
9
9
+
await supabaseServerClient
10
10
+
.from("subscribers_to_publications")
11
11
+
.delete()
12
12
+
.eq("publication", publication)
13
13
+
.eq("identity", identity.email);
14
14
+
}
+1
-1
app/lish/[handle]/[publication]/CallToActionButton.tsx
···
7
7
import { Menu, MenuItem } from "components/Layout";
8
8
import { ArrowRightTiny, MoreOptionsTiny, ShareSmall } from "components/Icons";
9
9
import { useIdentityData } from "components/IdentityProvider";
10
10
-
import { unsubscribeFromPublication } from "actions/unsubscribeFromPubliction";
10
10
+
import { unsubscribeFromPublication } from "actions/unsubscribeFromPublication";
11
11
12
12
export function CallToActionButton() {
13
13
let rel = usePublicationRelationship();