mirror of
https://github.com/tloncorp/landscape.git
synced 2024-12-18 14:21:53 +03:00
grid: SystemNotifications consumes pike
This commit is contained in:
parent
b23293228d
commit
5eaed93868
@ -1,27 +1,23 @@
|
||||
import { kilnBump, Vat } from '@urbit/api';
|
||||
import { kilnBump, Pike } from '@urbit/api';
|
||||
import { partition, pick } from 'lodash';
|
||||
import { useCallback } from 'react';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
import api from '../state/api';
|
||||
import { useCharges } from '../state/docket';
|
||||
import useKilnState, { useVat } from '../state/kiln';
|
||||
import useKilnState, { usePike } from '../../state/kiln';
|
||||
|
||||
export function vatIsBlocked(newKelvin: number | undefined, vat: Vat) {
|
||||
if (!newKelvin) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !(vat.arak?.rail?.next || []).find(({ weft }) => weft.kelvin === newKelvin);
|
||||
function pikeIsBlocked(newKelvin: number, pike: Pike) {
|
||||
return !pike.wefts?.find(({ kelvin }) => kelvin === newKelvin);
|
||||
}
|
||||
|
||||
export function useSystemUpdate() {
|
||||
const { push } = useHistory();
|
||||
const base = useVat('base');
|
||||
const basePike = usePike('base');
|
||||
const update = base?.arak?.rail?.next?.[0];
|
||||
const newKelvin = update?.weft?.kelvin;
|
||||
const newKelvin = basePike?.wefts[0]?.kelvin ?? 418;
|
||||
const charges = useCharges();
|
||||
const [blocked] = useKilnState((s) => {
|
||||
const [b, u] = partition(Object.entries(s.vats), ([, vat]) => vatIsBlocked(newKelvin, vat));
|
||||
const [b, u] = partition(Object.entries(s.pikes), ([, pike]) => pikeIsBlocked(newKelvin, pike));
|
||||
return [b.map(([d]) => d), u.map(([d]) => d)] as const;
|
||||
});
|
||||
|
||||
|
@ -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 }>) => {
|
||||
|
Loading…
Reference in New Issue
Block a user