grid: AppPrefs consumes pike

This commit is contained in:
tomholford 2022-11-03 22:58:12 -07:00
parent a92fb139f0
commit b23293228d
2 changed files with 11 additions and 6 deletions

View File

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

View File

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