fix: guard localStorage for SSR, fix currentAction written to wrong store
Build and Publish Mana Loop Docker Image / build-and-publish (push) Successful in 2m5s

This commit is contained in:
Refactoring Agent
2026-05-06 09:45:28 +02:00
parent b0cc848909
commit fe2d1f6bc6
2 changed files with 15 additions and 12 deletions
+7 -6
View File
@@ -15,6 +15,7 @@ import { hasSpecial, SPECIAL_EFFECTS } from '../special-effects';
// Import other stores to access required state // Import other stores to access required state
import { useSkillStore } from './skillStore'; import { useSkillStore } from './skillStore';
import { useGameStore } from './gameStore'; import { useGameStore } from './gameStore';
import { useCombatStore } from './combatStore';
// Import action modules // Import action modules
import * as ApplicationActions from '../crafting-actions/application-actions'; import * as ApplicationActions from '../crafting-actions/application-actions';
@@ -140,8 +141,8 @@ export const useCraftingStore = create<CraftingStore>()(
effects, effects,
}, },
}; };
// Update currentAction in gameStore // Update currentAction in combatStore
useGameStore.setState({ currentAction: 'design' }); useCombatStore.setState({ currentAction: 'design' });
} else if (hasEnchantMastery && !state.designProgress2) { } else if (hasEnchantMastery && !state.designProgress2) {
updates = { updates = {
designProgress2: { designProgress2: {
@@ -167,7 +168,7 @@ export const useCraftingStore = create<CraftingStore>()(
set({ designProgress2: null }); set({ designProgress2: null });
} else { } else {
set({ designProgress: null }); set({ designProgress: null });
useGameStore.setState({ currentAction: 'meditate' }); useCombatStore.setState({ currentAction: 'meditate' });
} }
}, },
@@ -189,8 +190,8 @@ export const useCraftingStore = create<CraftingStore>()(
set((s) => ({ set((s) => ({
enchantmentDesigns: [...s.enchantmentDesigns, design], enchantmentDesigns: [...s.enchantmentDesigns, design],
designProgress: null, designProgress: null,
currentAction: 'meditate' as const,
})); }));
useCombatStore.setState({ currentAction: 'meditate' });
} }
}, },
@@ -214,7 +215,7 @@ export const useCraftingStore = create<CraftingStore>()(
cancelApplication: () => { cancelApplication: () => {
ApplicationActions.cancelApplication(set); ApplicationActions.cancelApplication(set);
useGameStore.setState({ currentAction: 'meditate' }); useCombatStore.setState({ currentAction: 'meditate' });
}, },
// Preparation actions // Preparation actions
@@ -232,7 +233,7 @@ export const useCraftingStore = create<CraftingStore>()(
cancelPreparation: () => { cancelPreparation: () => {
PreparationActions.cancelPreparation(set); PreparationActions.cancelPreparation(set);
useGameStore.setState({ currentAction: 'meditate' }); useCombatStore.setState({ currentAction: 'meditate' });
}, },
// Loot inventory actions // Loot inventory actions
+8 -6
View File
@@ -8,12 +8,14 @@ import { useCombatStore } from './combatStore';
export const createResetGame = (set: (state: any) => void, initialState: any) => () => { export const createResetGame = (set: (state: any) => void, initialState: any) => () => {
// Clear all persisted state // Clear all persisted state
localStorage.removeItem('mana-loop-ui-storage'); if (typeof window !== 'undefined') {
localStorage.removeItem('mana-loop-prestige-storage'); localStorage.removeItem('mana-loop-ui-storage');
localStorage.removeItem('mana-loop-mana-storage'); localStorage.removeItem('mana-loop-prestige-storage');
localStorage.removeItem('mana-loop-skill-storage'); localStorage.removeItem('mana-loop-mana-storage');
localStorage.removeItem('mana-loop-combat-storage'); localStorage.removeItem('mana-loop-skill-storage');
localStorage.removeItem('mana-loop-game-storage'); localStorage.removeItem('mana-loop-combat-storage');
localStorage.removeItem('mana-loop-game-storage');
}
const startFloor = 1; const startFloor = 1;