Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix switching budget from rollover budget to report budget and immediately back does not work #1933

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

paulsukow
Copy link
Contributor

@paulsukow paulsukow commented Nov 19, 2023

Fix for #1915.

The issue was that TitlebarProvider has a pub/sub event pattern and the onTitlebarEvent listener was only set on first render of the budget screen, so the props.budgetType in the function context was always set to the original value. To fix it I pulled the logic for the new budget type out of the onTitlebarEvent function and into the tool bar component. If there was an additional budget type in the future, then the toolbar button could be changed to a drop down menu and the onTitlebarEvent function would not need to change.

This is my first pr on this project and I'm open to suggestions on a different way to fix this.

Copy link

netlify bot commented Nov 19, 2023

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 06fcd46
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/655cc2da865bec000832bc98
😎 Deploy Preview https://deploy-preview-1933.demo.actualbudget.org/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Nov 19, 2023

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
16 2.97 MB → 2.97 MB (+120 B) +0.00%
Changeset
File Δ Size
src/components/Titlebar.tsx 📈 +273 B (+1.73%) 15.44 kB → 15.7 kB
src/components/budget/MobileBudget.js 📈 +84 B (+0.60%) 13.65 kB → 13.73 kB
src/components/budget/index.tsx 📈 +54 B (+0.31%) 17.11 kB → 17.17 kB
src/components/budget/util.ts 📉 -54 B (-1.31%) 4.04 kB → 3.98 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/main.js 1.16 MB → 1.16 MB (+71 B) +0.01%
static/js/narrow-components.chunk.js 52.67 kB → 52.71 kB (+43 B) +0.08%
static/js/wide-components.chunk.js 117.61 kB → 117.62 kB (+6 B) +0.00%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/665.chunk.js 824.28 kB 0%
static/media/Inter-italic.var.woff2 239.29 kB 0%
static/media/Inter-roman.var.woff2 221.86 kB 0%
static/js/444.chunk.js 156.11 kB 0%
static/js/231.chunk.js 117.37 kB 0%
static/js/reports.chunk.js 74.37 kB 0%
static/js/301.chunk.js 13.31 kB 0%
static/js/473.chunk.js 13 kB 0%
static/js/resize-observer-polyfill.chunk.js 8.88 kB 0%
static/css/main.css 7.41 kB 0%
asset-manifest.json 2.07 kB 0%
index.html 1.66 kB 0%
static/media/browser-server.js 903 B 0%

Copy link
Contributor

github-actions bot commented Nov 19, 2023

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
2 2.22 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.23 MB 0%
xfo.xfo.kcab.worker.js 1014.46 kB 0%

@paulsukow paulsukow force-pushed the budget-type-switch-bug-fix branch from 44f141e to 4379c81 Compare November 19, 2023 15:03
@shaankhosla
Copy link
Contributor

This works, and the code looks good to me. Will wait for another maintainer approval before merging.

shaankhosla
shaankhosla previously approved these changes Nov 20, 2023
export type TitlebarContextValue = {
sendEvent: (msg: string) => void;
subscribe: (listener) => () => void;
sendEvent: (msg: string, newBudgetType?: LocalPrefs['budgetType']) => void;
Copy link
Contributor

@joel-jeremy joel-jeremy Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make the 2nd parameter here not specific to budget type as we might introduce different message types in the future. We should instead convert the msg parameter to a structured object with a type property similar to how it is with redux actions e.g.

{
  type: 'budget/switch-type',
  payload: {
    budgetType: newBudgetType,
  }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. I changed that

@paulsukow paulsukow force-pushed the budget-type-switch-bug-fix branch from 8e52794 to 06fcd46 Compare November 21, 2023 14:46
Copy link
Contributor

@joel-jeremy joel-jeremy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thank you!

@joel-jeremy joel-jeremy merged commit 28266ed into actualbudget:master Nov 21, 2023
19 checks passed
@trafico-bot trafico-bot bot added ✨ Merged Pull Request has been merged successfully ✅ Approved and removed 🔍 Ready for Review ✨ Merged Pull Request has been merged successfully labels Nov 21, 2023
FlorianLang06 pushed a commit to FlorianLang06/actual that referenced this pull request Mar 7, 2024
…ately back does not work (actualbudget#1933)

* Fix switching budget from rollover budget to report budget and immediately back does not work

* Pr Changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants