refactor: remove debug console.log statements
Clean up debugging output from production code: - Remove bead click analysis logging from InteractiveAbacus - Remove sessionStorage operation logging from HomeHeroContext These were useful during development but should not be in production. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
59d594c939
commit
32f51ae739
|
|
@ -66,32 +66,6 @@ export function InteractiveAbacus({
|
|||
const beadPosition = beadElement.getAttribute('data-bead-position')
|
||||
const isActive = beadElement.getAttribute('data-bead-active') === '1'
|
||||
|
||||
console.log('Bead clicked:', {
|
||||
beadType,
|
||||
beadColumn,
|
||||
beadPosition,
|
||||
isActive,
|
||||
})
|
||||
console.log('Current value before click:', currentValue)
|
||||
|
||||
if (beadType === 'earth') {
|
||||
const position = parseInt(beadPosition || '0', 10)
|
||||
const placeValue = beadColumn
|
||||
const columnPower = 10 ** placeValue
|
||||
const currentDigit = Math.floor(currentValue / columnPower) % 10
|
||||
const heavenContribution = Math.floor(currentDigit / 5) * 5
|
||||
const earthContribution = currentDigit % 5
|
||||
console.log('Earth bead analysis:', {
|
||||
position,
|
||||
beadColumn,
|
||||
placeValue,
|
||||
columnPower,
|
||||
currentDigit,
|
||||
heavenContribution,
|
||||
earthContribution,
|
||||
})
|
||||
}
|
||||
|
||||
if (beadType === 'heaven') {
|
||||
// Toggle heaven bead (worth 5)
|
||||
// Now using place-value based column numbering: 0=ones, 1=tens, 2=hundreds
|
||||
|
|
@ -140,13 +114,6 @@ export function InteractiveAbacus({
|
|||
newEarthContribution = position + 1
|
||||
}
|
||||
|
||||
console.log('Earth bead calculation:', {
|
||||
position,
|
||||
isActive,
|
||||
currentEarthContribution: earthContribution,
|
||||
newEarthContribution,
|
||||
})
|
||||
|
||||
// Calculate the new digit for this column
|
||||
const newDigit = heavenContribution + newEarthContribution
|
||||
|
||||
|
|
|
|||
|
|
@ -53,49 +53,28 @@ export function HomeHeroProvider({ children }: { children: React.ReactNode }) {
|
|||
|
||||
// Load from sessionStorage after mount (client-only, no hydration mismatch)
|
||||
useEffect(() => {
|
||||
console.log('[HeroAbacus] Loading from sessionStorage...')
|
||||
isLoadingFromStorage.current = true // Block saves during load
|
||||
|
||||
const saved = sessionStorage.getItem('heroAbacusValue')
|
||||
console.log('[HeroAbacus] Saved value from storage:', saved)
|
||||
|
||||
if (saved) {
|
||||
const parsedValue = parseInt(saved, 10)
|
||||
console.log('[HeroAbacus] Parsed value:', parsedValue)
|
||||
if (!Number.isNaN(parsedValue)) {
|
||||
console.log('[HeroAbacus] Setting abacus value to:', parsedValue)
|
||||
setAbacusValue(parsedValue)
|
||||
}
|
||||
} else {
|
||||
console.log('[HeroAbacus] No saved value found, staying at 0')
|
||||
}
|
||||
|
||||
// Use setTimeout to ensure the value has been set before we allow saves
|
||||
setTimeout(() => {
|
||||
isLoadingFromStorage.current = false
|
||||
setIsAbacusLoaded(true)
|
||||
console.log('[HeroAbacus] Load complete, allowing saves now and fading in')
|
||||
}, 0)
|
||||
}, [])
|
||||
|
||||
// Persist value to sessionStorage when it changes (but skip during load)
|
||||
useEffect(() => {
|
||||
console.log(
|
||||
'[HeroAbacus] Save effect triggered. Value:',
|
||||
abacusValue,
|
||||
'isLoadingFromStorage:',
|
||||
isLoadingFromStorage.current
|
||||
)
|
||||
|
||||
if (!isLoadingFromStorage.current) {
|
||||
console.log('[HeroAbacus] Saving to sessionStorage:', abacusValue)
|
||||
sessionStorage.setItem('heroAbacusValue', abacusValue.toString())
|
||||
console.log(
|
||||
'[HeroAbacus] Saved successfully. Storage now contains:',
|
||||
sessionStorage.getItem('heroAbacusValue')
|
||||
)
|
||||
} else {
|
||||
console.log('[HeroAbacus] Skipping save (currently loading from storage)')
|
||||
}
|
||||
}, [abacusValue])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue