Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(web): viewed PR files stay folded when the Code tab is reopened #13280

ClosedMnigos(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/13280/headopened View on GitHub

Showing 4 changed files with 143 additions and 4 deletions (loading 1).

x
0 of 4 viewed, 4 left
58 additions and 4 deletionsapps/web/src/components/pullRequest/PullRequestCodeTab.tsxModified
View file
@@ -79,6 +79,7 @@
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
import { PendingReviewCommentCard, ReviewThreadCard } from "./PullRequestReviewAnnotation";
import {
+ foldViewedFilesOnce,
isFileDiffCollapsed,
isLineInFileDiff,
toggleFileDiffFoldForViewed,
@@ -223,6 +224,15 @@
const { resolvedTheme } = useTheme();
const settings = useClientSettings();
const [toggledFiles, setToggledFiles] = useState<ReadonlySet<string>>(() => new Set());
+ /** Paths whose tick has been read once for this mount; see `foldViewedFilesOnce`. */
+ const seenViewedPathsRef = useRef<ReadonlySet<string>>(new Set());
+ /** Set by Expand all / Collapse all: from then on the reader's choice outranks the ticks. */
+ const readerSetAllFoldsRef = useRef(false);
+ const pathByFileKeyRef = useRef<ReadonlyMap<string, string>>(new Map());
+ const markViewedPathSeen = useCallback((path: string | undefined) => {
+ if (path === undefined || seenViewedPathsRef.current.has(path)) return;
+ seenViewedPathsRef.current = new Set([...seenViewedPathsRef.current, path]);
+ }, []);
// A change of any size can carry hundreds of commits, and a menu that long is a scroll rather
// than a choice. The rest arrive ten at a time, on request.
const [visibleCommitCount, setVisibleCommitCount] = useState(COMMIT_PAGE_SIZE);
@@ -267,6 +277,8 @@
setDraft(null);
setSelectedLines(null);
setToggledFiles(new Set());