Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Nov 9, 2023
1 parent 3199224 commit de2b215
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions packages/desktop-client/src/components/budget/MobileBudget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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 });
};

Expand Down
6 changes: 3 additions & 3 deletions packages/desktop-client/src/components/budget/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ function Budget(props: BudgetProps) {
setBounds({ start, end });

await prewarmAllMonths(
budgetType,
props.spreadsheet,
{ start, end },
prewarmStartMonth,
budgetType,
);

setInitialized(true);
Expand Down Expand Up @@ -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,
);
}

Expand Down
8 changes: 4 additions & 4 deletions packages/desktop-client/src/components/budget/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ export function getScrollbarWidth() {
}

export async function prewarmMonth(
budgetType: LocalPrefs['budgetType'],
spreadsheet: ReturnType<typeof useSpreadsheet>,
month: string,
budgetType: LocalPrefs['budgetType'],
) {
let method: keyof Handlers =
budgetType === 'report' ? 'report-budget-month' : 'rollover-budget-month';
Expand All @@ -145,10 +145,10 @@ export async function prewarmMonth(
}

export async function prewarmAllMonths(
budgetType: LocalPrefs['budgetType'],
spreadsheet: ReturnType<typeof useSpreadsheet>,
bounds: { start: string; end: string },
startMonth: string,
budgetType: LocalPrefs['budgetType'],
) {
let numMonths = 3;

Expand All @@ -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)),
);
}

Expand All @@ -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?.();
}

0 comments on commit de2b215

Please sign in to comment.