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) {
if (vat) {
const { ship, desk } = vat!.arak;
if (vat && vat.arak.rail) {
const { ship, desk } = vat.arak.rail;
return [ship, desk];
}
if ('chad' in docket) {

View File

@ -7,7 +7,8 @@ import { Attribute } from './Attribute';
export function VatMeta(props: { vat: Vat }) {
const { vat } = props;
const { desk, arak, cass, hash } = vat;
const { desk: foreignDesk, ship, next } = arak;
const { desk: foreignDesk, ship, next } = arak.rail!;
const pluralUpdates = next.length !== 1;
return (
<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 charge = useCharge(desk);
const vat = useVat(desk);
const otasEnabled = !vat?.arak.paused;
const otaSource = vat?.arak.ship;
const otasEnabled = !vat?.arak.rail?.paused;
const otaSource = vat?.arak.rail!.ship;
const toggleOTAs = useKilnState((s) => s.toggleOTAs);
const toggleUpdates = useCallback((on: boolean) => toggleOTAs(desk, on), [desk, toggleOTAs]);

View File

@ -12,8 +12,8 @@ export const SystemUpdatePrefs = () => {
_.pick(s, ['toggleOTAs', 'changeOTASource'])
);
const base = useVat('base');
const otasEnabled = base && !base.arak.paused;
const otaSource = base?.arak.ship;
const otasEnabled = base && !(base.arak?.rail ?? true);
const otaSource = base && base.arak.rail!.ship!;
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 {
const { vats } = useKilnState.getState();
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;
}
@ -23,6 +23,7 @@ type AppLinkProps = RouteComponentProps<{
function AppLink({ match, history, location }: AppLinkProps) {
const { ship, desk, link = '' } = match.params;
const ourDesk = getDeskByForeignRef(ship, desk);
console.log(ourDesk);
if (ourDesk) {
return <AppLinkRedirect desk={ourDesk} link={link} />;
@ -55,13 +56,13 @@ function AppLinkRedirect({ desk, link }: { desk: string; link: string }) {
return <Redirect to="/" />;
}
const LANDSCAPE_SHIP = '~zod';
const LANDSCAPE_DESK = 'groups';
const LANDSCAPE_DESK = 'landscape';
const LANDSCAPE_HOST = '~zod';
function LandscapeLink({ match }: RouteComponentProps<{ link: string }>) {
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() {

View File

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

View File

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

View File

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