From d3802fa0c011969d2f3f6b2e2cb632ed8281636a Mon Sep 17 00:00:00 2001 From: Liam Fitzgerald Date: Wed, 22 Sep 2021 12:01:33 +1000 Subject: [PATCH] interface: render app preview in link block --- .../apps/links/components/LinkBlocks.tsx | 14 ++++--- .../src/views/apps/permalinks/embed.tsx | 2 +- .../views/components/RemoteContent/embed.tsx | 38 ++++++++++++++++++- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/pkg/interface/src/views/apps/links/components/LinkBlocks.tsx b/pkg/interface/src/views/apps/links/components/LinkBlocks.tsx index 1fc7fa2945..0c24912e0b 100644 --- a/pkg/interface/src/views/apps/links/components/LinkBlocks.tsx +++ b/pkg/interface/src/views/apps/links/components/LinkBlocks.tsx @@ -9,7 +9,7 @@ import useLocalState from '~/logic/state/local'; import BigIntOrderedMap from '@urbit/api/lib/BigIntOrderedMap'; import bigInt from 'big-integer'; import airlock from '~/logic/api'; -import useHarkState from '~/logic/state/hark'; +import useHarkState, { selHarkGraph } from '~/logic/state/hark'; import { BlockScroller } from '~/views/components/BlockScroller'; export interface LinkBlocksProps { @@ -46,11 +46,13 @@ export function LinkBlocks(props: LinkBlocksProps) { ); useEffect(() => { - const unreads = - useHarkState.getState().unreads.graph?.[association.resource]?.['/'] - ?.unreads || new Set(); - Array.from(unreads as Set).forEach((u) => { - airlock.poke(markEachAsRead(association.resource, '/', u)); + const unreads = selHarkGraph(association.resource)(useHarkState.getState()); + const [,,ship,name] = association.resource.split('/'); + unreads.each.forEach((u) => { + airlock.poke(markEachAsRead({ + desk: (window as any).desk, + path: `/graph/${ship}/${name}` + }, u)); }); }, [association.resource]); diff --git a/pkg/interface/src/views/apps/permalinks/embed.tsx b/pkg/interface/src/views/apps/permalinks/embed.tsx index b86595c60c..e15698c557 100644 --- a/pkg/interface/src/views/apps/permalinks/embed.tsx +++ b/pkg/interface/src/views/apps/permalinks/embed.tsx @@ -198,7 +198,7 @@ const ClampedText = styled(Text)` type AppTileProps = Treaty & BoxProps; -function AppTile({ color, image, ...props }: AppTileProps) { +export function AppTile({ color, image, ...props }: AppTileProps) { return ( ; } else if (permalink.type === 'group') { return ; + } else if (permalink.type === 'app') { + return ; } return null; } +function RemoteContentPermalinkEmbedApp({ link, ship, desk }: Omit) { + const treaty = useTreaty(ship, desk); + + useEffect(() => { + if (!treaty) { + useDocketState.getState().requestTreaty(ship, desk); + } + }, [treaty, ship, desk]); + + return ( + + {treaty && ( + <> + + App: {treaty.title} + + )} + + ); +} + function RemoteContentPermalinkEmbedGroup(props: { group: string; link: string;