fix: funbox deselection not clearing effects without refresh (@prajith5)#7469
fix: funbox deselection not clearing effects without refresh (@prajith5)#7469prajith5 wants to merge 1 commit intomonkeytypegame:masterfrom
Conversation
|
This PR doesn't seem to fix the issue |
There was a problem hiding this comment.
Pull request overview
This PR fixes a critical bug where funbox effects remained active internally after deselection until page refresh (issue #7468).
Changes:
- Fixed
setFunbox()to callclearGlobal()on removed funboxes when switching between funbox sets - Fixed
toggleFunbox()to properly track activation state transitions and callclearGlobal()when deactivating andapplyGlobalCSS()when activating - Refactored forced config logic in
activate()for better readability with explicit type checking
| } | ||
|
|
||
| FunboxMemory.load(); | ||
| setConfig("funbox", funbox); |
There was a problem hiding this comment.
The setFunbox() function clears removed funboxes but doesn't apply global CSS for newly activated funboxes. When switching from one set of funboxes to another (e.g., from ["nausea"] to ["upside_down"]), the new funbox's applyGlobalCSS() is never called, which could leave it in an incomplete state.
Consider adding logic to detect newly activated funboxes and call their applyGlobalCSS() function, similar to how toggleFunbox() handles this on line 76.
| setConfig("funbox", funbox); | |
| setConfig("funbox", funbox); | |
| const currentFunboxes = getActiveFunboxNames(); | |
| const addedFunboxes = currentFunboxes.filter( | |
| (fb) => !previousFunboxes.includes(fb), | |
| ); | |
| for (const fb of addedFunboxes) { | |
| get(fb).functions?.applyGlobalCSS?.(); | |
| } |
| @@ -56,12 +59,20 @@ export function toggleFunbox(funbox: FunboxName): void { | |||
| ); | |||
| return; | |||
| } | |||
|
|
|||
| FunboxMemory.load(); | |||
|
|
|||
| const wasActive = getActiveFunboxNames().includes(funbox); | |||
|
|
|||
| configToggleFunbox(funbox, false); | |||
|
|
|||
| if (!getActiveFunboxNames().includes(funbox)) { | |||
| const isActive = getActiveFunboxNames().includes(funbox); | |||
|
|
|||
| if (wasActive && !isActive) { | |||
| get(funbox).functions?.clearGlobal?.(); | |||
| } else { | |||
| } | |||
|
|
|||
| if (!wasActive && isActive) { | |||
| get(funbox).functions?.applyGlobalCSS?.(); | |||
| } | |||
| } | |||
There was a problem hiding this comment.
The changes to toggleFunbox() and setFunbox() fix a critical bug but lack test coverage. Consider adding tests that verify:
clearGlobal()is called when a funbox is deselectedapplyGlobalCSS()is called when a funbox is selected- Multiple funbox effects are properly cleared when switching between different sets
This would prevent regression of the issue described in #7468.
Fixes an issue where Funbox effects remained active internally after being
deselected until a page refresh.
This change compares the previous and next activation state of a Funbox
and ensures:
This guarantees Funbox effects reset immediately without requiring a refresh.
Fixes #7468