Skip to content

Commit 28d3ab8

Browse files
n0mahdclaude
andcommitted
fix(web): ignore a skills refresh that finishes after the page is gone
The refresh button's request set state after its page was left, where the first load already drops a result that arrives late. Guard it the same way. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
1 parent 54141e8 commit 28d3ab8

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎apps/web/src/components/settings/SkillsSettings.tsx‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,13 @@ function EnvironmentSkills({
115115
const [onlyAttention, setOnlyAttention] = useState(false);
116116
const [detailReload, setDetailReload] = useState(0);
117117
const rootRef = useRef<HTMLDivElement>(null);
118+
const mounted = useRef(true);
119+
useEffect(() => {
120+
mounted.current = true;
121+
return () => {
122+
mounted.current = false;
123+
};
124+
}, []);
118125
// A new view starts at the top of the page.
119126
const show = (next: View) => {
120127
setView(next);
@@ -152,15 +159,20 @@ function EnvironmentSkills({
152159
setLoadError(null);
153160
void load()
154161
.then((loaded) => {
162+
if (!mounted.current) return;
155163
if (!loaded) {
156164
setLoadError(LOAD_ERROR);
157165
return;
158166
}
159167
setData(loaded);
160168
show({ kind: "list" });
161169
})
162-
.catch(() => setLoadError(LOAD_ERROR))
163-
.finally(() => setRefreshing(false));
170+
.catch(() => {
171+
if (mounted.current) setLoadError(LOAD_ERROR);
172+
})
173+
.finally(() => {
174+
if (mounted.current) setRefreshing(false);
175+
});
164176
};
165177

166178
const skills = data?.skills ?? null;

0 commit comments

Comments
 (0)