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
count top level quotes and comments correctly
awarm.space
4 months ago
f257ef2a
a6e98f01
+37
-14
3 changed files
expand all
collapse all
unified
split
app
lish
[did]
[publication]
[rkey]
Interactions
InteractionDrawer.tsx
PostHeader
PostHeader.tsx
PostPages.tsx
+7
-9
app/lish/[did]/[publication]/[rkey]/Interactions/InteractionDrawer.tsx
···
23
23
(c) => (c.record as any)?.onPage === props.pageId,
24
24
);
25
25
26
26
-
const filteredQuotes = props.pageId
27
27
-
? props.quotes.filter((q) => q.link.includes(props.pageId!))
28
28
-
: props.quotes.filter((q) => {
29
29
-
const url = new URL(q.link);
30
30
-
const quoteParam = url.pathname.split("/l-quote/")[1];
31
31
-
if (!quoteParam) return null;
32
32
-
const quotePosition = decodeQuotePosition(quoteParam);
33
33
-
return !quotePosition?.pageId;
34
34
-
});
26
26
+
const filteredQuotes = props.quotes.filter((q) => {
27
27
+
const url = new URL(q.link);
28
28
+
const quoteParam = url.pathname.split("/l-quote/")[1];
29
29
+
if (!quoteParam) return null;
30
30
+
const quotePosition = decodeQuotePosition(quoteParam);
31
31
+
return quotePosition?.pageId === props.pageId;
32
32
+
});
35
33
36
34
return (
37
35
<>
+20
-3
app/lish/[did]/[publication]/[rkey]/PostHeader/PostHeader.tsx
···
1
1
"use client";
2
2
-
import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api";
2
2
+
import {
3
3
+
PubLeafletComment,
4
4
+
PubLeafletDocument,
5
5
+
PubLeafletPublication,
6
6
+
} from "lexicons/api";
3
7
import { getPublicationURL } from "app/lish/createPub/getPublicationURL";
4
8
import { Interactions } from "../Interactions/Interactions";
5
9
import { PostPageData } from "../getPostPageData";
···
7
11
import { useIdentityData } from "components/IdentityProvider";
8
12
import { EditTiny } from "components/Icons/EditTiny";
9
13
import { SpeedyLink } from "components/SpeedyLink";
14
14
+
import { decodeQuotePosition } from "../quotePosition";
10
15
11
16
export function PostHeader(props: {
12
17
data: PostPageData;
···
86
91
<Interactions
87
92
showComments={props.preferences.showComments}
88
93
compact
89
89
-
quotesCount={document.document_mentions_in_bsky.length}
90
90
-
commentsCount={document.comments_on_documents.length}
94
94
+
quotesCount={
95
95
+
document.document_mentions_in_bsky.filter((q) => {
96
96
+
const url = new URL(q.link);
97
97
+
const quoteParam = url.pathname.split("/l-quote/")[1];
98
98
+
if (!quoteParam) return null;
99
99
+
const quotePosition = decodeQuotePosition(quoteParam);
100
100
+
return !quotePosition?.pageId;
101
101
+
}).length
102
102
+
}
103
103
+
commentsCount={
104
104
+
document.comments_on_documents.filter(
105
105
+
(c) => !(c.record as PubLeafletComment.Record)?.onPage,
106
106
+
).length
107
107
+
}
91
108
/>
92
109
</div>
93
110
</div>
+10
-2
app/lish/[did]/[publication]/[rkey]/PostPages.tsx
···
75
75
export const openPage = (
76
76
parent: string | undefined,
77
77
page: string,
78
78
-
options?: { scrollIntoView?: boolean }
78
78
+
options?: { scrollIntoView?: boolean },
79
79
) => {
80
80
flushSync(() => {
81
81
usePostPageUIState.setState((state) => {
···
158
158
/>
159
159
<Interactions
160
160
showComments={preferences.showComments}
161
161
-
quotesCount={document.document_mentions_in_bsky.length}
161
161
+
quotesCount={
162
162
+
document.document_mentions_in_bsky.filter((q) => {
163
163
+
const url = new URL(q.link);
164
164
+
const quoteParam = url.pathname.split("/l-quote/")[1];
165
165
+
if (!quoteParam) return null;
166
166
+
const quotePosition = decodeQuotePosition(quoteParam);
167
167
+
return !quotePosition?.pageId;
168
168
+
}).length
169
169
+
}
162
170
commentsCount={
163
171
document.comments_on_documents.filter(
164
172
(c) => !(c.record as PubLeafletComment.Record)?.onPage,