-
Notifications
You must be signed in to change notification settings - Fork 397
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: to token detail price ok-34763 #6459
Conversation
Signed-off-by: 王山栋 <[email protected]>
Review or Edit in CodeSandboxOpen the branch in Web Editor • VS Code • Insiders |
WalkthroughThe pull request modifies the Changes
Sequence DiagramsequenceDiagram
participant Method as loadSwapSelectTokenDetail
participant Condition as Token Condition Check
participant State as State Update
Method->>Condition: Check token validity
Condition-->>Method: Validate token
Method->>State: Create temporary condition object
State->>State: Update state with token details
The sequence diagram illustrates the refined flow of token detail loading, highlighting the simplified validation and state update process introduced in the changes. 🪧 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: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (1)
packages/kit/src/states/jotai/contexts/swap/actions.ts
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: lint (20.x)
🔇 Additional comments (1)
packages/kit/src/states/jotai/contexts/swap/actions.ts (1)
1319-1361
: Great refactoring of state updates!The use of a temporary
condition
object to collect updates before applying them to the state is a clean pattern that:
- Makes the code more maintainable
- Reduces the chance of state update errors
- Improves readability with clear property assignments
(token && | ||
accountAddress && | ||
accountNetworkId && | ||
accountNetworkId === token?.networkId) || | ||
(!token?.price && token) |
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.
🧹 Nitpick (assertive)
Improve condition readability.
The condition logic is correct but could be more readable. Consider extracting the conditions into descriptive variables.
- if (
- (token &&
- accountAddress &&
- accountNetworkId &&
- accountNetworkId === token?.networkId) ||
- (!token?.price && token)
- ) {
+ const hasValidAccountInfo = token && accountAddress && accountNetworkId && accountNetworkId === token?.networkId;
+ const isTokenWithoutPrice = !token?.price && token;
+ if (hasValidAccountInfo || isTokenWithoutPrice) {
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
(token && | |
accountAddress && | |
accountNetworkId && | |
accountNetworkId === token?.networkId) || | |
(!token?.price && token) | |
const hasValidAccountInfo = token && accountAddress && accountNetworkId && accountNetworkId === token?.networkId; | |
const isTokenWithoutPrice = !token?.price && token; | |
if (hasValidAccountInfo || isTokenWithoutPrice) { |
Summary by CodeRabbit
Refactor
Code Quality