Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions components/bookmarks-command-center/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { useAppToast } from "@/lib/toast";
import { COMMAND_CENTER_ITEMS_PER_PAGE } from "@/lib/constants/view-modes";
import type { BookmarkSortBy } from "@/lib/types";
import { LibraryPageShell } from "@/components/evidence-libraries/library-page-shell";
import { ListLoading } from "@/components/evidence-libraries/list-controls";
import { ListLoading, STALE_ROWS } from "@/components/evidence-libraries/list-controls";
import { usePersistedStoreReady } from "@/lib/use-persisted-store-ready";
import { useResearchStatus } from "@/lib/research/provider";
import { ResearchAccountChangedError } from "@/lib/research/binding";
Expand Down Expand Up @@ -224,7 +224,7 @@ export function BookmarksCommandCenter() {
>

{/* A page kept from before the filter, sort or search changed is dimmed and takes no clicks until its own arrives. */}
<div className={cn(bookmarks.isStale && "opacity-60")} inert={bookmarks.isStale || undefined}>
<div className={cn(bookmarks.isStale && STALE_ROWS)} inert={bookmarks.isStale || undefined}>
{!ready ? error ? <AuthStatePanel variant="sync_error_retry" onRetry={retry} /> : <ListLoading label={tc("loading")} /> : <CommandCenterList
items={bookmarks.items}
viewMode={bookmarkViewMode}
Expand Down
26 changes: 14 additions & 12 deletions components/evidence-libraries/added-papers/your-submissions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useCursorPageAt } from "@/lib/hooks/use-cursor-page";
import { cn } from "@/lib/utils";
import { useWorkspace } from "@/lib/workspaces/url";
import { StatusChip } from "../configuration/status-chip";
import { LIST_FILTER, ListEmpty, ListLoading } from "../list-controls";
import { LIST_FILTER, ListEmpty, ListLoading, STALE_ROWS } from "../list-controls";
import { CommunityIcon } from "../your-communities";
import { LINK, refusalOr } from "./add-papers-dialog";

Expand Down Expand Up @@ -83,17 +83,19 @@ export function YourSubmissions({ search, heading, submissions }: { search: stri
{read.isLoading ? (
<ListLoading label={t("tabSubmissions")} />
) : read.items.length ? (
// A full page's height while there are pages, so a short last page keeps the pager where it was.
<ul
key={`${show}:${search}:${read.page}`}
className={cn("fade-enter divide-y divide-border-subtle overflow-hidden rounded-xl border border-border-subtle", read.isStale && "opacity-60")}
inert={read.isStale || undefined}
style={read.hasPages ? { minHeight: `calc(${PER_PAGE * ROW_REM}rem + ${PER_PAGE + 1}px)` } : undefined}
>
{read.items.map((submission) => (
<SubmissionRow key={submission.submissionId} submission={submission} date={format.dateTime(submission.sentAt, { day: "numeric", month: "short" })} />
))}
</ul>
// A full page's height while there are pages, so a short last page keeps the pager where it was. Each list enters
// on a wrapper of its own: the list dims while the next is read, and one element never animates and transitions at once.
<div key={`${show}:${search}:${read.page}`} className="fade-enter">
<ul
className={cn("divide-y divide-border-subtle overflow-hidden rounded-xl border border-border-subtle", read.isStale && STALE_ROWS)}
inert={read.isStale || undefined}
style={read.hasPages ? { minHeight: `calc(${PER_PAGE * ROW_REM}rem + ${PER_PAGE + 1}px)` } : undefined}
>
{read.items.map((submission) => (
<SubmissionRow key={submission.submissionId} submission={submission} date={format.dateTime(submission.sentAt, { day: "numeric", month: "short" })} />
))}
</ul>
</div>
) : (
<ListEmpty icon={SearchX} description={search || show !== "all" ? undefined : t("noneYetHint")}>
{search || show !== "all" ? t("noMatches") : t("noneYet")}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { DisclosureButton, DisclosureContent } from "../disclosure-button";
import { SectionCard } from "../section-card";
import { StatusChip } from "../status-chip";
import { SourceCount, SourceRow, SourceSwitch } from "./source-row";
import { STALE_ROWS } from "@/components/evidence-libraries/list-controls";

/** The running community the Added papers row reads, and the person's role there; null until it runs. */
export function useAddedPapersCommunity(libraryId: Id<"evidenceLibraries">) {
Expand Down Expand Up @@ -101,7 +102,7 @@ export function AddedPapersRow({ libraryId, adding, onAddingChange }: {
<DisclosureContent>
<section aria-label={t("name")} className="border-b border-border-subtle bg-muted/40 px-4 pb-3 pt-3">
{/* Every page holds five rows' height, so a short last page doesn't move the pager. */}
<ul className={cn("min-h-[calc(5*3.5rem+4*1px)] divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-background transition-opacity", stale && "pointer-events-none opacity-60")} inert={stale}>
<ul className={cn("min-h-[calc(5*3.5rem+4*1px)] divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-background", stale && STALE_ROWS)} inert={stale}>
{papers?.papers.map((paper) => (
<li key={paper.itemKey}>
<AddedLine paper={paper} libraryId={libraryId} community={community} onChanged={refresh} />
Expand Down
5 changes: 5 additions & 0 deletions components/evidence-libraries/list-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const LIST_TILE =
* Every filter shares the search box's small text. A select's value takes the
* free space, so a wide select still reads from the left.
*/
/**
* Rows of a list still up while the next page, search or order is read (`isStale` from lib/hooks/use-cursor-page.ts):
* dimmed and out of reach of the pointer, the same in every list.
*/
export const STALE_ROWS = "pointer-events-none opacity-60 transition-opacity";
export const LIST_FILTER = "border-transparent bg-inset text-xs shadow-none md:text-xs *:data-[slot=select-value]:flex-1";

/**
Expand Down
4 changes: 2 additions & 2 deletions components/evidence-libraries/public-communities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { PUBLIC_PER_PAGE } from "@/lib/evidence-libraries/directory";
import type { Preloaded } from "convex/react";
import { preloadedQueryResult } from "convex/nextjs";
import { cn } from "@/lib/utils";
import { LIST_FILTER, ListEmpty, ListLoading } from "./list-controls";
import { LIST_FILTER, ListEmpty, ListLoading, STALE_ROWS } from "./list-controls";
import { FadeImage } from "@/components/ui/fade-image";
import { ApplyCorner } from "./applications/apply-corner";
import { fromCard, type Standing } from "./applications/apply-dialog";
Expand Down Expand Up @@ -79,7 +79,7 @@ export function PublicCommunities({ search, preloaded, heading, signedIn = false
<ul
key={read.items.map((community) => community._id).join(",")}
// One column of the panel's width on a phone: an implicit column would be as wide as a card's whole name.
className={cn("grid grid-cols-1 content-start gap-4 @xl/public:grid-cols-2 @4xl/public:grid-cols-3", read.isStale && "opacity-60")}
className={cn("grid grid-cols-1 content-start gap-4 @xl/public:grid-cols-2 @4xl/public:grid-cols-3", read.isStale && STALE_ROWS)}
inert={read.isStale || undefined}
>
{read.items.map((community) => <CommunityCard key={community._id} community={community} signedIn={signedIn} standing={standing.get(community._id)} />)}
Expand Down
4 changes: 2 additions & 2 deletions components/evidence-libraries/your-communities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigge
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectSeparator, SelectTrigger, SelectValue } from "@/components/ui/select";
import { PageStepper } from "@/components/shared/page-stepper";
import { AdminAreaLink } from "./admin-area-link";
import { LIST_FILTER } from "./list-controls";
import { LIST_FILTER, STALE_ROWS } from "./list-controls";
import { LibraryImage } from "./library-image";
import { LibraryStatusIcon, type LibraryOperation } from "./library-status-chip";

Expand Down Expand Up @@ -220,7 +220,7 @@ export function YourCommunities({ waiting = false, framed = false, search, perso
) : rows.length ? (
<ul
style={hasPages ? { minHeight: `${PER_PAGE * ROW_REM}rem` } : undefined}
className={cn(read.isStale && "opacity-60")}
className={cn(read.isStale && STALE_ROWS)}
inert={read.isStale || undefined}
>
{rows.map((community) => <CommunityRow key={community.invitationId ?? (community.application ? `applied:${community.id}` : community.id)} community={community} actions={actions} />)}
Expand Down
4 changes: 2 additions & 2 deletions components/extraction/extraction-command-center.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
import { CommandCenterFilters } from "@/components/command-center/command-center-toolbar";
import { BAR_ACTION, BAR_LABEL } from "@/components/evidence-libraries/configuration/panel-header";
import { LibraryPageShell } from "@/components/evidence-libraries/library-page-shell";
import { ListLoading } from "@/components/evidence-libraries/list-controls";
import { ListLoading, STALE_ROWS } from "@/components/evidence-libraries/list-controls";
import { ViewModeSwitch } from "@/components/view-mode-toggle";
import { JobListItem } from "./job-list-item";
import type { ViewMode } from "@/lib/types";
Expand Down Expand Up @@ -101,7 +101,7 @@ export function ExtractionCommandCenter() {
>
{/* Extractions shared with the person that wait for their answer, above their own. */}
<WaitingInvitations rows={invitations} kind="extraction" text={searchFilter} />
<div className={cn(jobs.isStale && "pointer-events-none opacity-60")}>
<div className={cn(jobs.isStale && STALE_ROWS)}>
{/* The list waits for the invitations above it too, so they never push it down. */}
{jobs.isLoading || invitations === undefined ? <ListLoading label={tc("loading")} /> : <CommandCenterList
items={jobs.items}
Expand Down
3 changes: 2 additions & 1 deletion components/extraction/setup-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import { PdfUpload } from "./pdf-upload";
import { LibrarySources, useLibrarySources, useRowLabel } from "@/components/screening/library-sources";
import { LIBRARY_SOURCE_MAX } from "@/lib/evidence-libraries/source-address";
import { isFrozen, rowKey, setOfRow, type HeldRow } from "@/lib/evidence-libraries/reader-sources";
import { STALE_ROWS } from "@/components/evidence-libraries/list-controls";

/** The sources the page offers; a Zotero set is one a chat starts an extraction from. */
type Kind = Exclude<PickedSource["set"]["kind"], "zotero"> | "pdf";
Expand Down Expand Up @@ -517,7 +518,7 @@ function List({ rows, empty, stale = false, pages = false, label, children }: {
if (!rows) return <p className={cn(LIST, "px-4 py-8 text-center text-sm text-muted-foreground")}>{empty}</p>;
return (
<div style={pages ? { minHeight: SOURCE_PAGE * SOURCE_ROW + 1 } : undefined}>
<div className={cn(LIST, stale && "pointer-events-none opacity-60")} role="group" aria-label={label}>
<div className={cn(LIST, stale && STALE_ROWS)} role="group" aria-label={label}>
{children}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions components/extraction/smart-pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
SelectValue,
} from "@/components/ui/select";
import { cn } from "@/lib/utils";
import { LIST_FILTER } from "@/components/evidence-libraries/list-controls";
import { LIST_FILTER, STALE_ROWS } from "@/components/evidence-libraries/list-controls";
import { useTranslations, useLocale } from "next-intl";

interface SmartPaginationProps {
Expand Down Expand Up @@ -56,7 +56,7 @@ export function SmartPagination({
const endIdx = offset + displayedCount;

return (
<div className={cn("flex flex-col items-center justify-between gap-3 border-t border-border-subtle px-4 py-3 sm:flex-row md:px-6", stale && "pointer-events-none opacity-60")}>
<div className={cn("flex flex-col items-center justify-between gap-3 border-t border-border-subtle px-4 py-3 sm:flex-row md:px-6", stale && STALE_ROWS)}>
{/* Left: Results info */}
{/* The sides share the row evenly, so the steps stay put when the count's text changes width. */}
<p className="text-xs tabular-nums text-muted-foreground sm:flex-1">
Expand Down
3 changes: 2 additions & 1 deletion components/library/library-filter-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { useDebouncedValue } from "@/lib/hooks/use-debounced-value";
import { cn } from "@/lib/utils";
import { AutoHeight } from "@/components/ui/auto-height";
import { inWorkspace, useWorkspace } from "@/lib/workspaces/url";
import { STALE_ROWS } from "@/components/evidence-libraries/list-controls";

/**
* Combined sort options for the library sort dropdown.
Expand Down Expand Up @@ -375,7 +376,7 @@ function CollectionFilterSection({

{/* Vertical list */}
<div
className={cn("space-y-0.5", collections.isStale && "pointer-events-none opacity-60")}
className={cn("space-y-0.5", collections.isStale && STALE_ROWS)}
// A full page's height while there are pages; while the first loads, the rows the count says it will have.
style={showPagination ? { minHeight: FULL_PAGE_PX } : collections.isLoading && totalCollections ? { minHeight: (Math.min(totalCollections, PAGE_SIZE) + 1) * ROW_PX - 2 } : undefined}
>
Expand Down
3 changes: 2 additions & 1 deletion components/library/library-page-client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import { LibraryEmptyState } from "./library-empty-state";
import { LibraryFilterSidebar } from "./library-filter-sidebar";
import { LibraryItemSkeleton } from "./library-item-skeleton";
import { inWorkspace, useWorkspace } from "@/lib/workspaces/url";
import { STALE_ROWS } from "@/components/evidence-libraries/list-controls";

const PAGE_SIZE = 20;

Expand Down Expand Up @@ -617,7 +618,7 @@ export function LibraryPageClient() {
{/* The page shown stays, dimmed and still, until the one it steps to arrives. */}
{/* Only the cards rate in the open collection. Focus mode keeps the person's own rating, on its stars, its shortcuts and its phone control alike. */}
<CollectionRatingContext.Provider value={collectionScope}>
<div className={cn(GRID_CLASSES[effectiveViewMode], paged.isStale && "pointer-events-none opacity-60")}>
<div className={cn(GRID_CLASSES[effectiveViewMode], paged.isStale && STALE_ROWS)}>
{pageResults.map((paper, index) => {
const globalIndex = pageStart + index;
return (
Expand Down
13 changes: 0 additions & 13 deletions components/screening/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -410,19 +410,6 @@ export const day = (at: number) => {
const date = new Date(at);
return `${date.getDate()} ${MONTHS[date.getMonth()]}${date.getFullYear() === new Date().getFullYear() ? "" : ` ${date.getFullYear()}`}`;
};
/** A date as a page shows it: how long ago for the last week, the day before that. */
export function ago(at: number, now = Date.now()) {
const minutes = Math.max(0, Math.round((now - at) / 60_000));
if (minutes < 1) return "just now";
if (minutes < 60) return `${minutes} min ago`;
// Days are counted on the calendar: a vote cast late yesterday was cast yesterday, not "18 h ago".
const midnight = (time: number) => new Date(time).setHours(0, 0, 0, 0);
const days = Math.round((midnight(now) - midnight(at)) / DAY);
if (days <= 0) return `${Math.round(minutes / 60)} h ago`;
if (days === 1) return "yesterday";
if (days < 7) return `${days} days ago`;
return day(at);
}

/** An abstract cut into its sentences, the way a model that names a passage counts them (lib/screening/passages.ts). */
export { sentencesOf } from "@/lib/screening/passages";
Expand Down
11 changes: 4 additions & 7 deletions components/screening/index-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { CommandCenterPagination } from "@/components/command-center/command-cen
import { CommandCenterFilters } from "@/components/command-center/command-center-toolbar";
import { BAR_ACTION, BAR_LABEL } from "@/components/evidence-libraries/configuration/panel-header";
import { LibraryPageShell } from "@/components/evidence-libraries/library-page-shell";
import { ListEmpty, ListRowsSkeleton } from "@/components/evidence-libraries/list-controls";
import { ListEmpty, ListRowsSkeleton, STALE_ROWS } from "@/components/evidence-libraries/list-controls";
import { SkeletonBar } from "@/components/library/library-item-skeleton";
import { PageWrapper } from "@/components/PageWrapper";
import { Chip } from "./parts";
Expand Down Expand Up @@ -98,7 +98,7 @@ export function ScreeningsIndex() {
// The screenings the person is invited to, narrowed by the search as the list is.
const invited = (invitations ?? []).filter((row) => row.kind === "screening" && nameHas(row.name, searched));
// "Needs you first" is the newest first with what waits for the person above them.
const listed = useCursorPageAt("page", api.screening.view.list, inWorkspace(here, show === "you" ? "skip" : { show, sort: sort === "you" ? ("newest" as const) : sort, ...(runBy.by ? { by: runBy.by } : {}), ...(searched ? { text: searched } : {}) }), PAGE);
const listed = useCursorPageAt("page", api.screening.view.list, inWorkspace(here, show === "you" ? "skip" : { show, sort: sort === "you" ? ("newest" as const) : sort, ...(runBy.by ? { by: runBy.by } : {}), ...(searched ? { text: searched } : {}) }), PAGE, { list: JSON.stringify([show, runBy.by ?? null]) });

const fits = (row: Summary) => nameHas(row.name, searched) && (!runBy.by || row.createdBy.id === runBy.by);
const needing = (row: Summary) => row.forYou + row.conflicts + row.asked > 0;
Expand All @@ -114,10 +114,7 @@ export function ScreeningsIndex() {
// Under "Needs you first" the rows sit in their groups, each group in the page's order: one group never splits around another.
.sort((a, b) => (sort === "you" ? a.group - b.group : 0));
// Another tab or person asked for (a search typed or another order keeps the rows up, dimmed): until its rows come it shows skeletons, or at once says it is empty where its count is 0. Never the last tab's rows under the new one. Needs you is read with the page, so it has no wait.
const askedList = JSON.stringify([show, runBy.by ?? null]);
const [arrivedList, setArrivedList] = useState(askedList);
if ((show === "you" || (!listed.isLoading && !listed.isStale)) && arrivedList !== askedList) setArrivedList(askedList);
const otherList = arrivedList !== askedList;
const otherList = listed.isOther;
const listRows = otherList ? [] : rows;
Comment thread
sickerine marked this conversation as resolved.
Resolved
// The rows wait for what is drawn above them too, so a list that has drawn is never pushed down.
const loading = mine === undefined || tally === undefined || elsewhere === undefined || invitations === undefined || (show !== "you" && listed.isLoading);
Expand Down Expand Up @@ -237,7 +234,7 @@ export function ScreeningsIndex() {
{(loading && !rows.length) || (otherList && counts?.[show] !== 0) ? (
<ListRowsSkeleton rows={Math.max(1, Math.min(counts?.[show] ?? UNCOUNTED_ROWS, PAGE))} height={72} icon={false} label={t("loadingScreenings")} />
) : (
<ul className={cn("divide-y divide-border-subtle", listed.isStale && "pointer-events-none opacity-60")}>
<ul className={cn("divide-y divide-border-subtle", listed.isStale && STALE_ROWS)}>
{listRows.map(({ row, group }, i) => {
const id = row.id;
const me = row.me as string;
Expand Down
3 changes: 2 additions & 1 deletion components/screening/overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import { useWorkspace } from "./workspace";
import { useOpenInAddress } from "./address";
import { useWords } from "./words";
import { ScrollArea } from "@/components/ui/scroll-area";
import { STALE_ROWS } from "@/components/evidence-libraries/list-controls";

/** What the Overview shows, kept in its address: the order of the reviewers, and every check for new papers or the last few. */
const PLACE = {
Expand Down Expand Up @@ -706,7 +707,7 @@ function Unread({ open, model }: { open: Open; model: Reviewer }) {
return (
<>
<ScrollArea shades className="-mx-1 min-h-10 flex-1">
<ul className={cn("space-y-0.5 transition-opacity", papers.isStale && "opacity-60")}>
<ul className={cn("space-y-0.5", papers.isStale && STALE_ROWS)}>
{/* Each row holds two lines, the most a title takes here, loaded or not: a long title never moves what is under the list. */}
{Array.from({ length: coming }, (_, at) => <li key={`coming-${at}`} aria-hidden className="min-h-10 space-y-1 px-1 py-1"><SkeletonBar className="h-3.5 w-11/12" /><SkeletonBar className="h-3.5 w-3/5" /></li>)}
{papers.items.map((paper) => (
Expand Down
Loading
Loading