diff --git a/src/app/features/desk/Desk.tsx b/src/app/features/desk/Desk.tsx index a09501e7..d6795ac4 100644 --- a/src/app/features/desk/Desk.tsx +++ b/src/app/features/desk/Desk.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useMemo } from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { Box, Icon, IconButton, Icons, Scroll, Text } from 'folds'; import { PhoneHit } from '../../styles/PhoneHit.css'; @@ -6,7 +6,7 @@ import { Page, PageContent, PageContentCenter, PageHeader } from '../../componen import { ScreenSize, useScreenSizeContext } from '../../hooks/useScreenSize'; import { getHomePath } from '../../pages/pathUtils'; import { DeskView } from './DeskView'; -import { unverifiedForks } from './optionsHash'; +import { useUnverified } from './useUnverified'; import { deskFor } from './source'; const labelOf = (mind: string) => mind.charAt(0).toUpperCase() + mind.slice(1); @@ -19,14 +19,7 @@ export function Desk() { const label = labelOf(mind); const list = useMemo(() => deskFor(mind), [mind]); // Until the recompute finishes nothing is flagged; a card that fails is withdrawn when it lands. - const [unverified, setUnverified] = useState>(new Set()); - useEffect(() => { - let live = true; - unverifiedForks(list?.forks ?? []).then((bad) => live && setUnverified(bad)); - return () => { - live = false; - }; - }, [list]); + const unverified = useUnverified(list); return ( diff --git a/src/app/features/desk/DeskEntry.tsx b/src/app/features/desk/DeskEntry.tsx index a0c3244c..8d772339 100644 --- a/src/app/features/desk/DeskEntry.tsx +++ b/src/app/features/desk/DeskEntry.tsx @@ -3,11 +3,11 @@ import { Box, Icon, Icons, Text } from 'folds'; import { NavGutter, NavItem, NavItemContent, NavLink } from '../../components/nav'; import { NAV_ROOM_ICON_REST_OPACITY, NavLabel } from '../../components/nav/styles.css'; import { getDeskPath } from '../../pages/pathUtils'; +import { buildDesk } from './buildDesk'; import { deskFor } from './source'; +import { useUnverified } from './useUnverified'; -/** A Mind's desk, pinned at the top of its navigator group: always there, with the open count when there is one. */ -export function DeskEntry({ mind }: { mind: string }) { - const open = deskFor(mind)?.open_count ?? 0; +export function DeskLink({ mind, open }: { mind: string; open: number }) { return ( @@ -29,3 +29,11 @@ export function DeskEntry({ mind }: { mind: string }) { ); } + +/** A Mind's desk, pinned at the top of its navigator group: always there, with the open count when there is one. */ +export function DeskEntry({ mind }: { mind: string }) { + const list = deskFor(mind); + const unverified = useUnverified(list); + // The same count the desk page shows; until the hash check lands there is no count to show. + return ; +} diff --git a/src/app/features/desk/DeskView.test.tsx b/src/app/features/desk/DeskView.test.tsx index 1bc7aa59..45529020 100644 --- a/src/app/features/desk/DeskView.test.tsx +++ b/src/app/features/desk/DeskView.test.tsx @@ -5,8 +5,8 @@ import { afterEach, describe, expect, it, vi } from 'vitest'; import { ScreenSize, ScreenSizeProvider } from '../../hooks/useScreenSize'; import { SkyInkContextProvider } from '../../hooks/useTheme'; import { SCRIM_GROUND, SCRIM_INK } from '../scene/skyInk'; -import { DeskEntry } from './DeskEntry'; -import { DeskView, SIGN_IN_NOTE } from './DeskView'; +import { DeskEntry, DeskLink } from './DeskEntry'; +import { DeskView, SIGN_IN_NOTE, rowOpen } from './DeskView'; import { ForkList } from './forkContract'; import { STATES } from './fixtures'; import { setDeskSource } from './source'; @@ -119,8 +119,8 @@ describe('DeskView', () => { const html = view('noAnswers', ScreenSize.Desktop, 'void', new Set(['c:question:plain'])); expect(html).toContain('does not match the hash it was published with'); expect(html).not.toContain('First way'); - expect(html).toContain('1 open.'); - expect(html).not.toContain('Nothing is waiting'); + expect(html).toContain('Nothing is waiting on you from Void.'); + expect(html).not.toContain('1 open.'); }); it('never claims an empty desk while the list says forks are open, whatever rows it could show', () => { setDeskSource(() => undefined); @@ -132,6 +132,29 @@ describe('DeskView', () => { expect(html).toContain('3 open.'); expect(html).not.toContain('Nothing is waiting'); }); + it('says every row is read-only for a signed-out viewer, in every state the fixtures hold', () => { + (['noAnswers', 'blocked', 'answered', 'settled'] as const).forEach((state) => { + const html = view(state, ScreenSize.Desktop); + const rows = html.match(/