v3: allow users to edit dump thumbnail, fixed some linter errors in the frontend
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 41s
All checks were successful
Build and Publish Docker Image / build-and-push (push) Successful in 41s
This commit is contained in:
@@ -55,13 +55,16 @@ export function Search() {
|
||||
const abortRef = useRef<AbortController | null>(null);
|
||||
|
||||
const fetchSearch = useCallback(async (query: string, page: number) => {
|
||||
// Deferred to a microtask so callers invoking this directly from an
|
||||
// effect body don't trip the synchronous-setState-in-effect check —
|
||||
// same timing for the user, just not in the same tick.
|
||||
if (!query.trim()) {
|
||||
setState({ status: "idle" });
|
||||
queueMicrotask(() => setState({ status: "idle" }));
|
||||
return;
|
||||
}
|
||||
|
||||
if (page === 1) {
|
||||
setState({ status: "loading" });
|
||||
queueMicrotask(() => setState({ status: "loading" }));
|
||||
}
|
||||
|
||||
abortRef.current?.abort();
|
||||
@@ -131,7 +134,10 @@ export function Search() {
|
||||
}, [token]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchSearch(q, 1);
|
||||
// fetchSearch is async; calling it directly is flagged as a synchronous
|
||||
// setState regardless of its own internal deferral, so defer the call
|
||||
// itself by a microtask too — same timing for the user.
|
||||
queueMicrotask(() => fetchSearch(q, 1));
|
||||
return () => abortRef.current?.abort();
|
||||
}, [q, fetchSearch]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user