A local-first personal finance app
fix(mobile): fix stale amounts in cover overspending modal (#6488)
Faizan Qureshidfc56b879f81
diff --git a/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx b/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsxindex 1b4da77e5a..abcc9f7c18 100644--- a/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx+++ b/packages/desktop-client/src/components/mobile/budget/BudgetPage.tsx@@ -1,5 +1,11 @@// @ts-strict-ignore-import React, { useCallback, useEffect, useMemo, useState } from 'react';+import React, {+ useCallback,+ useEffect,+ useMemo,+ useRef,+ useState,+} from 'react';import { GridList, GridListItem } from 'react-aria-components';import { Trans, useTranslation } from 'react-i18next';@@ -836,6 +842,9 @@ function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {totalAmount: totalOverspending,} = useOverspentCategories({ month });+ const amountsByCategoryRef = useRef(amountsByCategory);+ amountsByCategoryRef.current = amountsByCategory;+const categoryGroupsToShow = useMemo(() =>categoryGroups@@ -859,7 +868,7 @@ function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {options: {title: category.name,month,- amount: amountsByCategory.get(category.id),+ amount: amountsByCategoryRef.current.get(category.id),categoryId: category.id,onSubmit: (amount, fromCategoryId) => {onBudgetAction(month, 'cover-overspending', {@@ -887,7 +896,6 @@ function OverspendingBanner({ month, onBudgetAction, budgetType, ...props }) {);},[- amountsByCategory,categoriesById,dispatch,month,diff --git a/upcoming-release-notes/6488.md b/upcoming-release-notes/6488.mdnew file mode 100644index 0000000000..f45dbfc615--- /dev/null+++ b/upcoming-release-notes/6488.md@@ -0,0 +1,6 @@+---+category: Bugfix+authors: [Faizanq]+---++Fix mobile cover overspending amount not updating correctly when selecting categories