Skip to content

Commit

Permalink
Fix budget type toggle not working the first time (#3169)
Browse files Browse the repository at this point in the history
* use default 'rollover' for budgetType localPref

* release notes

---------

Co-authored-by: Yusef Ouda <[email protected]>
  • Loading branch information
YusefOuda and YusefOuda authored Aug 1, 2024
1 parent 8de0f6a commit c3c6acd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 1 addition & 2 deletions packages/desktop-client/src/components/budget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/3169.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Bugfix
authors: [YusefOuda]
---

Fix budget type toggle not working the first time

0 comments on commit c3c6acd

Please sign in to comment.