a tool for shared writing and social publishing
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

add flag if leaflet is in publication or published

+13 -4
+1 -1
actions/getIdentityData.ts
··· 18 18 subscribers_to_publications(*), 19 19 custom_domains(*), 20 20 home_leaflet:permission_tokens!identities_home_page_fkey(*, permission_token_rights(*)), 21 - permission_token_on_homepage(created_at, permission_tokens!inner(id, root_entity, permission_token_rights(*))) 21 + permission_token_on_homepage(created_at, permission_tokens!inner(id, root_entity, permission_token_rights(*), leaflets_in_publications(*))) 22 22 )`, 23 23 ) 24 24 .eq("id", auth_token)
+6 -2
app/home/LeafletList.tsx
··· 3 3 import { useEffect, useState } from "react"; 4 4 import { getHomeDocs, HomeDoc } from "./storage"; 5 5 import useSWR from "swr"; 6 - import { Fact, ReplicacheProvider } from "src/replicache"; 6 + import { Fact, PermissionToken, ReplicacheProvider } from "src/replicache"; 7 7 import { LeafletPreview } from "./LeafletPreview"; 8 8 import { useIdentityData } from "components/IdentityProvider"; 9 9 import type { Attribute } from "src/replicache/attributes"; ··· 36 36 useEffect(() => { 37 37 mutate(); 38 38 }, [localLeaflets.length, mutate]); 39 - let leaflets = identity 39 + let leaflets: Array< 40 + PermissionToken & { leaflets_in_publications?: Array<{ doc: string }> } 41 + > = identity 40 42 ? identity.permission_token_on_homepage 41 43 .sort((a, b) => 42 44 a.created_at === b.created_at ··· 69 71 <LeafletPreview 70 72 index={index} 71 73 token={leaflet} 74 + draft={!!leaflet.leaflets_in_publications?.length} 75 + published={!!leaflet.leaflets_in_publications?.find((l) => l.doc)} 72 76 leaflet_id={leaflet.root_entity} 73 77 loggedIn={!!identity} 74 78 />
+2
app/home/LeafletPreview.tsx
··· 31 31 } from "components/Pages/PublicationMetadata"; 32 32 33 33 export const LeafletPreview = (props: { 34 + draft?: boolean; 35 + published?: boolean; 34 36 index: number; 35 37 token: PermissionToken; 36 38 leaflet_id: string;
+4 -1
components/HomeButton.tsx
··· 55 55 ...identity.permission_token_on_homepage, 56 56 { 57 57 created_at: new Date().toISOString(), 58 - permission_tokens: permission_token, 58 + permission_tokens: { 59 + ...permission_token, 60 + leaflets_in_publications: [], 61 + }, 59 62 }, 60 63 ], 61 64 };