fix: watch another fight route watcher, profile fight button spinner
- Add route param watcher so navigating to a new fight properly resets and reinitializes the scene (fixes KAPLAY re-init / null scene errors) - Add loading spinner to profile page instant fight button - Restore truncated challenges.ts (was causing all 500 errors) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
88d0495910
commit
4c576b0369
@@ -27,6 +27,56 @@ const autoBattleCount = ref(0)
|
||||
let pollHandle: ReturnType<typeof setInterval> | null = null
|
||||
let pollCount = 0
|
||||
|
||||
// Watch route param changes (e.g. "watch another fight" navigating to a new fight)
|
||||
watch(() => route.params.fightId, async (newId) => {
|
||||
if (!newId || newId === fightId.value) return
|
||||
// Clean up current state
|
||||
if (pollHandle) { clearInterval(pollHandle); pollHandle = null }
|
||||
stopHumanPolling()
|
||||
disconnectSSE()
|
||||
stopAllAudio()
|
||||
if (liveScene) { liveScene.destroy(); liveScene = null }
|
||||
liveSceneReady.value = false
|
||||
|
||||
// Reset all state
|
||||
fightId.value = newId as string
|
||||
fight.value = null
|
||||
isLoading.value = true
|
||||
isLive.value = false
|
||||
liveRounds.value = 0
|
||||
fightError.value = ''
|
||||
replayDone.value = false
|
||||
autoBattle.value = false
|
||||
autoBattleCount.value = 0
|
||||
liveFightData.value = null
|
||||
liveLogItems.value = []
|
||||
liveHpA.value = 100
|
||||
liveHpB.value = 100
|
||||
liveCurrentRound.value = 0
|
||||
humanChallenge.value = null
|
||||
humanSubmitted.value = false
|
||||
humanFightDone.value = false
|
||||
humanFightResult.value = null
|
||||
pendingChallengeData.value = null
|
||||
|
||||
// Re-load
|
||||
const status = await loadFight()
|
||||
isLoading.value = false
|
||||
if (status === null || status !== 'finished') {
|
||||
isLive.value = true
|
||||
}
|
||||
if (isLive.value) {
|
||||
startPolling()
|
||||
if (isHumanFight.value) {
|
||||
startHumanPolling()
|
||||
connectSSE()
|
||||
await nextTick()
|
||||
await nextTick()
|
||||
if (liveFightData.value) await initLiveScene()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Human fight detection
|
||||
const isHumanFight = computed(() => !!myBot.value?.isHuman || myBot.value?.archetype === 'human')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user