feat(design): the channel menu's Tags and Priority submenus (C1, E28 S3e3b)
Tags A-Z as in-place checks (the menu stays open for the next); Priority as the fixed steps 10 5 3 2 1 0, an off-scale current value ticked in its place. A pick re-sorts the list at once, moving only that row (placeByPriority, the server's order), and the table / card pager and the focus follow it (DataTable and useCardPager take a reveal seq, listNav.focusNavItem lands on the row's own "…", a virtualized card revealed first). ActionMenu rows take check: many | one. The menu reads the row fresh from the cache and keys its target by id.
This commit is contained in:
@@ -10,11 +10,26 @@ import { readAccount, writeAccount } from "./storage";
|
||||
//
|
||||
// The page size persists per account; the page itself is transient. `enabled` is the card layout
|
||||
// flag — in table mode DataTable does its own paging, so this does no work and holds still.
|
||||
export function useCardPager<T>(rows: T[], sizeKey: string, enabled: boolean) {
|
||||
export function useCardPager<T>(
|
||||
rows: T[],
|
||||
sizeKey: string,
|
||||
enabled: boolean,
|
||||
/** Follow a row the caller just moved: each new `seq` turns to the page holding the row `match`
|
||||
* finds — the same contract as `DataTable`'s `reveal`, for the card paint of the same list. */
|
||||
reveal?: { seq: number; match: (row: T) => boolean } | null,
|
||||
) {
|
||||
const { t } = useTranslation();
|
||||
const [size, setSize] = useState(() => parseCardSize(readAccount(sizeKey, null)));
|
||||
const [page, setPage] = useState(0);
|
||||
|
||||
// During render against the last seq seen, as in DataTable (seeded so a mount never jumps).
|
||||
const [revealSeen, setRevealSeen] = useState(reveal?.seq);
|
||||
if (reveal && reveal.seq !== revealSeen) {
|
||||
setRevealSeen(reveal.seq);
|
||||
const at = rows.findIndex(reveal.match);
|
||||
if (enabled && at >= 0 && size > 0) setPage(Math.floor(at / size));
|
||||
}
|
||||
|
||||
const totalPages = size <= 0 ? 1 : Math.max(1, Math.ceil(rows.length / size));
|
||||
const safePage = Math.min(page, totalPages - 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user