fix: reset previousPartIdsRef on build clear; clarify first-hydration skip comment
This commit is contained in:
@@ -618,6 +618,7 @@ function GunbuilderPageContent() {
|
|||||||
if (ids.length === 0) {
|
if (ids.length === 0) {
|
||||||
lastHydrateKeyRef.current = "";
|
lastHydrateKeyRef.current = "";
|
||||||
setParts([]);
|
setParts([]);
|
||||||
|
previousPartIdsRef.current = new Set(); // keep in sync so re-selecting fires the event
|
||||||
setError(null);
|
setError(null);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
return;
|
return;
|
||||||
@@ -670,8 +671,9 @@ function GunbuilderPageContent() {
|
|||||||
|
|
||||||
setParts(hydrated);
|
setParts(hydrated);
|
||||||
|
|
||||||
// Track newly selected parts (fires after API returns with real names).
|
// Track newly selected parts after API fetch — fires with real name, not a numeric ID.
|
||||||
// Skip the first hydration — that's restoring a saved build, not a new selection.
|
// Skip the first hydration: this covers both localStorage build restoration and ?select=
|
||||||
|
// share-link arrivals. Neither represents a live user interaction in the current session.
|
||||||
if (isFirstPartsHydrationRef.current) {
|
if (isFirstPartsHydrationRef.current) {
|
||||||
isFirstPartsHydrationRef.current = false;
|
isFirstPartsHydrationRef.current = false;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user