-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 mobile transaction edit page's back button behavior #3905
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey 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
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey 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
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
WalkthroughThe pull request introduces changes primarily focused on renaming variables within the Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Warning There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure. 🔧 eslint
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsxOops! Something went wrong! :( ESLint: 8.57.1 ESLint couldn't find the plugin "eslint-plugin-eslint-plugin". (The package "eslint-plugin-eslint-plugin" was not found when loaded as a Node module from the directory "/packages/eslint-plugin-actual".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:
The plugin "eslint-plugin-eslint-plugin" was referenced from the config file in "packages/eslint-plugin-actual/.eslintrc.js". If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (3)
542-550
: Consider simplifying navigation logicThe navigation logic could be more maintainable with a clearer structure. Consider extracting it into a separate function with descriptive variable names.
- const isAddingFromAccountPage = isAdding && locationState?.accountId; - if (!isAddingFromAccountPage || hasAccountChanged.current) { - const { account: accountId } = unserializedTransaction; - const account = accountsById?.[accountId]; - if (account) { - navigate(`/accounts/${account.id}`, { replace: true }); - } else { - // Handle the case where account is undefined - navigate('/accounts'); - } + const shouldNavigateToAccount = () => { + const isAddingFromAccountPage = isAdding && locationState?.accountId; + return !isAddingFromAccountPage || hasAccountChanged.current; + }; + + const getTargetAccountPath = () => { + const { account: accountId } = unserializedTransaction; + const account = accountsById?.[accountId]; + return account ? `/accounts/${account.id}` : '/accounts'; + }; + + if (shouldNavigateToAccount()) { + navigate(getTargetAccountPath(), { replace: true }); } else { navigate(-1); }
Line range hint
1158-1182
: Add error handling for API callsThe batch update operation lacks proper error handling. If the API call fails, there's no mechanism to handle the error or notify the user.
Add try-catch blocks around the API call:
if (changes.added.length > 0 || changes.updated.length > 0 || changes.deleted.length ) { + try { const _remoteUpdates = await send('transactions-batch-update', { added: changes.added, deleted: changes.deleted, updated: changes.updated, }); + } catch (error) { + // Handle API error + console.error('Failed to update transactions:', error); + // Show error notification to user + return; + } }
Line range hint
982-1011
: Consider adding a confirmation dialog for delete actionTo prevent accidental deletions and improve user experience, consider adding a confirmation dialog before deleting transactions, especially in mobile view where touch interactions can be less precise.
Add a confirmation step:
<View style={{ alignItems: 'center' }}> <Button - onClick={() => onDeleteInner(transaction.id)} + onClick={() => { + dispatch( + pushModal('confirm', { + title: 'Delete Transaction', + message: 'Are you sure you want to delete this transaction?', + onConfirm: () => onDeleteInner(transaction.id), + }) + ); + }} style={{ height: 40, borderWidth: 0, marginLeft: styles.mobileEditingPadding, marginRight: styles.mobileEditingPadding, marginTop: 10, backgroundColor: 'transparent', }} type="bare" >
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/3905.md
is excluded by!**/*.md
📒 Files selected for processing (1)
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
(17 hunks)
🔇 Additional comments (1)
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (1)
159-159
: LGTM! Improved boolean variable naming
The renaming of variables from adding
to isAdding
and deleted
to isDeleted
follows better naming conventions for boolean variables, making the code more readable and self-documenting.
Also applies to: 235-235, 439-439, 483-483, 536-536, 778-778, 1250-1250, 1049-1049
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #3896