alpha
Login
or
Join now
jack.is
/
leaflet
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
a tool for shared writing and social publishing
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
make archiving in pubs work
author
Jared Pereira
date
8 months ago
(Nov 21, 2025, 5:29 PM -0500)
commit
140e309a
140e309ab1640efa56250424402b9f7eed8cee7e
parent
0a2cbc89
0a2cbc89257dba33fd9a7e1bce5ccb17a01cfb98
+92
-82
5 changed files
Expand all
Collapse all
Unified
Split
actions
deleteLeaflet.ts
app
(home-pages)
home
LeafletList
LeafletListItem.tsx
LeafletOptions.tsx
LeafletPreview.tsx
lish
[did]
[publication]
dashboard
PublicationSWRProvider.tsx
+38
-23
actions/deleteLeaflet.ts
View file
Reviewed
···
42
42
let identity = await getIdentityData();
43
43
if (!identity) throw new Error("No Identity");
44
44
45
45
+
// Archive on homepage
45
46
await supabaseServerClient
46
47
.from("permission_token_on_homepage")
47
48
.update({ archived: true })
48
49
.eq("token", token)
49
50
.eq("identity", identity.id);
50
50
-
refresh();
51
51
-
return;
52
52
-
}
53
53
-
export async function archivePublicationDraft(
54
54
-
token: string,
55
55
-
publication: string,
56
56
-
) {
57
57
-
console.log("ARCHIVING", token, publication);
58
58
-
let identity = await getIdentityData();
59
59
-
if (!identity) throw new Error("No Identity");
60
60
-
let { data: pub } = await supabaseServerClient
61
61
-
.from("publications")
62
62
-
.select("*")
63
63
-
.eq("uri", publication)
64
64
-
.single();
51
51
+
52
52
+
// Check if leaflet is in any publications where user is the creator
53
53
+
let { data: leafletInPubs } = await supabaseServerClient
54
54
+
.from("leaflets_in_publications")
55
55
+
.select("publication, publications!inner(identity_did)")
56
56
+
.eq("leaflet", token);
65
57
66
66
-
if (!pub || pub.identity_did !== identity.atp_did) return;
58
58
+
if (leafletInPubs) {
59
59
+
for (let pub of leafletInPubs) {
60
60
+
if (pub.publications.identity_did === identity.atp_did) {
61
61
+
await supabaseServerClient
62
62
+
.from("leaflets_in_publications")
63
63
+
.update({ archived: true })
64
64
+
.eq("leaflet", token)
65
65
+
.eq("publication", pub.publication);
66
66
+
}
67
67
+
}
68
68
+
}
67
69
68
68
-
console.log(
69
69
-
await supabaseServerClient
70
70
-
.from("leaflets_in_publications")
71
71
-
.update({ archived: true })
72
72
-
.eq("leaflet", token)
73
73
-
.eq("publication", publication),
74
74
-
);
75
70
refresh();
76
71
return;
77
72
}
···
80
75
let identity = await getIdentityData();
81
76
if (!identity) throw new Error("No Identity");
82
77
78
78
+
// Unarchive on homepage
83
79
await supabaseServerClient
84
80
.from("permission_token_on_homepage")
85
81
.update({ archived: false })
86
82
.eq("token", token)
87
83
.eq("identity", identity.id);
84
84
+
85
85
+
// Check if leaflet is in any publications where user is the creator
86
86
+
let { data: leafletInPubs } = await supabaseServerClient
87
87
+
.from("leaflets_in_publications")
88
88
+
.select("publication, publications!inner(identity_did)")
89
89
+
.eq("leaflet", token);
90
90
+
91
91
+
if (leafletInPubs) {
92
92
+
for (let pub of leafletInPubs) {
93
93
+
if (pub.publications.identity_did === identity.atp_did) {
94
94
+
await supabaseServerClient
95
95
+
.from("leaflets_in_publications")
96
96
+
.update({ archived: false })
97
97
+
.eq("leaflet", token)
98
98
+
.eq("publication", pub.publication);
99
99
+
}
100
100
+
}
101
101
+
}
102
102
+
88
103
refresh();
89
104
return;
90
105
}
+44
-48
app/(home-pages)/home/LeafletList/LeafletListItem.tsx
View file
Reviewed
···
51
51
if (props.display === "list")
52
52
return (
53
53
<>
54
54
-
<LeafletLink
55
55
-
id={props.token.id}
56
56
-
className={`w-full ${props.isHidden ? "hidden" : "block"}`}
54
54
+
<div
55
55
+
ref={previewRef}
56
56
+
className={`relative flex gap-3 w-full
57
57
+
${props.isHidden ? "hidden" : "flex"}
58
58
+
${props.cardBorderHidden ? "" : "px-2 py-1 block-border hover:outline-border relative"}`}
59
59
+
style={{
60
60
+
backgroundColor: props.cardBorderHidden
61
61
+
? "transparent"
62
62
+
: "rgba(var(--bg-page), var(--bg-page-alpha))",
63
63
+
}}
57
64
>
58
58
-
<div
59
59
-
ref={previewRef}
60
60
-
className={`flex gap-3 w-full ${props.cardBorderHidden ? "" : "px-2 py-1 block-border hover:outline-border relative"}`}
61
61
-
style={{
62
62
-
backgroundColor: props.cardBorderHidden
63
63
-
? "transparent"
64
64
-
: "rgba(var(--bg-page), var(--bg-page-alpha))",
65
65
-
}}
66
66
-
>
67
67
-
{props.showPreview && (
68
68
-
<LeafletListPreview isVisible={isOnScreen} {...props} />
69
69
-
)}
70
70
-
<LeafletInfo isTemplate={isTemplate} {...props} />
71
71
-
</div>
72
72
-
</LeafletLink>
65
65
+
<SpeedyLink
66
66
+
href={`/${props.token.id}`}
67
67
+
className={`absolute w-full h-full top-0 left-0 no-underline hover:no-underline! text-primary`}
68
68
+
/>
69
69
+
{props.showPreview && (
70
70
+
<LeafletListPreview isVisible={isOnScreen} {...props} />
71
71
+
)}
72
72
+
<LeafletInfo isTemplate={isTemplate} {...props} />
73
73
+
</div>
73
74
{props.cardBorderHidden && (
74
75
<hr
75
76
className="last:hidden border-border-light"
···
81
82
</>
82
83
);
83
84
return (
84
84
-
<LeafletLink
85
85
-
id={props.token.id}
86
86
-
className={`leafletGridListItem relative w-full ${props.isHidden ? "hidden" : "flex"}`}
87
87
-
>
88
88
-
<div
89
89
-
ref={previewRef}
90
90
-
className={`
85
85
+
<div
86
86
+
ref={previewRef}
87
87
+
className={`
88
88
+
relative
91
89
flex flex-col gap-1 p-1 h-52 w-full
92
90
block-border border-border! hover:outline-border
91
91
+
${props.isHidden ? "hidden" : "flex"}
93
92
`}
94
94
-
style={{
95
95
-
backgroundColor: props.cardBorderHidden
96
96
-
? "transparent"
97
97
-
: "rgba(var(--bg-page), var(--bg-page-alpha))",
98
98
-
}}
99
99
-
>
100
100
-
<div className="grow">
101
101
-
<LeafletGridPreview {...props} isVisible={isOnScreen} />
102
102
-
</div>
103
103
-
<LeafletInfo
104
104
-
isTemplate={isTemplate}
105
105
-
className="px-1 pb-0.5 shrink-0"
106
106
-
{...props}
107
107
-
/>
93
93
+
style={{
94
94
+
backgroundColor: props.cardBorderHidden
95
95
+
? "transparent"
96
96
+
: "rgba(var(--bg-page), var(--bg-page-alpha))",
97
97
+
}}
98
98
+
>
99
99
+
<SpeedyLink
100
100
+
href={`/${props.token.id}`}
101
101
+
className={`absolute w-full h-full top-0 left-0 no-underline hover:no-underline! text-primary`}
102
102
+
/>
103
103
+
<div className="grow">
104
104
+
<LeafletGridPreview {...props} isVisible={isOnScreen} />
108
105
</div>
109
109
-
</LeafletLink>
106
106
+
<LeafletInfo
107
107
+
isTemplate={isTemplate}
108
108
+
className="px-1 pb-0.5 shrink-0"
109
109
+
{...props}
110
110
+
/>
111
111
+
</div>
110
112
);
111
113
};
112
114
113
113
-
const LeafletLink = (props: {
114
114
-
id: string;
115
115
-
children: React.ReactNode;
116
116
-
className: string;
117
117
-
}) => {
115
115
+
const LeafletLink = (props: { id: string; className: string }) => {
118
116
return (
119
117
<SpeedyLink
120
118
href={`/${props.id}`}
121
119
className={`no-underline hover:no-underline! text-primary ${props.className}`}
122
122
-
>
123
123
-
{props.children}
124
124
-
</SpeedyLink>
120
120
+
/>
125
121
);
126
122
};
+1
-6
app/(home-pages)/home/LeafletList/LeafletOptions.tsx
View file
Reviewed
···
11
11
import { DeleteSmall } from "components/Icons/DeleteSmall";
12
12
import {
13
13
archivePost,
14
14
-
archivePublicationDraft,
15
14
deleteLeaflet,
16
15
unarchivePost,
17
16
} from "actions/deleteLeaflet";
···
124
123
<MenuItem
125
124
onSelect={async () => {
126
125
if (!props.archived) {
127
127
-
if (props.draftInPublication)
128
128
-
await archivePublicationDraft(
129
129
-
props.leaflet.id,
130
130
-
props.draftInPublication,
131
131
-
);
126
126
+
await archivePost(props.leaflet.id);
132
127
toaster({
133
128
content: (
134
129
<div className="font-bold flex gap-2">
+3
-3
app/(home-pages)/home/LeafletList/LeafletPreview.tsx
View file
Reviewed
···
133
133
);
134
134
return (
135
135
<ThemeProvider local entityID={root} className="w-full!">
136
136
-
<div className="border border-border-light rounded-md w-full h-full overflow-hidden relative">
137
137
-
<div className="relative w-full h-full">
136
136
+
<div className="border border-border-light rounded-md w-full h-full overflow-hidden ">
137
137
+
<div className="w-full h-full">
138
138
<ThemeBackgroundProvider entityID={root}>
139
139
<div
140
140
inert
141
141
-
className="leafletPreview relative grow shrink-0 h-full w-full px-2 pt-2 sm:px-3 sm:pt-3 flex items-end pointer-events-none"
141
141
+
className="leafletPreview grow shrink-0 h-full w-full px-2 pt-2 sm:px-3 sm:pt-3 flex items-end pointer-events-none"
142
142
>
143
143
<div
144
144
className={`leafletContentWrapper h-full sm:w-48 w-40 mx-auto overflow-clip ${!cardBorderHidden && "border border-border-light border-b-0 rounded-t-md"}`}
+6
-2
app/lish/[did]/[publication]/dashboard/PublicationSWRProvider.tsx
View file
Reviewed
···
2
2
3
3
import type { GetPublicationDataReturnType } from "app/api/rpc/[command]/get_publication_data";
4
4
import { callRPC } from "app/api/rpc/client";
5
5
-
import { createContext, useContext } from "react";
6
6
-
import useSWR, { SWRConfig } from "swr";
5
5
+
import { createContext, useContext, useEffect } from "react";
6
6
+
import useSWR, { SWRConfig, mutate } from "swr";
7
7
8
8
const PublicationContext = createContext({ name: "", did: "" });
9
9
export function PublicationSWRDataProvider(props: {
···
13
13
children: React.ReactNode;
14
14
}) {
15
15
let key = `publication-data-${props.publication_did}-${props.publication_rkey}`;
16
16
+
useEffect(() => {
17
17
+
console.log("UPDATING");
18
18
+
mutate(key, props.publication_data);
19
19
+
}, [props.publication_data]);
16
20
return (
17
21
<PublicationContext
18
22
value={{ name: props.publication_rkey, did: props.publication_did }}