mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Fix Garage and Settings load on Android
This commit is contained in:
parent
dafc2f91c7
commit
8c81bed013
@ -102,18 +102,16 @@ const makeTheme = function (settings: Settings) {
|
|||||||
return theme;
|
return theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
const initialSettings = new Settings();
|
|
||||||
const initialTheme = makeTheme(initialSettings);
|
|
||||||
const initialGarage = new Garage();
|
|
||||||
const initialSlot = initialGarage.slots.length - 1;
|
|
||||||
const initialRobot = new Robot(initialGarage.slots[initialSlot].robot);
|
|
||||||
|
|
||||||
export const useAppStore = () => {
|
export const useAppStore = () => {
|
||||||
// State provided right at the top level of the app. A chaotic bucket of everything.
|
// State provided right at the top level of the app. A chaotic bucket of everything.
|
||||||
// Contains app-wide state and functions. Triggers re-renders on the full tree often.
|
// Contains app-wide state and functions. Triggers re-renders on the full tree often.
|
||||||
|
|
||||||
const [theme, setTheme] = useState<Theme>(initialTheme);
|
const [settings, setSettings] = useState<Settings>(() => {
|
||||||
const [settings, setSettings] = useState<Settings>(initialSettings);
|
return new Settings();
|
||||||
|
});
|
||||||
|
const [theme, setTheme] = useState<Theme>(() => {
|
||||||
|
return makeTheme(settings);
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setTheme(makeTheme(settings));
|
setTheme(makeTheme(settings));
|
||||||
@ -130,9 +128,15 @@ export const useAppStore = () => {
|
|||||||
list: [],
|
list: [],
|
||||||
loading: true,
|
loading: true,
|
||||||
});
|
});
|
||||||
const [garage, setGarage] = useState<Garage>(initialGarage);
|
const [garage, setGarage] = useState<Garage>(() => {
|
||||||
const [currentSlot, setCurrentSlot] = useState<number>(initialSlot);
|
return new Garage();
|
||||||
const [robot, setRobot] = useState<Robot>(initialRobot);
|
});
|
||||||
|
const [currentSlot, setCurrentSlot] = useState<number>(() => {
|
||||||
|
return garage.slots.length - 1;
|
||||||
|
});
|
||||||
|
const [robot, setRobot] = useState<Robot>(() => {
|
||||||
|
return new Robot(garage.slots[currentSlot].robot);
|
||||||
|
});
|
||||||
const [maker, setMaker] = useState<Maker>(defaultMaker);
|
const [maker, setMaker] = useState<Maker>(defaultMaker);
|
||||||
const [info, setInfo] = useState<Info>(defaultInfo);
|
const [info, setInfo] = useState<Info>(defaultInfo);
|
||||||
const [coordinators, setCoordinators] = useState<Coordinator[]>(defaultCoordinators);
|
const [coordinators, setCoordinators] = useState<Coordinator[]>(defaultCoordinators);
|
||||||
|
Loading…
Reference in New Issue
Block a user