From f8e4ec89157faed82e5f4fcf28a17b7251b0fb77 Mon Sep 17 00:00:00 2001 From: tomholford Date: Thu, 3 Nov 2022 23:46:55 -0700 Subject: [PATCH] grid: OnboardingNotification consumes pike --- .../notifications/OnboardingNotification.tsx | 28 +++++-------------- pkg/grid/src/state/kiln.ts | 5 ++++ pkg/npm/api/hood/lib.ts | 6 +++- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/pkg/grid/src/nav/notifications/OnboardingNotification.tsx b/pkg/grid/src/nav/notifications/OnboardingNotification.tsx index bd9af8947..df6a8896e 100644 --- a/pkg/grid/src/nav/notifications/OnboardingNotification.tsx +++ b/pkg/grid/src/nav/notifications/OnboardingNotification.tsx @@ -1,15 +1,15 @@ import React from 'react'; import cn from 'classnames'; import { Link } from 'react-router-dom'; -import { HarkLid, Vats, getVatPublisher } from '@urbit/api'; +import { HarkLid, Pikes, getPikePublisher } from '@urbit/api'; import { Button } from '../../components/Button'; import { useBrowserId, useCurrentTheme } from '../../state/local'; import { getDarkColor } from '../../state/util'; -import useKilnState from '../../state/kiln'; +import { usePikes } from '../../state/kiln'; import { useHarkStore } from '../../state/hark'; import { useProtocolHandling } from '../../state/settings'; -const getCards = (vats: Vats, protocol: boolean): OnboardingCardProps[] => { +const getCards = (pikes: Pikes, protocol: boolean): OnboardingCardProps[] => { const cards = [ { title: 'Terminal', @@ -38,20 +38,6 @@ const getCards = (vats: Vats, protocol: boolean): OnboardingCardProps[] => { ship: '~mister-dister-dozzod-dozzod', desk: 'bitcoin' } - // Commenting out until we have something real - // { - // title: 'Debug', - // body: "Install a debugger. You can inspect your ship's internals using this interface", - // button: 'Install', - // color: '#E5E5E5', - // href: '/leap/search/direct/apps/~zod/debug' - // } - // { - // title: 'Build an app', - // body: 'You can instantly get started building new things on Urbit. Just right click your Landscape and select “New App”', - // button: 'Learn more', - // color: '#82A6CA' - // } ]; if ('registerProtocolHandler' in window.navigator && !protocol) { cards.push({ @@ -66,8 +52,8 @@ const getCards = (vats: Vats, protocol: boolean): OnboardingCardProps[] => { } return cards.filter((card) => { - return !Object.values(vats).find( - (vat) => getVatPublisher(vat) == card.ship && vat?.arak?.rail?.desk === card.desk + return !Object.values(pikes).find( + (pike) => getPikePublisher(pike) === card.ship && pike.sync?.desk === card.desk ); }); }; @@ -107,10 +93,10 @@ interface OnboardingNotificationProps { export const OnboardingNotification = ({ unread = false, lid }: OnboardingNotificationProps) => { const theme = useCurrentTheme(); - const vats = useKilnState((s) => s.vats); + const pikes = usePikes(); const browserId = useBrowserId(); const protocolHandling = useProtocolHandling(browserId); - const cards = getCards(vats, protocolHandling); + const cards = getCards(pikes, protocolHandling); if (cards.length === 0 && !('time' in lid)) { useHarkStore.getState().archiveNote( diff --git a/pkg/grid/src/state/kiln.ts b/pkg/grid/src/state/kiln.ts index 4c7341b69..537ba3f8c 100644 --- a/pkg/grid/src/state/kiln.ts +++ b/pkg/grid/src/state/kiln.ts @@ -112,6 +112,11 @@ export function useVat(desk: string): Vat | undefined { return useKilnState(useCallback((s) => s.vats[desk], [desk])); } +const selPikes = (s: KilnState) => s.pikes; +export function usePikes(): Pikes { + return useKilnState(selPikes); +} + export function usePike(desk: string): Pike | undefined { return useKilnState(useCallback((s) => s.pikes[desk], [desk])); } diff --git a/pkg/npm/api/hood/lib.ts b/pkg/npm/api/hood/lib.ts index a4291bf2b..a13f8d838 100644 --- a/pkg/npm/api/hood/lib.ts +++ b/pkg/npm/api/hood/lib.ts @@ -1,5 +1,5 @@ import { Poke, Scry } from '../lib'; -import { Vats, Vat } from './types'; +import { Vats, Vat, Pike } from './types'; export const getVats: Scry = { app: 'hood', @@ -121,3 +121,7 @@ export function getVatPublisher(vat: Vat): string | undefined { } return undefined; } + +export function getPikePublisher(pike: Pike) { + return pike.sync?.ship; +}