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
29
pulls
pipelines
add option to toggle comments off
awarm.space
6 months ago
3d71e345
f7f98499
+56
-13
9 changed files
expand all
collapse all
unified
split
app
lish
[did]
[publication]
[rkey]
Interactions
Interactions.tsx
PostHeader
PostHeader.tsx
PostPage.tsx
page.tsx
createPub
UpdatePubForm.tsx
lexicons
api
lexicons.ts
types
pub
leaflet
publication.ts
pub
leaflet
publication.json
src
publication.ts
+14
-11
app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx
···
34
34
commentsCount: number;
35
35
compact?: boolean;
36
36
className?: string;
37
37
+
showComments?: boolean;
37
38
}) => {
38
39
let { drawerOpen, drawer } = useInteractionState();
39
40
···
52
53
<QuoteTiny /> {props.quotesCount}{" "}
53
54
{!props.compact && `Quote${props.quotesCount === 1 ? "" : "s"}`}
54
55
</button>
55
55
-
<button
56
56
-
className={`flex gap-1 items-center ${!props.compact && "px-1 py-0.5 border border-border-light rounded-lg trasparent-outline selected-outline"}`}
57
57
-
onClick={() => {
58
58
-
if (!drawerOpen || drawer !== "comments")
59
59
-
openInteractionDrawer("comments");
60
60
-
else useInteractionState.setState({ drawerOpen: false });
61
61
-
}}
62
62
-
>
63
63
-
<CommentTiny /> {props.commentsCount}{" "}
64
64
-
{!props.compact && `Comment${props.commentsCount === 1 ? "" : "s"}`}
65
65
-
</button>
56
56
+
{props.showComments === false ? null : (
57
57
+
<button
58
58
+
className={`flex gap-1 items-center ${!props.compact && "px-1 py-0.5 border border-border-light rounded-lg trasparent-outline selected-outline"}`}
59
59
+
onClick={() => {
60
60
+
if (!drawerOpen || drawer !== "comments")
61
61
+
openInteractionDrawer("comments");
62
62
+
else useInteractionState.setState({ drawerOpen: false });
63
63
+
}}
64
64
+
>
65
65
+
<CommentTiny /> {props.commentsCount}{" "}
66
66
+
{!props.compact && `Comment${props.commentsCount === 1 ? "" : "s"}`}
67
67
+
</button>
68
68
+
)}
66
69
</div>
67
70
);
68
71
};
+2
app/lish/[did]/[publication]/[rkey]/PostHeader/PostHeader.tsx
···
14
14
data: PostPageData;
15
15
name: string;
16
16
profile: ProfileViewDetailed;
17
17
+
preferences: { showComments?: boolean };
17
18
}) {
18
19
let { identity } = useIdentityData();
19
20
let document = props.data;
···
92
93
) : null}
93
94
|{" "}
94
95
<Interactions
96
96
+
showComments={props.preferences.showComments}
95
97
compact
96
98
quotesCount={document.document_mentions_in_bsky.length}
97
99
commentsCount={document.comments_on_documents.length}
+9
-1
app/lish/[did]/[publication]/[rkey]/PostPage.tsx
···
20
20
name,
21
21
did,
22
22
profile,
23
23
+
preferences,
23
24
pubRecord,
24
25
prerenderedCodeBlocks,
25
26
bskyPostData,
···
32
33
did: string;
33
34
prerenderedCodeBlocks?: Map<string, string>;
34
35
bskyPostData: AppBskyFeedDefs.PostView[];
36
36
+
preferences: { showComments?: boolean };
35
37
}) {
36
38
let { identity } = useIdentityData();
37
39
let { drawerOpen } = useInteractionState();
···
62
64
<div
63
65
className={`postPageContent sm:max-w-prose mx-auto h-fit w-full px-3 sm:px-4 ${hasPageBackground ? " pt-2 pb-3 sm:pb-6" : "py-6 sm:py-9"}`}
64
66
>
65
65
-
<PostHeader data={document} profile={profile} name={name} />
67
67
+
<PostHeader
68
68
+
data={document}
69
69
+
profile={profile}
70
70
+
name={name}
71
71
+
preferences={preferences}
72
72
+
/>
66
73
<PostContent
67
74
bskyPostData={bskyPostData}
68
75
blocks={blocks}
···
70
77
prerenderedCodeBlocks={prerenderedCodeBlocks}
71
78
/>
72
79
<Interactions
80
80
+
showComments={preferences.showComments}
73
81
quotesCount={document.document_mentions_in_bsky.length}
74
82
commentsCount={document.comments_on_documents.length}
75
83
/>
+6
-1
app/lish/[did]/[publication]/[rkey]/page.tsx
···
160
160
*/}
161
161
<PageLayout>
162
162
<PostPage
163
163
+
preferences={pubRecord.preferences || {}}
163
164
pubRecord={pubRecord}
164
165
profile={JSON.parse(JSON.stringify(profile.data))}
165
166
document={document}
···
171
172
/>
172
173
<InteractionDrawer
173
174
document_uri={document.uri}
174
174
-
comments={document.comments_on_documents}
175
175
+
comments={
176
176
+
pubRecord.preferences?.showComments === false
177
177
+
? []
178
178
+
: document.comments_on_documents
179
179
+
}
175
180
quotes={document.document_mentions_in_bsky}
176
181
did={did}
177
182
/>
+15
app/lish/createPub/UpdatePubForm.tsx
···
31
31
? true
32
32
: record.preferences.showInDiscover,
33
33
);
34
34
+
let [showComments, setShowComments] = useState(
35
35
+
record?.preferences?.showComments === undefined
36
36
+
? true
37
37
+
: record.preferences.showComments,
38
38
+
);
34
39
let [descriptionValue, setDescriptionValue] = useState(
35
40
record?.description || "",
36
41
);
···
62
67
iconFile: iconFile,
63
68
preferences: {
64
69
showInDiscover: showInDiscover,
70
70
+
showComments: showComments,
65
71
},
66
72
});
67
73
toast({ type: "success", content: "Updated!" });
···
153
159
<p className="text-xs text-tertiary font-normal">
154
160
This publication will appear on our public Discover page
155
161
</p>
162
162
+
</div>
163
163
+
</Checkbox>
164
164
+
165
165
+
<Checkbox
166
166
+
checked={showComments}
167
167
+
onChange={(e) => setShowComments(e.target.checked)}
168
168
+
>
169
169
+
<div className=" pt-0.5 flex flex-col text-sm italic text-tertiary ">
170
170
+
<p className="font-bold">Show comments on posts</p>
156
171
</div>
157
172
</Checkbox>
158
173
<hr className="border-border-light" />
+4
lexicons/api/lexicons.ts
···
160
160
type: 'boolean',
161
161
default: true,
162
162
},
163
163
+
showComments: {
164
164
+
type: 'boolean',
165
165
+
default: true,
166
166
+
},
163
167
},
164
168
},
165
169
theme: {
+1
lexicons/api/types/pub/leaflet/publication.ts
···
36
36
export interface Preferences {
37
37
$type?: 'pub.leaflet.publication#preferences'
38
38
showInDiscover: boolean
39
39
+
showComments: boolean
39
40
}
40
41
41
42
const hashPreferences = 'preferences'
+4
lexicons/pub/leaflet/publication.json
···
48
48
"showInDiscover": {
49
49
"type": "boolean",
50
50
"default": true
51
51
+
},
52
52
+
"showComments": {
53
53
+
"type": "boolean",
54
54
+
"default": true
51
55
}
52
56
}
53
57
},
+1
lexicons/src/publication.ts
···
26
26
type: "object",
27
27
properties: {
28
28
showInDiscover: { type: "boolean", default: true },
29
29
+
showComments: { type: "boolean", default: true },
29
30
},
30
31
},
31
32
theme: {