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
28
pulls
pipelines
fix actually posting comments on subpages
awarm.space
4 months ago
00fab06c
529b5287
+14
-3
4 changed files
expand all
collapse all
unified
split
app
lish
[did]
[publication]
[rkey]
Interactions
Comments
CommentBox.tsx
commentAction.ts
index.tsx
Interactions.tsx
+2
app/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentBox.tsx
···
39
39
40
40
export function CommentBox(props: {
41
41
doc_uri: string;
42
42
+
pageId?: string;
42
43
replyTo?: string;
43
44
onSubmit?: () => void;
44
45
autoFocus?: boolean;
···
56
57
let currentState = view.current.state;
57
58
let [plaintext, facets] = docToFacetedText(currentState.doc);
58
59
let comment = await publishComment({
60
60
+
pageId: props.pageId,
59
61
document: props.doc_uri,
60
62
comment: {
61
63
plaintext,
+2
app/lish/[did]/[publication]/[rkey]/Interactions/Comments/commentAction.ts
···
11
11
12
12
export async function publishComment(args: {
13
13
document: string;
14
14
+
pageId?: string;
14
15
comment: {
15
16
plaintext: string;
16
17
facets: PubLeafletRichtextFacet.Main[];
···
28
29
);
29
30
let record: Un$Typed<PubLeafletComment.Record> = {
30
31
subject: args.document,
32
32
+
onPage: args.pageId,
31
33
createdAt: new Date().toISOString(),
32
34
plaintext: args.comment.plaintext,
33
35
facets: args.comment.facets,
+8
-1
app/lish/[did]/[publication]/[rkey]/Interactions/Comments/index.tsx
···
40
40
}, [props.comments, localComments]);
41
41
let pathname = usePathname();
42
42
let redirectRoute = useMemo(() => {
43
43
+
if (typeof window === "undefined") return;
43
44
let url = new URL(pathname, window.location.origin);
44
45
url.searchParams.set("refreshAuth", "");
45
46
url.searchParams.set("interactionDrawer", "comments");
···
61
62
</button>
62
63
</div>
63
64
{identity?.atp_did ? (
64
64
-
<CommentBox doc_uri={props.document_uri} />
65
65
+
<CommentBox doc_uri={props.document_uri} pageId={props.pageId} />
65
66
) : (
66
67
<div className="w-full accent-container text-tertiary text-center italic p-3 flex flex-col gap-2">
67
68
Connect a Bluesky account to comment
···
88
89
?.record as AppBskyActorProfile.Record;
89
90
return (
90
91
<Comment
92
92
+
pageId={props.pageId}
91
93
profile={profile}
92
94
document={props.document_uri}
93
95
comment={comment}
···
108
110
comments: Comment[];
109
111
profile?: AppBskyActorProfile.Record;
110
112
record: PubLeafletComment.Record;
113
113
+
pageId?: string;
111
114
}) => {
112
115
return (
113
116
<div className="comment">
···
139
142
/>
140
143
</pre>
141
144
<Replies
145
145
+
pageId={props.pageId}
142
146
comment_uri={props.comment.uri}
143
147
comments={props.comments}
144
148
document={props.document}
···
151
155
comment_uri: string;
152
156
comments: Comment[];
153
157
document: string;
158
158
+
pageId?: string;
154
159
}) => {
155
160
let { identity } = useIdentityData();
156
161
···
200
205
<div className="flex flex-col gap-2">
201
206
{replyBoxOpen && (
202
207
<CommentBox
208
208
+
pageId={props.pageId}
203
209
doc_uri={props.document}
204
210
replyTo={props.comment_uri}
205
211
autoFocus={true}
···
223
229
{replies.map((reply) => {
224
230
return (
225
231
<Comment
232
232
+
pageId={props.pageId}
226
233
document={props.document}
227
234
key={reply.uri}
228
235
comment={reply}
+2
-2
app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx
···
106
106
if (!document_uri)
107
107
throw new Error("document_uri not available in PostPageContext");
108
108
109
109
-
let { drawerOpen, drawer } = useInteractionState(document_uri);
109
109
+
let { drawerOpen, drawer, pageId } = useInteractionState(document_uri);
110
110
111
111
return (
112
112
<div
···
132
132
<button
133
133
className={`flex gap-1 items-center ${!props.compact && "px-1 py-0.5 border border-border-light rounded-lg trasparent-outline selected-outline"}`}
134
134
onClick={() => {
135
135
-
if (!drawerOpen || drawer !== "comments")
135
135
+
if (!drawerOpen || drawer !== "comments" || pageId !== props.pageId)
136
136
openInteractionDrawer("comments", document_uri, props.pageId);
137
137
else setInteractionState(document_uri, { drawerOpen: false });
138
138
}}