a tool for shared writing and social publishing

added the looseleaf page

+113 -5
+62
app/(home-pages)/looseleafs/LooseleafsLayout.tsx
··· 1 + "use client"; 2 + import { DashboardLayout } from "components/PageLayouts/DashboardLayout"; 3 + import { useCardBorderHidden } from "components/Pages/useCardBorderHidden"; 4 + import { useState } from "react"; 5 + import { useDebouncedEffect } from "src/hooks/useDebouncedEffect"; 6 + import { Fact } from "src/replicache"; 7 + import { Attribute } from "src/replicache/attributes"; 8 + import { Actions } from "../home/Actions/Actions"; 9 + 10 + export const LooseleafsLayout = (props: { 11 + entityID: string | null; 12 + titles: { [root_entity: string]: string }; 13 + initialFacts: { 14 + [root_entity: string]: Fact<Attribute>[]; 15 + }; 16 + }) => { 17 + let [searchValue, setSearchValue] = useState(""); 18 + let [debouncedSearchValue, setDebouncedSearchValue] = useState(""); 19 + 20 + useDebouncedEffect( 21 + () => { 22 + setDebouncedSearchValue(searchValue); 23 + }, 24 + 200, 25 + [searchValue], 26 + ); 27 + 28 + let cardBorderHidden = !!useCardBorderHidden(props.entityID); 29 + return ( 30 + <DashboardLayout 31 + id="looseleafs" 32 + cardBorderHidden={cardBorderHidden} 33 + currentPage="looseleafs" 34 + defaultTab="home" 35 + actions={<Actions />} 36 + tabs={{ 37 + home: { 38 + controls: null, 39 + content: ( 40 + <LooseleafList 41 + titles={props.titles} 42 + initialFacts={props.initialFacts} 43 + cardBorderHidden={cardBorderHidden} 44 + searchValue={debouncedSearchValue} 45 + /> 46 + ), 47 + }, 48 + }} 49 + /> 50 + ); 51 + }; 52 + 53 + export const LooseleafList = (props: { 54 + titles: { [root_entity: string]: string }; 55 + initialFacts: { 56 + [root_entity: string]: Fact<Attribute>[]; 57 + }; 58 + searchValue: string; 59 + cardBorderHidden: boolean; 60 + }) => { 61 + return <div>hello</div>; 62 + };
+46
app/(home-pages)/looseleafs/page.tsx
··· 1 + import { getIdentityData } from "actions/getIdentityData"; 2 + import { DashboardLayout } from "components/PageLayouts/DashboardLayout"; 3 + import { Actions } from "../home/Actions/Actions"; 4 + import { Fact } from "src/replicache"; 5 + import { Attribute } from "src/replicache/attributes"; 6 + import { getFactsFromHomeLeaflets } from "app/api/rpc/[command]/getFactsFromHomeLeaflets"; 7 + import { supabaseServerClient } from "supabase/serverClient"; 8 + import { LooseleafsLayout } from "./LooseleafsLayout"; 9 + 10 + export default async function Home() { 11 + let auth_res = await getIdentityData(); 12 + 13 + let [allLeafletFacts] = await Promise.all([ 14 + auth_res 15 + ? getFactsFromHomeLeaflets.handler( 16 + { 17 + tokens: auth_res.permission_token_on_homepage.map( 18 + (r) => r.permission_tokens.root_entity, 19 + ), 20 + }, 21 + { supabase: supabaseServerClient }, 22 + ) 23 + : undefined, 24 + ]); 25 + 26 + let home_docs_initialFacts = allLeafletFacts?.result || {}; 27 + 28 + return ( 29 + <LooseleafsLayout 30 + entityID={auth_res?.home_leaflet?.root_entity || null} 31 + titles={{ 32 + ...home_docs_initialFacts.titles, 33 + ...auth_res?.permission_token_on_homepage.reduce( 34 + (acc, tok) => { 35 + let title = 36 + tok.permission_tokens.leaflets_in_publications[0]?.title; 37 + if (title) acc[tok.permission_tokens.root_entity] = title; 38 + return acc; 39 + }, 40 + {} as { [k: string]: string }, 41 + ), 42 + }} 43 + initialFacts={home_docs_initialFacts.facts || {}} 44 + /> 45 + ); 46 + }
+1 -1
app/[leaflet_id]/actions/PublishButton.tsx
··· 286 286 <LooseLeafSmall className="shrink-0" /> 287 287 <div className="flex flex-col leading-snug"> 288 288 <div className="text-secondary font-bold"> 289 - Publish as LooseLeaf 289 + Publish as Looseleaf 290 290 </div> 291 291 <div className="text-tertiary text-sm font-normal"> 292 292 Publish this as a one off doc to AT Proto
+1 -1
components/ActionBar/Navigation.tsx
··· 24 24 | "pub" 25 25 | "discover" 26 26 | "notifications" 27 - | "looseleaf"; 27 + | "looseleafs"; 28 28 29 29 export const DesktopNavigation = (props: { 30 30 currentPage: navPages;
+3 -3
components/ActionBar/Publications.tsx
··· 35 35 {looseleaves.length > 0 && ( 36 36 <> 37 37 <SpeedyLink 38 - href={`/lish/looseleaf`} 38 + href={`/looseleafs`} 39 39 className="flex gap-2 items-start text-secondary font-bold hover:no-underline! hover:text-accent-contrast w-full" 40 40 > 41 41 {/*TODO How should i get if this is the current page or not? 42 42 theres not "pub" to check the uri for. Do i need to add it as an option to NavPages? thats kinda annoying*/} 43 43 <ActionButton 44 - label="LooseLeafs" 44 + label="Looseleafs" 45 45 icon={<LooseLeafSmall />} 46 46 nav 47 47 className={ 48 - props.currentPage === "looseleaf" 48 + props.currentPage === "looseleafs" 49 49 ? "bg-bg-page! border-border!" 50 50 : "" 51 51 }