a tool for shared writing and social publishing

don't show comment button in highlight tool if comments disabled

+24 -18
+24 -18
app/lish/[did]/[publication]/[rkey]/QuoteHandler.tsx
··· 13 import { CommentTiny } from "components/Icons/CommentTiny"; 14 import { setInteractionState } from "./Interactions/Interactions"; 15 import { PostPageContext } from "./PostPageContext"; 16 17 export function QuoteHandler() { 18 let [position, setPosition] = useState<{ ··· 131 let { identity } = useIdentityData(); 132 const data = useContext(PostPageContext); 133 const document_uri = data?.uri; 134 - if (!document_uri) throw new Error('document_uri not available in PostPageContext'); 135 let [url, position] = useMemo(() => { 136 let currentUrl = new URL(window.location.href); 137 let pos = decodeQuotePosition(props.position); ··· 139 currentUrl.pathname = currentUrl.pathname.split("/l-quote/")[0]; 140 } 141 currentUrl.pathname = currentUrl.pathname + `/l-quote/${props.position}`; 142 - 143 // Clear existing query parameters 144 currentUrl.search = ""; 145 146 currentUrl.hash = `#${pos?.start.block.join(".")}_${pos?.start.offset}`; 147 return [currentUrl.toString(), pos]; 148 }, [props.position]); 149 150 return ( 151 <> ··· 183 <CopyTiny className="shrink-0" /> 184 Link 185 </button> 186 - <Separator classname="h-4" /> 187 - 188 - {identity?.atp_did && ( 189 - <button 190 - className="flex gap-1 items-center hover:font-bold px-1" 191 - onClick={() => { 192 - if (!position) return; 193 - setInteractionState(document_uri, { 194 - drawer: "comments", 195 - drawerOpen: true, 196 - commentBox: { quote: position }, 197 - }); 198 - }} 199 - > 200 - <CommentTiny /> Comment 201 - </button> 202 )} 203 </> 204 );
··· 13 import { CommentTiny } from "components/Icons/CommentTiny"; 14 import { setInteractionState } from "./Interactions/Interactions"; 15 import { PostPageContext } from "./PostPageContext"; 16 + import { PubLeafletPublication } from "lexicons/api"; 17 18 export function QuoteHandler() { 19 let [position, setPosition] = useState<{ ··· 132 let { identity } = useIdentityData(); 133 const data = useContext(PostPageContext); 134 const document_uri = data?.uri; 135 + if (!document_uri) 136 + throw new Error("document_uri not available in PostPageContext"); 137 let [url, position] = useMemo(() => { 138 let currentUrl = new URL(window.location.href); 139 let pos = decodeQuotePosition(props.position); ··· 141 currentUrl.pathname = currentUrl.pathname.split("/l-quote/")[0]; 142 } 143 currentUrl.pathname = currentUrl.pathname + `/l-quote/${props.position}`; 144 + 145 // Clear existing query parameters 146 currentUrl.search = ""; 147 148 currentUrl.hash = `#${pos?.start.block.join(".")}_${pos?.start.offset}`; 149 return [currentUrl.toString(), pos]; 150 }, [props.position]); 151 + let pubRecord = data.documents_in_publications[0]?.publications?.record as 152 + | PubLeafletPublication.Record 153 + | undefined; 154 155 return ( 156 <> ··· 188 <CopyTiny className="shrink-0" /> 189 Link 190 </button> 191 + {pubRecord?.preferences?.showComments !== false && identity?.atp_did && ( 192 + <> 193 + <Separator classname="h-4" /> 194 + <button 195 + className="flex gap-1 items-center hover:font-bold px-1" 196 + onClick={() => { 197 + if (!position) return; 198 + setInteractionState(document_uri, { 199 + drawer: "comments", 200 + drawerOpen: true, 201 + commentBox: { quote: position }, 202 + }); 203 + }} 204 + > 205 + <CommentTiny /> Comment 206 + </button> 207 + </> 208 )} 209 </> 210 );