-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Redux Toolkit Migration] queriesSlice #4016
Changes from all commits
a6f4576
943281d
813388d
4222add
7c11cd4
1be216f
4822331
ea3160c
512480b
7dd17a5
6fb9827
27c6693
964c261
723d69a
19cdc3a
a454660
943fda1
79ca573
3d0d64e
1356ed2
d5a904f
cbf5cf1
66e2897
acbfcce
f7c216e
e84a73f
d28d75c
f31bcfe
8e42b2e
96c781d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,18 +16,19 @@ import { v4 as uuidv4 } from 'uuid'; | |
import { unlinkAccount } from 'loot-core/client/accounts/accountsSlice'; | ||
import { | ||
addNotification, | ||
createPayee, | ||
getPayees, | ||
initiallyLoadPayees, | ||
markAccountRead, | ||
openAccountCloseModal, | ||
pushModal, | ||
reopenAccount, | ||
replaceModal, | ||
syncAndDownload, | ||
} from 'loot-core/client/actions'; | ||
import { | ||
createPayee, | ||
initiallyLoadPayees, | ||
markAccountRead, | ||
reopenAccount, | ||
updateAccount, | ||
updateNewTransactions, | ||
} from 'loot-core/client/actions'; | ||
} from 'loot-core/client/queries/queriesSlice'; | ||
import { type AppDispatch } from 'loot-core/client/store'; | ||
import { validForTransfer } from 'loot-core/client/transfer'; | ||
import { type UndoState } from 'loot-core/server/undo'; | ||
|
@@ -59,7 +60,6 @@ import { | |
type NewRuleEntity, | ||
type RuleActionEntity, | ||
type AccountEntity, | ||
type PayeeEntity, | ||
type RuleConditionEntity, | ||
type TransactionEntity, | ||
type TransactionFilterEntity, | ||
|
@@ -501,7 +501,7 @@ class AccountInternal extends PureComponent< | |
else this.updateQuery(query); | ||
|
||
if (this.props.accountId) { | ||
this.props.dispatch(markAccountRead(this.props.accountId)); | ||
this.props.dispatch(markAccountRead({ id: this.props.accountId })); | ||
} | ||
}; | ||
|
||
|
@@ -687,7 +687,7 @@ class AccountInternal extends PureComponent< | |
} | ||
}); | ||
|
||
this.props.dispatch(updateNewTransactions(updatedTransaction.id)); | ||
this.props.dispatch(updateNewTransactions({ id: updatedTransaction.id })); | ||
}; | ||
|
||
canCalculateBalance = () => { | ||
|
@@ -781,7 +781,10 @@ class AccountInternal extends PureComponent< | |
const account = this.props.accounts.find( | ||
account => account.id === this.props.accountId, | ||
); | ||
this.props.dispatch(updateAccount({ ...account, name } as AccountEntity)); | ||
if (!account) { | ||
throw new Error(`Account with ID ${this.props.accountId} not found.`); | ||
} | ||
this.props.dispatch(updateAccount({ account: { ...account, name } })); | ||
this.setState({ editingName: false, nameError: '' }); | ||
} | ||
}; | ||
|
@@ -829,7 +832,7 @@ class AccountInternal extends PureComponent< | |
this.props.dispatch(openAccountCloseModal(accountId)); | ||
break; | ||
case 'reopen': | ||
this.props.dispatch(reopenAccount(accountId)); | ||
this.props.dispatch(reopenAccount({ id: accountId })); | ||
break; | ||
case 'export': | ||
const accountName = this.getAccountTitle(account, accountId); | ||
|
@@ -944,7 +947,7 @@ class AccountInternal extends PureComponent< | |
onCreatePayee = (name: string) => { | ||
const trimmed = name.trim(); | ||
if (trimmed !== '') { | ||
return this.props.dispatch(createPayee(name)); | ||
return this.props.dispatch(createPayee({ name })).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Codebase verification Error handling needed for createPayee operation The review comment is valid. The codebase shows that:
The suggested try-catch solution using 🔗 Analysis chainConsider handling potential errors when creating a payee The use of Consider wrapping the dispatch call in a try-catch block: + try {
return await this.props.dispatch(createPayee({ name })).unwrap();
+ } catch (error) {
+ // Handle the error, e.g., display a notification
+ this.props.dispatch(addGenericErrorNotification());
+ return null;
+ } 🏁 Scripts executedThe following scripts were executed for the analysis: Error: No shell scripts found Script: #!/bin/bash
# Find createPayee usage
rg "createPayee" -A 3 -B 3
# Look for error notification patterns
rg "addGenericErrorNotification|addNotification.*error" -A 2 -B 2
# Find error handling patterns with unwrap
rg "\.unwrap\(\)" -A 3 -B 3
Length of output: 13725 |
||
} | ||
return null; | ||
}; | ||
|
@@ -1322,7 +1325,8 @@ class AccountInternal extends PureComponent< | |
const onConfirmTransfer = async (ids: string[]) => { | ||
this.setState({ workingHard: true }); | ||
|
||
const payees: PayeeEntity[] = await this.props.dispatch(getPayees()); | ||
const payees = this.props.payees; | ||
|
||
const { data: transactions } = await runQuery( | ||
q('transactions') | ||
.filter({ id: { $oneof: ids } }) | ||
|
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.
Not a huge fan of this
.unwrap
API tbh, wish it threw by default like a normal Promise :/