From de2b215fa7c35df1cc1fbfa1e1c48b9c307bde89 Mon Sep 17 00:00:00 2001 From: Joel Jeremy Marquez Date: Thu, 9 Nov 2023 15:24:54 -0800 Subject: [PATCH] Cleanup --- .../desktop-client/src/components/budget/MobileBudget.js | 6 +++--- packages/desktop-client/src/components/budget/index.tsx | 6 +++--- packages/desktop-client/src/components/budget/util.ts | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/desktop-client/src/components/budget/MobileBudget.js b/packages/desktop-client/src/components/budget/MobileBudget.js index 69611baf691..c619075cbef 100644 --- a/packages/desktop-client/src/components/budget/MobileBudget.js +++ b/packages/desktop-client/src/components/budget/MobileBudget.js @@ -56,9 +56,9 @@ class Budget extends Component { this.setState({ bounds: { start, end } }); await prewarmMonth( + this.props.budgetType, this.props.spreadsheet, this.state.currentMonth, - this.props.budgetType, ); this.setState({ initialized: true }); @@ -259,14 +259,14 @@ class Budget extends Component { onPrevMonth = async () => { let { spreadsheet, budgetType } = this.props; let month = monthUtils.subMonths(this.state.currentMonth, 1); - await prewarmMonth(spreadsheet, month, budgetType); + await prewarmMonth(budgetType, spreadsheet, month); this.setState({ currentMonth: month, initialized: true }); }; onNextMonth = async () => { let { spreadsheet, budgetType } = this.props; let month = monthUtils.addMonths(this.state.currentMonth, 1); - await prewarmMonth(spreadsheet, month, budgetType); + await prewarmMonth(budgetType, spreadsheet, month); this.setState({ currentMonth: month, initialized: true }); }; diff --git a/packages/desktop-client/src/components/budget/index.tsx b/packages/desktop-client/src/components/budget/index.tsx index 2de3cf8cb18..02259f24e51 100644 --- a/packages/desktop-client/src/components/budget/index.tsx +++ b/packages/desktop-client/src/components/budget/index.tsx @@ -130,10 +130,10 @@ function Budget(props: BudgetProps) { setBounds({ start, end }); await prewarmAllMonths( + budgetType, props.spreadsheet, { start, end }, prewarmStartMonth, - budgetType, ); setInitialized(true); @@ -206,16 +206,16 @@ function Budget(props: BudgetProps) { if (month < startMonth) { // pre-warm prev month await prewarmMonth( + props.budgetType, props.spreadsheet, monthUtils.subMonths(month, 1), - props.budgetType, ); } else if (month > startMonth) { // pre-warm next month await prewarmMonth( + props.budgetType, props.spreadsheet, monthUtils.addMonths(month, numDisplayed), - props.budgetType, ); } diff --git a/packages/desktop-client/src/components/budget/util.ts b/packages/desktop-client/src/components/budget/util.ts index f83e503a36d..74c0ecaaf37 100644 --- a/packages/desktop-client/src/components/budget/util.ts +++ b/packages/desktop-client/src/components/budget/util.ts @@ -130,9 +130,9 @@ export function getScrollbarWidth() { } export async function prewarmMonth( + budgetType: LocalPrefs['budgetType'], spreadsheet: ReturnType, month: string, - budgetType: LocalPrefs['budgetType'], ) { let method: keyof Handlers = budgetType === 'report' ? 'report-budget-month' : 'rollover-budget-month'; @@ -145,10 +145,10 @@ export async function prewarmMonth( } export async function prewarmAllMonths( + budgetType: LocalPrefs['budgetType'], spreadsheet: ReturnType, bounds: { start: string; end: string }, startMonth: string, - budgetType: LocalPrefs['budgetType'], ) { let numMonths = 3; @@ -160,7 +160,7 @@ export async function prewarmAllMonths( let months = monthUtils.rangeInclusive(bounds.start, bounds.end); await Promise.all( - months.map(month => prewarmMonth(spreadsheet, month, budgetType)), + months.map(month => prewarmMonth(budgetType, spreadsheet, month)), ); } @@ -176,7 +176,7 @@ export async function switchBudgetType( spreadsheet.disableObservers(); await send('budget-set-type', { type: newType }); - await prewarmAllMonths(spreadsheet, bounds, startMonth, newType); + await prewarmAllMonths(newType, spreadsheet, bounds, startMonth); spreadsheet.enableObservers(); await onSuccess?.(); }