grid: fix breakage caused by type change

This commit is contained in:
Liam Fitzgerald 2021-09-21 14:13:02 +10:00
parent 079b6cea2e
commit 4792776f07
8 changed files with 31 additions and 19 deletions

View File

@ -36,8 +36,8 @@ function getInstallStatus(docket: App): InstallStatus {
} }
function getRemoteDesk(docket: App, vat?: Vat) { function getRemoteDesk(docket: App, vat?: Vat) {
if (vat) { if (vat && vat.arak.rail) {
const { ship, desk } = vat!.arak; const { ship, desk } = vat.arak.rail;
return [ship, desk]; return [ship, desk];
} }
if ('chad' in docket) { if ('chad' in docket) {

View File

@ -7,7 +7,8 @@ import { Attribute } from './Attribute';
export function VatMeta(props: { vat: Vat }) { export function VatMeta(props: { vat: Vat }) {
const { vat } = props; const { vat } = props;
const { desk, arak, cass, hash } = vat; const { desk, arak, cass, hash } = vat;
const { desk: foreignDesk, ship, next } = arak;
const { desk: foreignDesk, ship, next } = arak.rail!;
const pluralUpdates = next.length !== 1; const pluralUpdates = next.length !== 1;
return ( return (
<div className="mt-5 sm:mt-8 space-y-5 sm:space-y-8"> <div className="mt-5 sm:mt-8 space-y-5 sm:space-y-8">

View File

@ -9,8 +9,8 @@ export const AppPrefs = ({ match }: RouteComponentProps<{ desk: string }>) => {
const { desk } = match.params; const { desk } = match.params;
const charge = useCharge(desk); const charge = useCharge(desk);
const vat = useVat(desk); const vat = useVat(desk);
const otasEnabled = !vat?.arak.paused; const otasEnabled = !vat?.arak.rail?.paused;
const otaSource = vat?.arak.ship; const otaSource = vat?.arak.rail!.ship;
const toggleOTAs = useKilnState((s) => s.toggleOTAs); const toggleOTAs = useKilnState((s) => s.toggleOTAs);
const toggleUpdates = useCallback((on: boolean) => toggleOTAs(desk, on), [desk, toggleOTAs]); const toggleUpdates = useCallback((on: boolean) => toggleOTAs(desk, on), [desk, toggleOTAs]);

View File

@ -12,8 +12,8 @@ export const SystemUpdatePrefs = () => {
_.pick(s, ['toggleOTAs', 'changeOTASource']) _.pick(s, ['toggleOTAs', 'changeOTASource'])
); );
const base = useVat('base'); const base = useVat('base');
const otasEnabled = base && !base.arak.paused; const otasEnabled = base && !(base.arak?.rail ?? true);
const otaSource = base?.arak.ship; const otaSource = base && base.arak.rail!.ship!;
const toggleBase = useCallback((on: boolean) => toggleOTAs('base', on), [toggleOTAs]); const toggleBase = useCallback((on: boolean) => toggleOTAs('base', on), [toggleOTAs]);

View File

@ -9,7 +9,7 @@ import { getAppHref } from '../state/util';
function getDeskByForeignRef(ship: string, desk: string): string | undefined { function getDeskByForeignRef(ship: string, desk: string): string | undefined {
const { vats } = useKilnState.getState(); const { vats } = useKilnState.getState();
const found = Object.entries(vats).find( const found = Object.entries(vats).find(
([, vat]) => vat.arak.ship === ship && vat.arak.desk === desk ([, vat]) => vat.arak.rail?.ship === ship && vat.arak.rail?.desk === desk
); );
return found ? found[0] : undefined; return found ? found[0] : undefined;
} }
@ -23,6 +23,7 @@ type AppLinkProps = RouteComponentProps<{
function AppLink({ match, history, location }: AppLinkProps) { function AppLink({ match, history, location }: AppLinkProps) {
const { ship, desk, link = '' } = match.params; const { ship, desk, link = '' } = match.params;
const ourDesk = getDeskByForeignRef(ship, desk); const ourDesk = getDeskByForeignRef(ship, desk);
console.log(ourDesk);
if (ourDesk) { if (ourDesk) {
return <AppLinkRedirect desk={ourDesk} link={link} />; return <AppLinkRedirect desk={ourDesk} link={link} />;
@ -55,13 +56,13 @@ function AppLinkRedirect({ desk, link }: { desk: string; link: string }) {
return <Redirect to="/" />; return <Redirect to="/" />;
} }
const LANDSCAPE_SHIP = '~zod'; const LANDSCAPE_DESK = 'landscape';
const LANDSCAPE_DESK = 'groups'; const LANDSCAPE_HOST = '~zod';
function LandscapeLink({ match }: RouteComponentProps<{ link: string }>) { function LandscapeLink({ match }: RouteComponentProps<{ link: string }>) {
const { link } = match.params; const { link } = match.params;
return <Redirect to={`/perma/${LANDSCAPE_SHIP}/${LANDSCAPE_DESK}/${link}`} />; return <Redirect to={`/perma/${LANDSCAPE_HOST}/${LANDSCAPE_DESK}/group/${link}`} />;
} }
export function PermalinkRoutes() { export function PermalinkRoutes() {

View File

@ -252,6 +252,8 @@ export function allyForTreaty(ship: string, desk: string) {
return ally; return ally;
} }
export const landscapeTreatyHost = import.meta.env.LANDSCAPE_HOST as string;
// xx useful for debugging // xx useful for debugging
window.docket = useDocketState.getState; window.docket = useDocketState.getState;

View File

@ -39,7 +39,10 @@ const useKilnState = create<KilnState>((set, get) => ({
await fakeRequest(''); await fakeRequest('');
set( set(
produce((draft: KilnState) => { produce((draft: KilnState) => {
draft.vats.base.arak.ship = ship; if (!draft.vats.base.arak.rail) {
return;
}
draft.vats.base.arak.rail.ship = ship;
}) })
); );
return; return;
@ -53,11 +56,14 @@ const useKilnState = create<KilnState>((set, get) => ({
set( set(
produce((draft: KilnState) => { produce((draft: KilnState) => {
const { arak } = draft.vats[desk]; const { arak } = draft.vats[desk];
if (!arak.rail) {
return;
}
if (on) { if (on) {
arak.paused = false; arak.rail.paused = false;
} else { } else {
arak.paused = true; arak.rail.paused = true;
} }
}) })
); );

View File

@ -335,11 +335,13 @@ export const mockVat = (desk: string, blockers?: boolean): Vat => ({
sub: [], sub: [],
add: [] add: []
}, },
aeon: 3, rail: {
desk, aeon: 3,
next: blockers ? [{ aeon: 3, weft: { name: 'zuse', kelvin: 419 } }] : [], desk,
ship: '~zod', next: blockers ? [{ aeon: 3, weft: { name: 'zuse', kelvin: 419 } }] : [],
paused: false ship: '~zod',
paused: false
}
}, },
hash: '0vh.lhfn6.julg1.fs52d.g2lqj.q5kp0.2o7j3.2bljl.jdm34.hd46v.9uv5v' hash: '0vh.lhfn6.julg1.fs52d.g2lqj.q5kp0.2o7j3.2bljl.jdm34.hd46v.9uv5v'
}); });