5.1
Combine and relabel table view switch. Remove and re-arrange some table columns Group Pets together
This commit is contained in:
@@ -442,8 +442,12 @@ export function useAppState() {
|
||||
if (key !== 'custom') {
|
||||
setVisibleCols({ ...profile.cols });
|
||||
const hasIndoor = profile.cols['indoorT'] || profile.cols['managedT'];
|
||||
setIndoorMode(hasIndoor ? 'on' : 'off');
|
||||
setIndoorManaged(false);
|
||||
// Must go through the persisting setters: the Indoors pill and column
|
||||
// read indoorMode, and its initialiser reads it back from localStorage
|
||||
// on the next load. Setting only the React state left the stored value
|
||||
// behind, so a reload restored the previous profile's Indoors state.
|
||||
setIndoorModeAndSave(hasIndoor ? 'on' : 'off');
|
||||
setIndoorManagedAndSave(false);
|
||||
if (hasIndoor) setBuildingTypeAndSave('brick');
|
||||
const defaultEnv = VARIANT_DEFAULT_ENV[key];
|
||||
if (defaultEnv) setUtciEnvAndSave(defaultEnv);
|
||||
@@ -453,8 +457,8 @@ export function useAppState() {
|
||||
if (customCols) {
|
||||
setVisibleCols({ ...customCols });
|
||||
const hasIndoor = customCols['indoorT'] || customCols['managedT'];
|
||||
setIndoorMode(hasIndoor ? 'on' : 'off');
|
||||
setIndoorManaged(false);
|
||||
setIndoorModeAndSave(hasIndoor ? 'on' : 'off');
|
||||
setIndoorManagedAndSave(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -501,7 +505,7 @@ export function useAppState() {
|
||||
if (variantCols) {
|
||||
setVisibleCols({ ...variantCols });
|
||||
const hasIndoor = variantCols['indoorT'] || variantCols['managedT'];
|
||||
setIndoorMode(hasIndoor ? 'on' : 'off');
|
||||
setIndoorModeAndSave(hasIndoor ? 'on' : 'off');
|
||||
}
|
||||
// Auto-set UTCI environment modifier to match the selected variant.
|
||||
const defaultEnv = VARIANT_DEFAULT_ENV[v] ?? 'open';
|
||||
@@ -548,11 +552,19 @@ export function useAppState() {
|
||||
};
|
||||
const [indoorMode, setIndoorMode] = useState(() => {
|
||||
try {
|
||||
const saved = localStorage.getItem('sunscope_indoor_mode');
|
||||
if (saved) return saved;
|
||||
const profile = localStorage.getItem('sunscope_profile') || 'basic';
|
||||
const cols = FILTER_PROFILES[profile]?.cols ?? FILTER_PROFILES.basic.cols;
|
||||
return (cols['indoorT'] || cols['managedT']) ? 'on' : 'off';
|
||||
const cols = profile === 'outdoors'
|
||||
? (OUTDOORS_VARIANTS[localStorage.getItem('sunscope_outdoors_variant') || 'urban']?.cols
|
||||
?? FILTER_PROFILES.outdoors.cols)
|
||||
: (FILTER_PROFILES[profile]?.cols ?? FILTER_PROFILES.basic.cols);
|
||||
const offered = !!(cols['indoorT'] || cols['managedT']);
|
||||
// A profile that has no Indoors columns has no Indoors pill either, so
|
||||
// an 'on' left over from a profile that did would show the column with
|
||||
// no way to turn it off. The profile decides whether it's available;
|
||||
// the saved value only decides the state within a profile that offers it.
|
||||
if (!offered) return 'off';
|
||||
const saved = localStorage.getItem('sunscope_indoor_mode');
|
||||
return saved || 'on';
|
||||
} catch (e) { return 'off'; }
|
||||
});
|
||||
const setIndoorModeAndSave = (v) => {
|
||||
@@ -643,11 +655,10 @@ export function useAppState() {
|
||||
const [tableRotated, setTableRotated] = useState(() => {
|
||||
try { return localStorage.getItem('sunscope_table_rotated') === '1'; } catch (e) { return false; }
|
||||
});
|
||||
const toggleTableRotated = () => setTableRotated(v => {
|
||||
const next = !v;
|
||||
const setTableRotatedAndSave = (next) => {
|
||||
try { localStorage.setItem('sunscope_table_rotated', next ? '1' : '0'); } catch (e) { /* ignore */ }
|
||||
return next;
|
||||
});
|
||||
setTableRotated(!!next);
|
||||
};
|
||||
|
||||
// Table row interval: 1 = every hour, 2/3/4 = clock-aligned buckets. Default 2.
|
||||
const [tableInterval, setTableIntervalState] = useState(() => {
|
||||
@@ -903,7 +914,7 @@ export function useAppState() {
|
||||
panelOpen, openPanel, closePanel,
|
||||
showUnits, toggleShowUnits,
|
||||
tableInterval, setTableInterval,
|
||||
tableRotated, toggleTableRotated,
|
||||
tableRotated, setTableRotated: setTableRotatedAndSave,
|
||||
forecastView, setForecastView,
|
||||
// table refs
|
||||
headStickyRef, headTrackRef, headTableRef,
|
||||
|
||||
Reference in New Issue
Block a user