hash: fixing vat missing issue

This commit is contained in:
Hunter Miller 2021-09-03 18:31:38 -05:00
parent dea33d9019
commit 8ea33cc081
2 changed files with 16 additions and 14 deletions

View File

@ -24,7 +24,7 @@ export const SystemMenu = ({ className, menu, open, navOpen }: SystemMenuProps)
const { push } = useHistory();
const [copied, setCopied] = useState(false);
const garden = useVat('garden');
const hash = getHash(garden);
const hash = garden ? getHash(garden) : null;
const copyHash = useCallback((event: Event) => {
event.preventDefault();
@ -107,17 +107,19 @@ export const SystemMenu = ({ className, menu, open, navOpen }: SystemMenuProps)
<span className="w-5 h-5 bg-gray-100 rounded-full" />
<span className="h4">About Landscape</span>
</DropdownMenu.Item>
<DropdownMenu.Item
as="button"
className="inline-flex items-center py-2 px-3 m-2 h4 text-black bg-gray-100 rounded focus:bg-blue-200 focus:outline-none"
onSelect={copyHash}
>
<span className="sr-only">Base Hash</span>
<code>
{!copied && <span aria-label={hash.split('').join('-')}>{hash}</span>}
{copied && 'copied!'}
</code>
</DropdownMenu.Item>
{hash && (
<DropdownMenu.Item
as="button"
className="inline-flex items-center py-2 px-3 m-2 h4 text-black bg-gray-100 rounded focus:bg-blue-200 focus:outline-none"
onSelect={copyHash}
>
<span className="sr-only">Base Hash</span>
<code>
{!copied && <span aria-label={hash.split('').join('-')}>{hash}</span>}
{copied && 'copied!'}
</code>
</DropdownMenu.Item>
)}
</DropdownMenu.Group>
</DropdownMenu.Content>
</Route>

View File

@ -1,4 +1,4 @@
import { getVats, Vats, scryLag, getBlockers } from '@urbit/api';
import { getVats, Vats, scryLag, getBlockers, Vat } from '@urbit/api';
import create from 'zustand';
import produce from 'immer';
import { useCallback } from 'react';
@ -44,7 +44,7 @@ export function useBlockers() {
return useKilnState(selBlockers);
}
export function useVat(desk: string) {
export function useVat(desk: string): Vat | undefined {
return useKilnState(useCallback((s) => s.vats[desk], [desk]));
}