From b23293228d052d7c603417e308b2267726fbedb7 Mon Sep 17 00:00:00 2001 From: tomholford Date: Thu, 3 Nov 2022 22:58:12 -0700 Subject: [PATCH] grid: AppPrefs consumes pike --- ui/src/preferences/AppPrefs.tsx | 10 +++++----- ui/src/state/kiln.ts | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ui/src/preferences/AppPrefs.tsx b/ui/src/preferences/AppPrefs.tsx index 9ce6216..763d493 100644 --- a/ui/src/preferences/AppPrefs.tsx +++ b/ui/src/preferences/AppPrefs.tsx @@ -3,16 +3,16 @@ import { RouteComponentProps } from 'react-router-dom'; import { Setting } from '../components/Setting'; import { ShipName } from '../components/ShipName'; import { useCharge } from '../state/docket'; -import useKilnState, { useVat } from '../state/kiln'; +import useKilnState, { usePike, useVat } from '../../state/kiln'; import { getAppName } from '../state/util'; export const AppPrefs = ({ match }: RouteComponentProps<{ desk: string }>) => { const { desk } = match.params; const charge = useCharge(desk); - const vat = useVat(desk); - const tracking = !!vat?.arak.rail; - const otasEnabled = !vat?.arak.rail?.paused; - const otaSource = vat?.arak.rail?.ship; + const pike = usePike(desk); + const tracking = !!pike?.sync; + const otasEnabled = pike?.zest === 'live'; + const otaSource = pike?.sync?.ship; const toggleOTAs = useKilnState((s) => s.toggleOTAs); const toggleUpdates = useCallback((on: boolean) => toggleOTAs(desk, on), [desk, toggleOTAs]); diff --git a/ui/src/state/kiln.ts b/ui/src/state/kiln.ts index 2d65044..36c4089 100644 --- a/ui/src/state/kiln.ts +++ b/ui/src/state/kiln.ts @@ -8,7 +8,8 @@ import { kilnPause, kilnResume, getPikes, - Pikes + Pikes, + Pike } from '@urbit/api'; import create from 'zustand'; import produce from 'immer'; @@ -92,6 +93,10 @@ export function useVat(desk: string): Vat | undefined { return useKilnState(useCallback((s) => s.vats[desk], [desk])); } +export function usePike(desk: string): Pike | undefined { + return useKilnState(useCallback((s) => s.pikes[desk], [desk])); +} + const selLag = (s: KilnState) => s.lag; export function useLag() { return useKilnState(selLag);