Skip to content

Commit a1a91b9

Browse files
committed
Merge remote-tracking branch 'origin/fix-blinks-starred-projects' into pr-20251208
2 parents 28186c1 + 8cdfc42 commit a1a91b9

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/packages/frontend/projects/projects-starred.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {
2121

2222
import { CSS, useActions, useTypedRedux } from "@cocalc/frontend/app-framework";
2323
import { Icon, TimeAgo } from "@cocalc/frontend/components";
24-
import { trunc } from "@cocalc/util/misc";
24+
import { sha1, trunc } from "@cocalc/util/misc";
2525
import { COLORS } from "@cocalc/util/theme";
2626
import { useBookmarkedProjects } from "./use-bookmarked-projects";
2727

@@ -131,9 +131,7 @@ export function StarredProjectsBar() {
131131
title: project.get("title") ?? "Untitled",
132132
description: project.get("description") ?? "",
133133
last_edited: project.get("last_edited"),
134-
state: project.get("state"),
135134
avatar_image_tiny: project.get("avatar_image_tiny"),
136-
users: project.get("users"),
137135
color: project.get("color"),
138136
};
139137
})
@@ -143,6 +141,24 @@ export function StarredProjectsBar() {
143141
return projects;
144142
}, [bookmarkedProjects, project_map]);
145143

144+
// Hash only the fields that impact layout so we can avoid unnecessary re-measurements.
145+
const layoutKey = useMemo(() => {
146+
if (starredProjects.length === 0) {
147+
return "";
148+
}
149+
const signature = starredProjects
150+
.map((project) =>
151+
[
152+
project.project_id,
153+
project.title,
154+
project.color ?? "",
155+
project.avatar_image_tiny ?? "",
156+
].join("|"),
157+
)
158+
.join("::");
159+
return sha1(signature);
160+
}, [starredProjects]);
161+
146162
// Drag and drop sensors
147163
const mouseSensor = useSensor(MouseSensor, {
148164
activationConstraint: { distance: 5 }, // 5px to activate drag
@@ -215,7 +231,7 @@ export function StarredProjectsBar() {
215231
useLayoutEffect(() => {
216232
setMeasurementPhase(true);
217233
setVisibleCount(0);
218-
}, [starredProjects]);
234+
}, [layoutKey]);
219235

220236
// Measure button widths from hidden container and calculate visible count
221237
useLayoutEffect(() => {

0 commit comments

Comments
 (0)