- {drawer === "quotes" ? (
-
+ {drawer.drawer === "quotes" ? (
+
) : (
)}
@@ -40,8 +59,10 @@ export const InteractionDrawer = (props: {
export const useDrawerOpen = (uri: string) => {
let params = useSearchParams();
let interactionDrawerSearchParam = params.get("interactionDrawer");
- let { drawerOpen: open, drawer } = useInteractionState(uri);
+ let { drawerOpen: open, drawer, pageId } = useInteractionState(uri);
if (open === false || (open === undefined && !interactionDrawerSearchParam))
return null;
- return drawer || interactionDrawerSearchParam;
+ drawer =
+ drawer || (interactionDrawerSearchParam as InteractionState["drawer"]);
+ return { drawer, pageId };
};
diff --git a/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx b/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx
index 842634ad..d7a612c4 100644
--- a/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx
+++ b/app/lish/[did]/[publication]/[rkey]/Interactions/Interactions.tsx
@@ -10,8 +10,9 @@ import { useContext } from "react";
import { PostPageContext } from "../PostPageContext";
import { scrollIntoView } from "src/utils/scrollIntoView";
-type InteractionState = {
+export type InteractionState = {
drawerOpen: undefined | boolean;
+ pageId?: string;
drawer: undefined | "comments" | "quotes";
localComments: Comment[];
commentBox: { quote: QuotePosition | null };
@@ -84,9 +85,10 @@ export function setInteractionState(
export function openInteractionDrawer(
drawer: "comments" | "quotes",
document_uri: string,
+ pageId?: string,
) {
flushSync(() => {
- setInteractionState(document_uri, { drawerOpen: true, drawer });
+ setInteractionState(document_uri, { drawerOpen: true, drawer, pageId });
});
scrollIntoView("interaction-drawer");
}
@@ -97,6 +99,7 @@ export const Interactions = (props: {
compact?: boolean;
className?: string;
showComments?: boolean;
+ pageId?: string;
}) => {
const data = useContext(PostPageContext);
const document_uri = data?.uri;
@@ -113,7 +116,7 @@ export const Interactions = (props: {
className={`flex gap-1 items-center ${!props.compact && "px-1 py-0.5 border border-border-light rounded-lg trasparent-outline selected-outline"}`}
onClick={() => {
if (!drawerOpen || drawer !== "quotes")
- openInteractionDrawer("quotes", document_uri);
+ openInteractionDrawer("quotes", document_uri, props.pageId);
else setInteractionState(document_uri, { drawerOpen: false });
}}
>
@@ -130,7 +133,7 @@ export const Interactions = (props: {
className={`flex gap-1 items-center ${!props.compact && "px-1 py-0.5 border border-border-light rounded-lg trasparent-outline selected-outline"}`}
onClick={() => {
if (!drawerOpen || drawer !== "comments")
- openInteractionDrawer("comments", document_uri);
+ openInteractionDrawer("comments", document_uri, props.pageId);
else setInteractionState(document_uri, { drawerOpen: false });
}}
>
diff --git a/app/lish/[did]/[publication]/[rkey]/PostPages.tsx b/app/lish/[did]/[publication]/[rkey]/PostPages.tsx
index d9fa394f..c157cbd4 100644
--- a/app/lish/[did]/[publication]/[rkey]/PostPages.tsx
+++ b/app/lish/[did]/[publication]/[rkey]/PostPages.tsx
@@ -1,5 +1,6 @@
"use client";
import {
+ PubLeafletComment,
PubLeafletDocument,
PubLeafletPagesLinearDocument,
PubLeafletPublication,
@@ -119,14 +120,14 @@ export function PostPages({
preferences: { showComments?: boolean };
}) {
let { identity } = useIdentityData();
- let drawerOpen = useDrawerOpen(document_uri);
+ let drawer = useDrawerOpen(document_uri);
useInitializeOpenPages();
let pages = useOpenPages();
if (!document || !document.documents_in_publications[0].publications)
return null;
let hasPageBackground = !!pubRecord.theme?.showPageBackground;
- let fullPageScroll = !hasPageBackground && !drawerOpen && pages.length === 0;
+ let fullPageScroll = !hasPageBackground && !drawer && pages.length === 0;
let record = document.data as PubLeafletDocument.Record;
return (
<>
@@ -135,7 +136,7 @@ export function PostPages({
fullPageScroll={fullPageScroll}
cardBorderHidden={!hasPageBackground}
id={"post-page"}
- drawerOpen={!!drawerOpen}
+ drawerOpen={!!drawer && !drawer.pageId}
>
!(c.record as PubLeafletComment.Record)?.onPage,
+ ).length
+ }
/>
@@ -183,16 +188,18 @@ export function PostPages({
-
+ {drawer && !drawer.pageId && (
+
+ )}
{pages.map((p) => {
let page = record.pages.find(
@@ -207,7 +214,7 @@ export function PostPages({
cardBorderHidden={!hasPageBackground}
id={`post-page-${p}`}
fullPageScroll={false}
- drawerOpen={!!drawerOpen}
+ drawerOpen={!!drawer && drawer.pageId === page.id}
pageOptions={
closePage(page?.id!)}
@@ -223,7 +230,36 @@ export function PostPages({
did={did}
prerenderedCodeBlocks={prerenderedCodeBlocks}
/>
+
+ q.link.includes(page.id!),
+ ).length
+ }
+ commentsCount={
+ document.comments_on_documents.filter(
+ (c) =>
+ (c.record as PubLeafletComment.Record)?.onPage ===
+ page.id,
+ ).length
+ }
+ />
+ {drawer && drawer.pageId === page.id && (
+
+ )}
);
})}
diff --git a/app/lish/[did]/[publication]/[rkey]/QuoteHandler.tsx b/app/lish/[did]/[publication]/[rkey]/QuoteHandler.tsx
index 2d2e5d0f..decd058d 100644
--- a/app/lish/[did]/[publication]/[rkey]/QuoteHandler.tsx
+++ b/app/lish/[did]/[publication]/[rkey]/QuoteHandler.tsx
@@ -212,6 +212,7 @@ export const QuoteOptionButtons = (props: { position: string }) => {
setInteractionState(document_uri, {
drawer: "comments",
drawerOpen: true,
+ pageId: position.pageId,
commentBox: { quote: position },
}),
);
diff --git a/lexicons/api/lexicons.ts b/lexicons/api/lexicons.ts
index 5ebfc688..56145091 100644
--- a/lexicons/api/lexicons.ts
+++ b/lexicons/api/lexicons.ts
@@ -1325,6 +1325,9 @@ export const schemaDict = {
ref: 'lex:pub.leaflet.richtext.facet',
},
},
+ onPage: {
+ type: 'string',
+ },
attachment: {
type: 'union',
refs: ['lex:pub.leaflet.comment#linearDocumentQuote'],
@@ -1541,7 +1544,6 @@ export const schemaDict = {
},
base_path: {
type: 'string',
- format: 'uri',
},
description: {
type: 'string',
diff --git a/lexicons/api/types/pub/leaflet/comment.ts b/lexicons/api/types/pub/leaflet/comment.ts
index ef7a020d..9168104a 100644
--- a/lexicons/api/types/pub/leaflet/comment.ts
+++ b/lexicons/api/types/pub/leaflet/comment.ts
@@ -19,6 +19,7 @@ export interface Record {
reply?: ReplyRef
plaintext: string
facets?: PubLeafletRichtextFacet.Main[]
+ onPage?: string
attachment?: $Typed | { $type: string }
[k: string]: unknown
}
diff --git a/lexicons/pub/leaflet/comment.json b/lexicons/pub/leaflet/comment.json
index afca5a69..57f16a37 100644
--- a/lexicons/pub/leaflet/comment.json
+++ b/lexicons/pub/leaflet/comment.json
@@ -38,6 +38,9 @@
"ref": "pub.leaflet.richtext.facet"
}
},
+ "onPage": {
+ "type": "string"
+ },
"attachment": {
"type": "union",
"refs": [
diff --git a/lexicons/pub/leaflet/publication.json b/lexicons/pub/leaflet/publication.json
index def5d283..1d3ab1e3 100644
--- a/lexicons/pub/leaflet/publication.json
+++ b/lexicons/pub/leaflet/publication.json
@@ -17,8 +17,7 @@
"maxLength": 2000
},
"base_path": {
- "type": "string",
- "format": "uri"
+ "type": "string"
},
"description": {
"type": "string",
diff --git a/lexicons/src/comment.ts b/lexicons/src/comment.ts
index 18e5a73d..df95864c 100644
--- a/lexicons/src/comment.ts
+++ b/lexicons/src/comment.ts
@@ -23,6 +23,7 @@ export const PubLeafletComment: LexiconDoc = {
type: "array",
items: { type: "ref", ref: PubLeafletRichTextFacet.id },
},
+ onPage: { type: "string" },
attachment: { type: "union", refs: ["#linearDocumentQuote"] },
},
},