fix: branch cycling logic

This commit is contained in:
neoapps-dev
2026-05-05 14:12:52 +03:00
parent 1411f78388
commit b04d1f06eb
+11 -6
View File
@@ -178,15 +178,20 @@ export function useGameManager({
if (available.length <= 1) return; if (available.length <= 1) return;
setSelectedBranches(prev => { setSelectedBranches(prev => {
const current = prev[editionId] || available[0]; const current = prev[editionId] || available[0];
const currentIndex = available.indexOf(current); let currentIndex = available.indexOf(current);
const nextIndex = (currentIndex + 1) % available.length; let nextIndex = currentIndex;
const nextBranch = available[nextIndex]; let nextBranch = current;
const oldInstanceId = current === "Stable" ? editionId : `${editionId}_${current}`; do {
const newInstanceId = nextBranch === "Stable" ? editionId : `${editionId}_${nextBranch}`; nextIndex = (nextIndex + 1) % available.length;
nextBranch = available[nextIndex];
} while (nextBranch.startsWith("v") && nextIndex !== currentIndex);
const oldInstanceId =
current === "Stable" ? editionId : `${editionId}_${current}`;
const newInstanceId =
nextBranch === "Stable" ? editionId : `${editionId}_${nextBranch}`;
if (profile === oldInstanceId) { if (profile === oldInstanceId) {
setProfile(newInstanceId); setProfile(newInstanceId);
} }
return { ...prev, [editionId]: nextBranch }; return { ...prev, [editionId]: nextBranch };
}); });
}, [branches, profile, setProfile]); }, [branches, profile, setProfile]);