From 84ea05f17b41ab89eb2d79d2edef9cb3a1c1f8eb Mon Sep 17 00:00:00 2001 From: tomholford Date: Thu, 3 Nov 2022 23:21:04 -0700 Subject: [PATCH] grid: SystemNotifications consumes pike --- .../nav/notifications/SystemNotification.tsx | 21 +++++++++---------- pkg/grid/src/nav/preferences/AppPrefs.tsx | 2 +- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkg/grid/src/nav/notifications/SystemNotification.tsx b/pkg/grid/src/nav/notifications/SystemNotification.tsx index 6a8320e864..3ab57dd7e8 100644 --- a/pkg/grid/src/nav/notifications/SystemNotification.tsx +++ b/pkg/grid/src/nav/notifications/SystemNotification.tsx @@ -1,18 +1,17 @@ -import { pick, pickBy, partition } from 'lodash'; +import { pick, partition } from 'lodash'; import React, { useCallback } from 'react'; -import { kilnBump } from '@urbit/api'; +import { kilnBump, Pike } from '@urbit/api'; +import { useHistory } from 'react-router-dom'; import { AppList } from '../../components/AppList'; import { Button } from '../../components/Button'; import { Dialog, DialogClose, DialogContent, DialogTrigger } from '../../components/Dialog'; import { Elbow } from '../../components/icons/Elbow'; import api from '../../state/api'; import { useCharges } from '../../state/docket'; -import useKilnState, { useVat } from '../../state/kiln'; +import useKilnState, { usePike } from '../../state/kiln'; import { NotificationButton } from './NotificationButton'; import { disableDefault } from '../../state/util'; -import { Vat } from '@urbit/api'; -import {useHistory} from 'react-router-dom'; export const RuntimeLagNotification = () => (
(
); -function vatIsBlocked(newKelvin: number, vat: Vat) { - return !(vat.arak?.rail?.next || []).find(({ aeon, weft }) => weft.kelvin === newKelvin); +function pikeIsBlocked(newKelvin: number, pike: Pike) { + return !pike.wefts?.find(({ kelvin }) => kelvin === newKelvin); } export const BaseBlockedNotification = () => { - const base = useVat('base'); + const basePike = usePike('base'); const { push } = useHistory(); // TODO: assert weft.name === 'zuse'?? - const newKelvin = base?.arak?.rail?.next?.[0]?.weft?.kelvin || 420; + const newKelvin = basePike?.wefts[0]?.kelvin ?? 418; const charges = useCharges(); - const [blocked, unblocked] = useKilnState((s) => { - const [b, u] = partition(Object.entries(s.vats), ([desk, vat]) => vatIsBlocked(newKelvin, vat)); + const [blocked] = useKilnState((s) => { + const [b, u] = partition(Object.entries(s.pikes), ([, pike]) => pikeIsBlocked(newKelvin, pike)); return [b.map(([d]) => d), u.map(([d]) => d)] as const; }); diff --git a/pkg/grid/src/nav/preferences/AppPrefs.tsx b/pkg/grid/src/nav/preferences/AppPrefs.tsx index aef7114489..91109cd23c 100644 --- a/pkg/grid/src/nav/preferences/AppPrefs.tsx +++ b/pkg/grid/src/nav/preferences/AppPrefs.tsx @@ -3,7 +3,7 @@ import { RouteComponentProps } from 'react-router-dom'; import { Setting } from '../../components/Setting'; import { ShipName } from '../../components/ShipName'; import { useCharge } from '../../state/docket'; -import useKilnState, { usePike, useVat } from '../../state/kiln'; +import useKilnState, { usePike } from '../../state/kiln'; import { getAppName } from '../../state/util'; export const AppPrefs = ({ match }: RouteComponentProps<{ desk: string }>) => {