grid: OnboardingNotification consumes pike

This commit is contained in:
tomholford 2022-11-03 23:46:55 -07:00
parent 11445e2882
commit f8e4ec8915
3 changed files with 17 additions and 22 deletions

View File

@ -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(

View File

@ -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]));
}

View File

@ -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;
}