Fix budget type toggle not working the first time (#3169)

* use default 'rollover' for budgetType localPref

* release notes

---------

Co-authored-by: Yusef Ouda <5180063+YusefOuda@users.noreply.github.com>
This commit is contained in:
Yusef Ouda
2024-08-01 11:59:04 -05:00
committed by GitHub
parent 8de0f6a72a
commit c3c6acd37c
6 changed files with 11 additions and 7 deletions

View File

@@ -375,7 +375,7 @@ function CategoryItem({
borderTop: `1px solid ${theme.pillBorder}`,
}
: {};
const [budgetType] = useLocalPref('budgetType');
const [budgetType = 'rollover'] = useLocalPref('budgetType');
const balance = useSheetValue(
budgetType === 'rollover'

View File

@@ -75,8 +75,7 @@ function BudgetInner(props: BudgetInnerProps) {
start: startMonth,
end: startMonth,
});
const [budgetTypePref] = useLocalPref('budgetType');
const budgetType = budgetTypePref || 'rollover';
const [budgetType = 'rollover'] = useLocalPref('budgetType');
const [maxMonthsPref] = useGlobalPref('maxMonths');
const maxMonths = maxMonthsPref || 1;
const [initialized, setInitialized] = useState(false);

View File

@@ -461,8 +461,7 @@ function BudgetInner(props: BudgetInnerProps) {
export function Budget() {
const { list: categories, grouped: categoryGroups } = useCategories();
const [_budgetType] = useLocalPref('budgetType');
const budgetType = _budgetType || 'rollover';
const [budgetType = 'rollover'] = useLocalPref('budgetType');
const spreadsheet = useSpreadsheet();
useSetThemeColor(theme.mobileViewTheme);
return (

View File

@@ -15,7 +15,7 @@ import { Setting } from './UI';
export function BudgetTypeSettings() {
const dispatch = useDispatch();
const [budgetType] = useLocalPref('budgetType');
const [budgetType = 'rollover'] = useLocalPref('budgetType');
const [loading, setLoading] = useState(false);
const currentMonth = monthUtils.currentMonth();

View File

@@ -57,7 +57,7 @@ function FeatureToggle({
}
function ReportBudgetFeature() {
const [budgetType] = useLocalPref('budgetType');
const [budgetType = 'rollover'] = useLocalPref('budgetType');
const enabled = useFeatureFlag('reportBudget');
const blockToggleOff = budgetType === 'report' && enabled;
return (

View File

@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [YusefOuda]
---
Fix budget type toggle not working the first time