Skip to content

Commit

Permalink
Add duplicate save handler to deal with early unbind
Browse files Browse the repository at this point in the history
  • Loading branch information
tiliv committed Apr 25, 2024
1 parent ae0b3e4 commit f4adce9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/displays/WorldDisplay.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ScreenStack from './ScreenStack';
import useLocation from '../../hooks/useLocation';
import useInteraction from '../../hooks/useInteraction';
import useStats from '../../hooks/useStats';
import useSave from '../../hooks/useSave';
import { list } from '../../actions/Load';
import { ACTIONS } from '../../Actions';
import * as Buy from '../../actions/Buy';
Expand All @@ -23,6 +24,18 @@ export default function WorldDisplay({
}) {
const [activeBuffer, setActiveBuffer] = useState(null);

// This is redundant to the outer App.jsx useSave, because that one fails a
// race condition to save data before it's unmounted and re-mounted. This one
// saves data fine, but won't load anything, as the setters are no-op.
useSave({
magnification: [magnification, () => {}],
width: [width, () => {}],
height: [height, () => {}],
startWorld: [startWorld, () => {}],
startX: [startX, () => {}],
startY: [startY, () => {}],
});

const { name } = useStats();
const { marker, layers, bump, local, position, interactions } = useLocation({
world: startWorld,
Expand Down

0 comments on commit f4adce9

Please sign in to comment.