-
Notifications
You must be signed in to change notification settings - Fork 7
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
2.2.x b1 #675
base: main
Are you sure you want to change the base?
2.2.x b1 #675
Conversation
📝 WalkthroughWalkthroughThe pull request removes numerous exported constants from the configuration file and updates the project version and dependency in package.json. Several modal components now include new state variables for enabling actions, keydown event listeners (specifically handling the Enter key), and improved focus/blur behavior. Additionally, modifications have been made across various pages to adjust state management and event handling. Redux-related files have been updated to rename ticket redemption identifiers and to add new thunks and state properties. Lastly, a new dispatch is added in the routing logic to retrieve session-related information after login. Changes
Sequence Diagram(s)sequenceDiagram
participant U as User
participant M as Modal Component
participant E as Keydown Listener
participant A as Action Handler
U->>M: Open modal
M->>E: Attach keydown (Enter) event listener
U->>M: Press Enter key
E->>M: Invoke handleEnter()
alt Valid input & modal open
M->>A: Execute associated action (e.g., connect, add alias, fund)
else Invalid/disabled
M-->>U: No action triggered
end
sequenceDiagram
participant U as User
participant R as Router/Layout
participant S as Redux Store
U->>R: Successful login
R->>S: Dispatch getSessionsThunk({apiEndpoint, apiToken})
S-->>R: Update session state
✨ Finishing Touches
🪧 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: 2
🧹 Nitpick comments (14)
src/future-hopr-lib-components/PeerInfo/index.tsx (1)
31-35
: Enhanced Destructuring in PeersInfoThe multi-line destructuring of
props
(extractingpeerId
,nodeAddress
, and the rest via...rest
) increases readability. Note that whilepeerId
andnodeAddress
are immediately extracted, other props (e.g.shortenPeerId
andshortenPeerIdIfAliasPresent
) are still accessed viaprops
. For uniformity, consider destructuring all used properties if that suits the project style.src/future-hopr-lib-components/Modal/index.tsx (1)
39-48
: Refined Component Props Destructuring in ModalThe
Modal
component now destructures its props (onClose
,selectedValue
,open
,title
,children
,maxWidth
, anddisableScrollLock
) in a multi-line format, enhancing readability. As a side note, the use of@ts-ignore
in thehandleClose
function suggests there may be a type mismatch; consider revisiting the type definitions foronClose
to eliminate the need for suppression.src/future-hopr-lib-components/Modal/styled.tsx (1)
4-7
: Enhanced Destructuring Improves ReadabilityThe multi-line destructuring of the props (extracting
maxWidth
and the rest) in theSDialog
component improves code clarity and maintainability without altering functionality.src/components/Modal/node/FundChannelModal.tsx (1)
113-118
: Minor typesafety improvement opportunityWhile the keyboard event handler works correctly, consider using the more specific
KeyboardEvent
type instead ofany
for better type safety.-function handleEnter(event: any) { +function handleEnter(event: KeyboardEvent) {src/pages/node/configuration.tsx (3)
65-70
: Consider updating the useEffect dependency array.The dependency array only includes
localNotificationSettings
, but thehandleEnter
function also depends oncanSave
. This could potentially lead to stale closures where the event handler uses outdated values.- }, [localNotificationSettings]); + }, [localNotificationSettings, canSave]);
134-138
: Consider using a more specific type for the event parameter.The
event: any
type is too generic and loses type safety. Using the importedKeyboardEvent
type would be more appropriate.-function handleEnter(event: any) { +function handleEnter(event: KeyboardEvent) { - if (canSave && (event as KeyboardEvent).key === 'Enter') { + if (canSave && event.key === 'Enter') { handleSaveSettings(); } }
168-168
: Remove console.log statement.This console.log statement should be removed before merging to production.
- console.log('localNotificationSettings', localNotificationSettings);
src/store/slices/node/actionsFetching.ts (1)
89-94
: Good implementation of reducer cases for new actions.The reducer cases for the new actions are well-implemented and follow the same pattern as existing cases. However, there's a minor formatting issue with the semicolon placement.
builder.addCase(setRedeemAllTicketsFetching, (state, action) => { state.redeemAllTickets.isFetching = action.payload; - }); + }), builder.addCase(setResetTicketStatisticsFetching, (state, action) => { state.resetTicketStatistics.isFetching = action.payload; });src/components/Modal/node/SendMessageModal.tsx (3)
116-122
: Good addition of thecanSendMessage
variable but check the logic.The variable neatly encapsulates multiple conditions for enabling the send button, improving code readability. However, there may be a logical issue in one of the conditions:
(sendMode !== 'directMessage' && sendMode !== 'automaticPath' && numberOfHops < 0 && path === '')Should this be using
||
between thenumberOfHops < 0
andpath === ''
parts? As written, both conditions must be true, but the intent might be that either condition should disable sending.Verify the intent of this condition, especially when
sendMode
is neither 'directMessage' nor 'automaticPath'.
132-137
: Consider updating the useEffect dependency array.The dependency array doesn't include
canSendMessage
which is used in thehandleEnter
function. This could potentially lead to stale closures.- }, [loginData, message, selectedReceiver, sendMode]); + }, [loginData, message, selectedReceiver, sendMode, canSendMessage]);
282-287
: Consider improving thehandleEnter
function.There's unnecessary type casting and a console.log statement that should be removed before merging to production.
function handleEnter(event: KeyboardEvent) { - if (canSendMessage && (event as KeyboardEvent)?.key === 'Enter') { + if (canSendMessage && event.key === 'Enter') { - console.log('SendMessageModal event'); handleSendMessage(); } }src/components/Modal/node/WithdrawModal.tsx (2)
116-121
: Consider updating the useEffect dependency array.The dependency array includes all necessary state variables, but doesn't include
canWithdraw
which is used in thehandleEnter
function. This could potentially lead to stale closures.- }, [recipient, amount, apiEndpoint, apiToken, currency, loginData]); + }, [recipient, amount, apiEndpoint, apiToken, currency, loginData, canWithdraw]);
197-202
: Improve thehandleEnter
function.The function has unnecessary type casting and a console.log statement that should be removed before merging to production.
-function handleEnter(event: any) { +function handleEnter(event: KeyboardEvent) { - if (canWithdraw && (event as KeyboardEvent)?.key === 'Enter') { + if (canWithdraw && event.key === 'Enter') { - console.log('WithdrawModal event'); handleWithdraw(); } }src/pages/node/tickets.tsx (1)
95-106
: Consider using distinct loading states for the two buttonsBoth action buttons use
redeemAllTicketsFetching
for their loading state, which means they can't display independent loading states. This could confuse users if both actions are triggered in succession.Consider using
resetTicketStatistics.isFetching
for the reset button's loading state:- reloading={redeemAllTicketsFetching} + reloading={useAppSelector((store) => store.node.resetTicketStatistics.isFetching)}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (40)
config.ts
(0 hunks)package.json
(1 hunks)src/components/Card/index.tsx
(1 hunks)src/components/Code/CodeCopyBox/index.tsx
(1 hunks)src/components/ConnectNode/modal.tsx
(3 hunks)src/components/Faq/index.tsx
(2 hunks)src/components/Modal/node/AddAliasModal.tsx
(5 hunks)src/components/Modal/node/FundChannelModal.tsx
(5 hunks)src/components/Modal/node/OpenChannelModal.tsx
(5 hunks)src/components/Modal/node/OpenMultipleChannelsModal.tsx
(4 hunks)src/components/Modal/node/PingModal.tsx
(5 hunks)src/components/Modal/node/SendMessageModal.tsx
(6 hunks)src/components/Modal/node/WithdrawModal.tsx
(7 hunks)src/components/Stepper/index.tsx
(1 hunks)src/components/SubpageTitle/index.tsx
(1 hunks)src/future-hopr-lib-components/Button/chain-button.jsx
(1 hunks)src/future-hopr-lib-components/Button/index.tsx
(1 hunks)src/future-hopr-lib-components/Cards/GrayCard.tsx
(1 hunks)src/future-hopr-lib-components/Icons/JazzIcon.tsx
(1 hunks)src/future-hopr-lib-components/Modal/index.tsx
(2 hunks)src/future-hopr-lib-components/Modal/styled.tsx
(1 hunks)src/future-hopr-lib-components/NFT/index.jsx
(1 hunks)src/future-hopr-lib-components/Navbar/navBar.tsx
(1 hunks)src/future-hopr-lib-components/Navbar/navBarItems.tsx
(1 hunks)src/future-hopr-lib-components/Navbar/navButton.jsx
(1 hunks)src/future-hopr-lib-components/PeerInfo/index.tsx
(1 hunks)src/future-hopr-lib-components/Table/table-pro.tsx
(1 hunks)src/future-hopr-lib-components/Tooltip/tooltip-fixed-width.tsx
(1 hunks)src/hooks/useWatcher/index.ts
(1 hunks)src/pages/node/aliases.tsx
(1 hunks)src/pages/node/configuration.tsx
(5 hunks)src/pages/node/info/index.tsx
(1 hunks)src/pages/node/messages.tsx
(1 hunks)src/pages/node/metrics.tsx
(1 hunks)src/pages/node/ping.tsx
(1 hunks)src/pages/node/tickets.tsx
(4 hunks)src/store/slices/auth/actionsAsync.ts
(1 hunks)src/store/slices/node/actionsAsync.ts
(32 hunks)src/store/slices/node/actionsFetching.ts
(3 hunks)src/store/slices/node/initialState.ts
(2 hunks)
💤 Files with no reviewable changes (1)
- config.ts
🧰 Additional context used
🧬 Code Definitions (13)
src/future-hopr-lib-components/Tooltip/tooltip-fixed-width.tsx (2)
src/future-hopr-lib-components/Button/chain-button.jsx (1) (1)
rest
(26-30)src/future-hopr-lib-components/Navbar/navButton.jsx (1) (1)
rest
(45-48)
src/future-hopr-lib-components/Button/chain-button.jsx (1)
src/future-hopr-lib-components/Navbar/navButton.jsx (1) (1)
rest
(45-48)
src/future-hopr-lib-components/PeerInfo/index.tsx (2)
src/future-hopr-lib-components/Button/chain-button.jsx (1) (1)
rest
(26-30)src/future-hopr-lib-components/Navbar/navButton.jsx (1) (1)
rest
(45-48)
src/hooks/useWatcher/index.ts (1)
src/store/index.ts (1) (1)
useAppSelector
(26-26)
src/pages/node/messages.tsx (1)
src/store/index.ts (1) (1)
useAppSelector
(26-26)
src/store/slices/auth/actionsAsync.ts (1)
src/store/index.ts (1) (1)
RootState
(20-20)
src/pages/node/info/index.tsx (1)
src/store/index.ts (1) (1)
useAppSelector
(26-26)
src/future-hopr-lib-components/Button/index.tsx (2)
src/future-hopr-lib-components/Button/chain-button.jsx (1) (1)
rest
(26-30)src/future-hopr-lib-components/Navbar/navButton.jsx (1) (1)
rest
(45-48)
src/pages/node/configuration.tsx (1)
src/store/slices/app/index.ts (1) (1)
appActions
(118-118)
src/components/Modal/node/WithdrawModal.tsx (1)
src/store/index.ts (1) (1)
useAppSelector
(26-26)
src/store/slices/node/actionsAsync.ts (2)
src/store/slices/node/actionsFetching.ts (1) (1)
nodeActionsFetching
(24-43)src/store/index.ts (1) (1)
RootState
(20-20)
src/pages/node/tickets.tsx (3)
src/store/index.ts (2) (2)
useAppDispatch
(25-25)useAppSelector
(26-26)src/store/slices/node/actionsAsync.ts (1) (1)
actionsAsync
(1685-1719)src/future-hopr-lib-components/Button/IconButton.tsx (1) (1)
IconButton
(55-83)
src/components/Modal/node/OpenMultipleChannelsModal.tsx (2)
src/future-hopr-lib-components/Modal/styled.tsx (1) (1)
SDialogContent
(25-33)src/future-hopr-lib-components/Navbar/navButton.jsx (1) (1)
Button
(44-109)
🔇 Additional comments (88)
src/components/Code/CodeCopyBox/index.tsx (1)
11-15
: Improved code readability with multi-line destructuring.The parameter destructuring has been reformatted from a single line to a multi-line format, improving readability without changing any functionality.
src/pages/node/ping.tsx (1)
20-23
: Improved readability with multi-line object destructuring.The destructuring of
loginData
has been reformatted from a single line to a multi-line format, which is consistent with similar formatting changes throughout the codebase.package.json (2)
3-3
: Version bump to beta release.The project version has been updated from
2.1.15
to2.2.0-beta.0
, indicating this PR is preparing for a new beta release.
9-9
:❓ Verification inconclusive
SDK dependency update for compatibility with new version.
The
@hoprnet/hopr-sdk
dependency has been updated from version2.1.9
to2.2.0-beta.4
to align with the project's version bump.Let's verify the compatibility between the new SDK version and the application's current implementation:
🏁 Script executed:
#!/bin/bash # Look for any breaking changes or migration-related comments in the codebase rg -i "breaking|migration|upgrade|2\.2\." --type ts --type tsx --type jsxLength of output: 103
Below is an updated verification step. The previous search command failed due to an unrecognized file type error. To re‐verify the absence of any migration notes or breaking changes in TypeScript/TSX/JSX files related to the SDK upgrade, please run this revised script:
#!/bin/bash # Re-run the search for migration or breaking changes related to the SDK upgrade rg -i "breaking|migration|upgrade|2\.2\." -g "*.ts" -g "*.tsx" -g "*.jsx"If no output is produced, it indicates no migration-related comments were found—suggesting that the dependency update to
@hoprnet/[email protected]
is aligned with the version bump. However, please manually verify the script’s output and ensure that no compatibility issues are missed.Action:
- Re-run the above script.
- Confirm that no migration or breaking change messages are present.
- Then approve the dependency update accordingly.
src/future-hopr-lib-components/Button/chain-button.jsx (1)
26-30
: Improved readability with multi-line props destructuring.The destructuring of the
props
object has been reformatted from a single line to a multi-line format, consistent with similar changes in other components (e.g.,navButton.jsx
).src/future-hopr-lib-components/Navbar/navBarItems.tsx (1)
29-37
: Improved Function Signature FormattingThe updated multi-line parameter formatting for the
NavBarItems
component enhances readability and aligns the code with our formatting guidelines. No change in functionality was introduced.src/hooks/useWatcher/index.ts (1)
13-16
: Improved Destructuring for API CredentialsChanging the destructuring of
apiEndpoint
andapiToken
to a multi-line format improves clarity and consistency with similar changes elsewhere in the codebase.src/pages/node/aliases.tsx (1)
341-345
: Clearer Destructuring inhandleChange
Switching to a multi-line destructuring for
event.target
in thehandleChange
function improves clarity without affecting functionality.src/pages/node/messages.tsx (1)
19-22
: Refined Destructuring for Auth DataThe updated multi-line destructuring for
apiEndpoint
andapiToken
from the login data enhances the readability of the code. This change is consistent with similar updates in other parts of the codebase.
As a side note, please verify that omitting these variables from the dependency array in the associateduseEffect
is intentional.src/future-hopr-lib-components/Icons/JazzIcon.tsx (1)
11-16
: Enhanced Readability in Parameter DestructuringThe reformatting of the destructuring in the
JazzIcon
component—placing each parameter (address
,diameter
,className
, and...rest
) on its own line—improves the code’s readability. There are no functional changes, and the component continues to perform as expected.src/future-hopr-lib-components/Navbar/navButton.jsx (1)
45-48
: Consistent Multi-Line DestructuringThe updated multi-line destructuring of the
props
object (extractingsubMenu
and the rest of the properties) enhances clarity and aligns with our formatting standards. No functionality has been altered.src/future-hopr-lib-components/Tooltip/tooltip-fixed-width.tsx (1)
9-13
: Improved Props Destructuring in Tooltip ComponentExpanding the single-line destructuring into a multi-line format (listing
className
,notWide
, and...rest
on separate lines) makes the component easier to read and maintain. The functionality remains unchanged.src/future-hopr-lib-components/Modal/index.tsx (1)
11-14
: Enhanced Destructuring in Styled SDialog ComponentReformatting the destructuring of props in the
SDialog
styled component (extractingmaxWidthCss
and...rest
) into multiple lines improves legibility without affecting behavior.src/future-hopr-lib-components/Navbar/navBar.tsx (1)
17-21
: Improved Destructuring in Styled AppBar DefinitionThe refactoring of the
AppBar
component’s props destructuring into a multi-line format (listingtallerNavBarOnMobile
,webapp
, and...rest
) significantly enhances readability. This change is purely stylistic and does not affect the component’s behavior.src/pages/node/metrics.tsx (1)
159-162
: Enhanced Readability through Multi-line DestructuringBy reformatting the destructuring of
loginData
into a multi-line structure, the code is now more readable and consistent with similar changes across the codebase. No functional changes are introduced.src/components/SubpageTitle/index.tsx (1)
59-64
: Improved Parameter Formatting in Component SignatureTransforming the
SubpageTitle
component’s function signature to a multi-line format makes the component's props clearer without modifying its functionality.src/pages/node/info/index.tsx (1)
39-42
: Consistent Multi-line Destructuring for Redux StateExpanding the destructuring of
loginData
into a multi-line format improves clarity and maintains consistency across different pages. The change is purely stylistic while keeping the logic intact.src/future-hopr-lib-components/NFT/index.jsx (1)
60-68
: Clearer Function Signature with Multi-line DestructuringThe adjusted multi-line destructuring in the
CustomWidthTooltip
component enhances readability without affecting its behavior. The formatting aligns well with similar improvements across components.src/future-hopr-lib-components/Table/table-pro.tsx (1)
58-63
: Refactored Pagination Props Destructuring for ClarityChanging the destructuring of props (
count
,page
,rowsPerPage
,onPageChange
) in theTablePaginationActions
function into a multi-line format significantly improves the readability of the code. This is a purely cosmetic change with no impact on functionality.src/components/Card/index.tsx (1)
56-62
: Improved Parameter FormattingThe reformatting of the
Card
component’s parameters into a multi-line destructuring format enhances readability. No functional impact is introduced with this purely stylistic update.src/components/Stepper/index.tsx (1)
154-157
: Refactored Function Signature for ClarityThe updated multi-line destructuring in the
getStepState
function makes the parameter list (i.e.,index
andcurrentStep
) clearer and easier to read. This change is purely cosmetic and does not affect the function’s logic.src/future-hopr-lib-components/Cards/GrayCard.tsx (1)
85-94
: Enhanced Parameter Destructuring in GrayCardSplitting the props into separate lines in the
GrayCard
component improves code readability and adheres to consistent formatting practices without changing any functionality.src/future-hopr-lib-components/Button/index.tsx (1)
101-111
: Improved Props Destructuring in Button ComponentThe multi-line destructuring of the
Button
component’s props (includingimageOnly
,size70
,standardWidth
, etc.) enhances clarity. The changes are stylistic and have no impact on functionality.src/components/Faq/index.tsx (2)
2-8
: Good improvement on code readability.Breaking down Material UI imports into multiple lines makes the code more maintainable and easier to read.
117-121
: Function signature formatting improvement.The multi-line destructuring pattern enhances readability and is consistent with the formatting changes across the codebase.
src/components/ConnectNode/modal.tsx (4)
153-153
: Good variable extraction for condition logic.Creating the
canConnectToNode
variable makes the code more readable and centralizes the condition logic.
155-160
: Well-implemented keyboard event handling.Adding the event listener for keyboard events enhances user experience by allowing keyboard navigation. The cleanup function properly removes the listener when the component unmounts.
369-374
: Good implementation of Enter key functionality.The
handleEnter
function improves user experience by allowing the Enter key to submit the form. The console log statement helps with debugging.
457-457
: Consistent use of the new condition variable.Using the
canConnectToNode
variable here maintains consistency with its definition above.src/store/slices/auth/actionsAsync.ts (2)
8-11
: Improved import destructuring format.Breaking down the API destructuring into multiple lines improves readability.
17-24
: Enhanced function parameter formatting.The multi-line formatting of the thunk parameters and payload destructuring makes the code more readable and maintainable.
src/components/Modal/node/AddAliasModal.tsx (6)
37-43
: Excellent consolidation of condition logic.Creating the
canAddAlias
variable centralizes all validation conditions in one place, making the code more maintainable and easier to understand.
45-50
: Well-implemented keyboard event handling.Adding the event listener for keyboard events improves user experience. The cleanup function properly removes the listener on unmount.
76-76
: Good UX improvement for modal opening.Blurring the active element when opening the modal prevents unintended interactions and improves user experience.
139-144
: Good implementation of Enter key functionality.The
handleEnter
function improves form submission experience by supporting keyboard interaction, consistent with other modals in the application.
189-190
: Smart autofocus implementation.The conditional autofocus ensures the empty field receives focus, improving user experience when the modal opens.
Also applies to: 207-208
212-213
: Consistent use of the consolidated condition variable.Using the
canAddAlias
variable here maintains consistency with its definition above and simplifies the code.src/components/Modal/node/PingModal.tsx (7)
1-1
: Good update to importsAdding the
KeyboardEvent
type import is necessary for the new keyboard event handling functionality.
30-30
: Good refactoring with descriptive variableCreating a dedicated
canPing
variable improves code readability by clearly expressing the condition for enabling the ping button.
32-37
: Good implementation of keyboard event listenerThe useEffect correctly sets up and cleans up the keyboard event listener. This follows React best practices for event handling.
54-54
: Improved focus managementBlurring the active element when opening the modal provides a better user experience by removing focus from previously active elements.
119-124
: Good addition of keyboard shortcut functionalityThe
handleEnter
function enhances usability by allowing users to submit the form using the Enter key, which is a common UX pattern.
167-167
: Enhanced user experience with autoFocusSetting autoFocus on the input field improves usability by allowing immediate typing after the modal opens.
172-172
: Improved code readability with canPing variableUsing the
canPing
variable instead of an inline condition makes the code more maintainable and easier to understand.src/components/Modal/node/OpenMultipleChannelsModal.tsx (7)
1-1
: Good update to importsAdding the
useRef
import is necessary for the file input reference implementation.
29-29
: Enhanced code readability with descriptive variableCreating a dedicated
canOpen
variable improves code maintainability by centralizing the logic for enabling the action button.
31-36
: Well-implemented keyboard event handlingThe useEffect hook properly manages event listener lifecycle, adding it when dependencies change and cleaning it up on unmount.
179-179
: Improved focus managementBlurring the active element before opening the file input dialog improves user experience by ensuring clear focus states.
183-188
: Enhanced user experience with keyboard shortcutsThe
handleEnter
function properly implements the Enter key functionality, consistent with other modal components in the application.
244-244
: Better user experience with autoFocusAdding
autoFocus
to the amount field ensures users can immediately start typing after the CSV is loaded.
250-250
: Improved code clarity with canOpen variableUsing the
canOpen
variable instead of repeating the validation logic inline makes the code more maintainable.src/components/Modal/node/OpenChannelModal.tsx (7)
1-1
: Good update to importsAdding the
useEffect
import is necessary for the keyboard event handling implementation.
37-37
: Enhanced code readability with descriptive variableThe
canOpen
variable centralizes the validation logic, making it reusable and self-documenting.
39-44
: Properly implemented keyboard event handlingThe useEffect hook correctly sets up and cleans up event listeners, with appropriate dependencies.
52-52
: Improved focus managementBlurring the active element when opening the dialog ensures a clean focus state in the modal.
111-116
: Enhanced user experience with keyboard shortcutsThe
handleEnter
function implementation is consistent with other modals, creating a unified user experience.
158-158
: Smart implementation of conditional autoFocusAlternating the
autoFocus
between fields based on whether peerAddress is already provided improves user workflow.Also applies to: 168-168
174-174
: Improved code clarity with canOpen variableUsing the
canOpen
variable for the button's disabled state ensures consistent validation throughout the component.src/components/Modal/node/FundChannelModal.tsx (6)
1-1
: Good update to importsAdding the
useEffect
import supports the new keyboard event handling functionality.
31-31
: Improved code clarity with canFund variableThe descriptive
canFund
variable makes the validation logic more readable and maintainable.
33-38
: Well-implemented event handlingThe useEffect hook properly manages the event listener lifecycle with appropriate dependencies.
41-41
: Enhanced focus managementBlurring the active element before opening the dialog ensures a clean focus state transition.
155-155
: Smart implementation of conditional autoFocusThe conditional autoFocus implementation intelligently focuses on the right field based on whether channelId is already provided.
Also applies to: 165-165
171-171
: Improved code readabilityUsing the
canFund
variable for the button's disabled state makes the code more maintainable and self-documenting.src/pages/node/configuration.tsx (3)
57-63
: Good addition of thecanSave
variable for better code clarity.This new boolean condition cleanly encapsulates the logic for determining when the save button should be enabled or disabled, making the code more readable and maintainable.
128-132
: Nice refactoring from arrow function to regular function.The function signature change from an async arrow function to a regular function is good for consistency.
235-235
: Good use of thecanSave
variable for button enabling/disabling.Using the
canSave
variable to control the disabled state of the button improves both code readability and user experience.src/store/slices/node/actionsFetching.ts (2)
21-22
: Good addition of new actions for ticket management.The new actions for redeeming all tickets and resetting ticket statistics are well-named and follow the same pattern as existing actions.
41-42
: Properly exported new action creators.The action creators are correctly exported in the
nodeActionsFetching
object, maintaining consistency with the existing code structure.src/components/Modal/node/SendMessageModal.tsx (2)
232-232
: Good UX improvement with blur on modal open.Blurring the active element when opening the modal ensures that keyboard focus is properly managed.
355-355
: Good UX improvements with autoFocus and disabled state.Adding autoFocus to the message input when a receiver is selected and disabling the send button based on the
canSendMessage
variable are excellent UX improvements.Also applies to: 403-403
src/components/Modal/node/WithdrawModal.tsx (5)
6-12
: Improved import formatting.Breaking the imports into individual lines improves readability and will make future changes easier.
88-91
: Good use of destructuring for API credentials.Destructuring
apiEndpoint
andapiToken
fromloginData
makes the code cleaner and easier to read.
104-110
: Good addition of thecanWithdraw
variable.This variable clearly defines the conditions for when withdrawals are allowed, improving code readability and maintainability.
149-149
: Good TODO comment.The TODO comment clearly indicates a future enhancement to update the balances after a withdrawal operation.
288-288
: Good use of thecanWithdraw
variable for button enabling/disabling.Using the
canWithdraw
variable to control the disabled state of the button improves both code readability and user experience.src/store/slices/node/initialState.ts (1)
221-224
: Renamed state property for better clarityThe rename from
redeemTickets
toredeemAllTickets
provides better clarity about what this state property represents - the action of redeeming all tickets rather than individual ones.src/pages/node/tickets.tsx (5)
17-19
: Icons added for improved UI clarityGood addition of appropriate icons for the ticket management actions.
25-26
: State variables renamed for consistencyProperly renamed state variables to match the state property rename in the store.
44-55
: Updated function to use renamed thunkThe function now correctly calls the renamed thunk with proper parameters and handles the result.
57-68
: Added new function for resetting ticket statisticsGood implementation of the new reset functionality, following the same pattern as other similar functions.
83-94
: Updated button for ticket redemptionButton properly using the renamed fetching state.
src/store/slices/node/actionsAsync.ts (6)
81-83
: Added new SDK API function importsAdded
redeemAllTickets
andresetTicketStatistics
to the list of imported API functions.
856-881
: Properly implemented redeemAllTicketsThunkThe thunk is correctly implemented, following the established patterns. It dispatches the appropriate action to set the loading state and handles errors properly.
883-908
: Added new resetTicketStatisticsThunkGood implementation of the new reset functionality as a thunk. It follows the established patterns and correctly dispatches the loading state action.
1331-1346
: Updated reducer cases for redeemAllTicketsThunkThe reducer cases have been properly updated to match the renamed state property.
1347-1354
: Added reducer case for resetTicketStatisticsThunkThe implementation resets all the relevant ticket statistics values when the thunk is successfully fulfilled. This ensures a clean state for future statistics.
1712-1713
: Updated exports to include new thunksProperly added the new and renamed thunks to the exported actionsAsync object.
dispatch(nodeActionsFetching.setRedeemAllTicketsFetching(true)); | ||
try { |
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.
Incorrect fetching action in redeemChannelTicketsThunk
The redeemChannelTicketsThunk
is using setRedeemAllTicketsFetching
instead of a separate action specific to channel tickets. This could lead to unexpected loading state behavior.
Consider creating and using a dedicated action for channel ticket redemption:
- dispatch(nodeActionsFetching.setRedeemAllTicketsFetching(true));
+ dispatch(nodeActionsFetching.setRedeemChannelTicketsFetching(true));
This would require adding the new action in the actionsFetching.ts
file.
📝 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.
dispatch(nodeActionsFetching.setRedeemAllTicketsFetching(true)); | |
try { | |
dispatch(nodeActionsFetching.setRedeemChannelTicketsFetching(true)); | |
try { |
state.redeemAllTickets.isFetching = false; | ||
}); | ||
builder.addCase(redeemChannelTicketsThunk.rejected, (state) => { | ||
state.redeemTickets.isFetching = false; | ||
state.redeemAllTickets.isFetching = false; | ||
}); |
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.
Inconsistent state reference in redeemChannelTicketsThunk handlers
The fulfilled and rejected handlers for redeemChannelTicketsThunk
are setting state.redeemAllTickets.isFetching
to false. This is inconsistent with the action they're dispatching and could cause state management issues.
Consider updating to use a dedicated state property for channel tickets:
- state.redeemAllTickets.isFetching = false;
+ state.redeemChannelTickets.isFetching = false;
This would require adding the new state property in initialState.ts
as well.
📝 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.
state.redeemAllTickets.isFetching = false; | |
}); | |
builder.addCase(redeemChannelTicketsThunk.rejected, (state) => { | |
state.redeemTickets.isFetching = false; | |
state.redeemAllTickets.isFetching = false; | |
}); | |
state.redeemChannelTickets.isFetching = false; | |
}); | |
builder.addCase(redeemChannelTicketsThunk.rejected, (state) => { | |
state.redeemChannelTickets.isFetching = false; | |
}); |
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
🧹 Nitpick comments (1)
src/pages/node/aliases.tsx (1)
94-103
: Improved alias update logic to handle existing mappings.This enhancement checks if a peerId already has an alias and removes it before setting a new one, preventing orphaned or duplicate aliases. This is a good improvement for data consistency.
However, there's a missing trailing comma at the end of line 101 which should be fixed:
apiToken: loginData.apiToken ? loginData.apiToken : '', - }) + }),🧰 Tools
🪛 ESLint
[error] 101-102: Missing trailing comma.
(comma-dangle)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
package.json
(1 hunks)src/pages/node/aliases.tsx
(3 hunks)src/store/slices/node/actionsAsync.ts
(32 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- package.json
🧰 Additional context used
🧬 Code Definitions (2)
src/pages/node/aliases.tsx (3)
src/store/index.ts (1) (1)
useAppSelector
(26-26)src/store/slices/node/actionsAsync.ts (1) (1)
actionsAsync
(1685-1719)src/store/slices/auth/actionsAsync.ts (1) (1)
actionsAsync
(144-144)
src/store/slices/node/actionsAsync.ts (2)
src/store/slices/node/actionsFetching.ts (1) (1)
nodeActionsFetching
(24-43)src/store/index.ts (1) (1)
RootState
(20-20)
🪛 ESLint
src/pages/node/aliases.tsx
[error] 101-102: Missing trailing comma.
(comma-dangle)
🔇 Additional comments (9)
src/store/slices/node/actionsAsync.ts (7)
81-82
: API update with additional ticket management functions.The API has been updated to include
redeemAllTickets
andresetTicketStatistics
functions, which aligns with the new thunks added in this file.
753-753
: Incorrect fetching action in redeemChannelTicketsThunkThe
redeemChannelTicketsThunk
is usingsetRedeemAllTicketsFetching
instead of a dedicated action specific to channel tickets. This could lead to unexpected loading state behavior.Consider creating and using a dedicated action for channel ticket redemption:
- dispatch(nodeActionsFetching.setRedeemAllTicketsFetching(true)); + dispatch(nodeActionsFetching.setRedeemChannelTicketsFetching(true));This would require adding the new action in the
actionsFetching.ts
file.
766-767
: Inconsistent state reference in redeemChannelTicketsThunk conditionThe condition check for
redeemChannelTicketsThunk
is usingstate.redeemAllTickets.isFetching
which is inconsistent with the action name and purpose. This could cause unexpected behavior if both redemption processes run simultaneously.Consider using a dedicated state property for channel tickets:
- const isFetching = getState().node.redeemAllTickets.isFetching; + const isFetching = getState().node.redeemChannelTickets.isFetching;This would require adding the new state property in the initialState.
856-881
: New thunk for redeeming all tickets.This new thunk provides a dedicated function for redeeming all tickets, which separates this functionality from channel-specific ticket redemption. The implementation follows the established pattern for thunks in this file.
883-908
: New thunk for resetting ticket statistics.This adds functionality to reset ticket statistics, which complements the ticket management feature set. The implementation properly handles fetching state and error conditions.
1669-1673
: Inconsistent state reference in redeemChannelTicketsThunk handlersThe fulfilled and rejected handlers for
redeemChannelTicketsThunk
are settingstate.redeemAllTickets.isFetching
to false. This is inconsistent with the action they're dispatching and could cause state management issues.Consider updating to use a dedicated state property for channel tickets:
- state.redeemAllTickets.isFetching = false; + state.redeemChannelTickets.isFetching = false;This would require adding the new state property in
initialState.ts
as well.
1712-1713
: Exported newly added thunks.The new thunks have been properly exported in the
actionsAsync
object, making them available for use throughout the application.src/pages/node/aliases.tsx (2)
37-38
: Added utility for mapping peerIds to aliases.The addition of these selectors improves the component's ability to track which peer IDs already have aliases assigned, enabling more robust alias management.
357-360
: Improved code readability with multi-line destructuring.The destructuring assignment has been reformatted to a multi-line structure, which improves readability, especially as more properties might be added in the future.
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
♻️ Duplicate comments (2)
src/store/slices/node/actionsAsync.ts (2)
697-697
:⚠️ Potential issueIncorrect fetching action in redeemChannelTicketsThunk
The
redeemChannelTicketsThunk
is usingsetRedeemAllTicketsFetching
instead of a dedicated action specific to channel tickets. This could lead to unexpected loading state behavior.Consider creating and using a dedicated action for channel ticket redemption:
- dispatch(nodeActionsFetching.setRedeemAllTicketsFetching(true)); + dispatch(nodeActionsFetching.setRedeemChannelTicketsFetching(true));This would require adding the new action in the
actionsFetching.ts
file.
1623-1627
:⚠️ Potential issueInconsistent state reference in redeemChannelTicketsThunk handlers
The fulfilled and rejected handlers for
redeemChannelTicketsThunk
are settingstate.redeemAllTickets.isFetching
to false. This is inconsistent with the action they're dispatching and could cause state management issues.Consider updating to use a dedicated state property for channel tickets:
- state.redeemAllTickets.isFetching = false; + state.redeemChannelTickets.isFetching = false;This would require adding the new state property in
initialState.ts
as well.
🧹 Nitpick comments (5)
src/components/Modal/node/FundChannelModal.tsx (2)
113-118
: Consider adding type safety to the event parameter.The
any
type for the event parameter could be replaced with a more specific type.-function handleEnter(event: any) { +function handleEnter(event: KeyboardEvent) { if (openChannelModal && canFund && event.key === 'Enter') { console.log('FundChannelModal event'); handleAction(); } }
115-115
: Remove or improve console.log statement.This console log doesn't provide meaningful information for debugging and should be removed or enhanced with more context.
function handleEnter(event: any) { if (openChannelModal && canFund && event.key === 'Enter') { - console.log('FundChannelModal event'); + // Handled Enter key press in FundChannelModal handleAction(); } }src/components/Modal/node/SendMessageModal.tsx (3)
116-122
: Complex validation logic could be simplified.The
canSendMessage
logic is quite complex with multiple nested conditions. Consider breaking it down into smaller, more readable parts.-const canSendMessage = !( - selectedReceiver === null || - (sendMode !== 'directMessage' && sendMode !== 'automaticPath' && numberOfHops < 0 && path === '') || - message.length === 0 || - ((sendMode === 'directMessage' || (sendMode !== 'path' && numberOfHops < 1)) && selectedReceiver === hoprAddress) || - (sendMode === 'path' && path.length === 0) -); +// Check if a receiver is selected +const hasReceiver = selectedReceiver !== null; +// Check if message is not empty +const hasMessage = message.length > 0; +// Check if trying to send to self in direct mode +const isSendingToSelf = selectedReceiver === hoprAddress; +const isDirectToSelf = isSendingToSelf && (sendMode === 'directMessage' || (sendMode !== 'path' && numberOfHops < 1)); +// Check if path mode has a valid path +const hasValidPath = sendMode !== 'path' || path.length > 0; +// Check if routing configuration is valid +const hasValidRouting = sendMode === 'directMessage' || sendMode === 'automaticPath' || + !(numberOfHops < 0 && path === ''); + +const canSendMessage = hasReceiver && hasMessage && !isDirectToSelf && hasValidPath && hasValidRouting;
282-287
: Consider handling modifier keys in the Enter key event.The current implementation triggers on any Enter key press. Consider checking for modifier keys to avoid triggering when user is pressing Ctrl+Enter or Shift+Enter to create new lines in the message.
function handleEnter(event: KeyboardEvent) { - if (canSendMessage && (event as KeyboardEvent)?.key === 'Enter') { + if (canSendMessage && event.key === 'Enter' && !event.shiftKey && !event.ctrlKey && !event.altKey) { console.log('SendMessageModal event'); handleSendMessage(); } }
284-284
: Remove or improve console.log statement.This console log statement doesn't provide meaningful information for debugging and should be removed or enhanced.
function handleEnter(event: KeyboardEvent) { if (canSendMessage && (event as KeyboardEvent)?.key === 'Enter') { - console.log('SendMessageModal event'); + // Handled Enter key press in SendMessageModal handleSendMessage(); } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
src/components/ConnectNode/modal.tsx
(4 hunks)src/components/Modal/node/AddAliasModal.tsx
(5 hunks)src/components/Modal/node/FundChannelModal.tsx
(5 hunks)src/components/Modal/node/OpenChannelModal.tsx
(5 hunks)src/components/Modal/node/OpenMultipleChannelsModal.tsx
(4 hunks)src/components/Modal/node/PingModal.tsx
(5 hunks)src/components/Modal/node/SendMessageModal.tsx
(6 hunks)src/components/Modal/node/WithdrawModal.tsx
(6 hunks)src/pages/node/aliases.tsx
(2 hunks)src/pages/node/configuration.tsx
(5 hunks)src/pages/node/info/index.tsx
(5 hunks)src/pages/node/tickets.tsx
(5 hunks)src/router.tsx
(1 hunks)src/store/slices/node/actionsAsync.ts
(15 hunks)src/store/slices/node/initialState.ts
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
- src/pages/node/configuration.tsx
- src/components/Modal/node/PingModal.tsx
- src/components/ConnectNode/modal.tsx
- src/components/Modal/node/OpenMultipleChannelsModal.tsx
- src/pages/node/aliases.tsx
- src/components/Modal/node/WithdrawModal.tsx
- src/components/Modal/node/OpenChannelModal.tsx
- src/components/Modal/node/AddAliasModal.tsx
- src/store/slices/node/initialState.ts
🧰 Additional context used
🧬 Code Definitions (5)
src/router.tsx (1)
src/store/slices/node/index.ts (1)
nodeActionsAsync
(64-64)
src/components/Modal/node/FundChannelModal.tsx (2)
src/future-hopr-lib-components/Modal/styled.tsx (1)
SDialogContent
(22-30)src/future-hopr-lib-components/Navbar/navButton.jsx (1)
Button
(44-106)
src/pages/node/info/index.tsx (1)
src/store/index.ts (1)
useAppSelector
(26-26)
src/store/slices/node/actionsAsync.ts (2)
src/store/slices/node/actionsFetching.ts (1)
nodeActionsFetching
(24-43)src/store/index.ts (1)
RootState
(20-20)
src/pages/node/tickets.tsx (3)
src/store/index.ts (2)
useAppDispatch
(25-25)useAppSelector
(26-26)src/store/slices/node/actionsAsync.ts (1)
actionsAsync
(1648-1683)src/future-hopr-lib-components/Button/IconButton.tsx (1)
IconButton
(55-83)
🔇 Additional comments (25)
src/components/Modal/node/FundChannelModal.tsx (5)
31-31
: Improved validation logic withcanFund
variable.Centralizing the validation logic in a single variable improves code readability and maintainability.
33-38
: Good addition of keyboard event handling.The useEffect hook appropriately sets up and cleans up the keyboard event listener, allowing users to submit the form with the Enter key. The dependency array correctly includes all relevant state variables.
41-41
: Improved focus management when opening modal.Blurring the active element before opening the modal prevents focus-related issues and improves user experience.
155-155
: Smart focus management withautoFocus
properties.The conditional autoFocus properties improve user experience by focusing on the appropriate input field based on whether the channelId is already populated.
Also applies to: 165-165
171-171
: Simplified button disabled logic using thecanFund
variable.Using the centralized
canFund
variable for the button's disabled state improves code readability and consistency.src/components/Modal/node/SendMessageModal.tsx (4)
132-137
: Good implementation of keyboard event handling.The useEffect hook properly sets up and cleans up the keyboard event listener. This enhances user experience by allowing message sending with the Enter key.
232-232
: Improved focus management when opening the modal.Blurring the active element before opening the modal prevents focus-related issues and improves user experience.
355-355
: Good usage of autoFocus for better user experience.The conditional autoFocus property on the message field improves user experience by focusing on the field when a receiver is selected.
403-403
: Simplified button disabled logic usingcanSendMessage
.Using the centralized
canSendMessage
variable for the button's disabled state improves code readability and consistency.src/router.tsx (1)
326-331
: New dispatch added to fetch minimum network probability after loginThis addition enhances the node connection process by retrieving the minimum network probability after a successful login. The implementation is clean and follows the established pattern of other API calls in this useEffect hook.
src/pages/node/info/index.tsx (4)
60-62
: Block number variables refactored for clarityThe implementation now uses more descriptive variable names from the Redux store, improving readability and maintainability.
64-64
: Added minimum network probability stateAdded state to expose the minimum network probability data from Redux, which aligns with the new functionality introduced throughout this PR.
330-381
: Enhanced node information display with improved block dataThe UI has been updated to provide more detailed information about the node's synchronization status, including provider address, current block, last indexed log block, and log checksum. These changes offer users greater visibility into node operations.
463-491
: Added ticket properties section with minimum network probabilityNew table section displays ticket information including minimum ticket winning probability, providing valuable context about the network configuration. The tooltip includes dynamic network name from the info object.
src/store/slices/node/actionsAsync.ts (5)
800-822
: Renamed redeemTicketsThunk to redeemAllTicketsThunkThe function has been renamed to better reflect its purpose of redeeming all tickets at once. The implementation has been updated consistently with the new naming.
824-846
: Added new resetTicketStatisticsThunkNew thunk to reset ticket statistics, enhancing the ticket management functionality. The implementation follows the established pattern for async thunks.
959-985
: Added new getMinimumNetworkProbabilityThunkNew thunk to retrieve the minimum network probability from the API. This enhances the available information about network configuration.
1637-1645
: Added reducer cases for minimum network probabilityAdded proper handlers for the new getMinimumNetworkProbabilityThunk to update Redux state with the probability data. The implementation follows the established pattern for other similar thunks.
1675-1678
: Updated actionsAsync exports with new and renamed thunksThe exported actionsAsync object has been updated to include the new thunks and the renamed thunk, ensuring they're available for use throughout the application.
src/pages/node/tickets.tsx (6)
17-20
: Added imports for new UI functionalityAdded icon imports to support the new reset ticket statistics button.
25-30
: Updated state variables for consistency with backend changesRenamed variables to match the backend naming changes and added new state variables to access ticket price, network info, and minimum probability data.
47-58
: Updated redeemAllTickets handler to use renamed thunkThe function has been updated to call the renamed thunk with the required parameters. The implementation is clean and includes proper error handling.
60-71
: Added new handler for resetting ticket statisticsNew function to reset ticket statistics using the new thunk, following the same pattern as other API calls in this component.
86-109
: Enhanced UI with new reset statistics buttonAdded a new button to reset ticket statistics and updated the reloading props to reflect the correct loading state. This provides users with more control over their ticket data.
119-147
: Added ticket properties display sectionNew table section displays ticket properties including price and minimum winning probability, providing users with important network configuration information. This complements the changes in the info page.
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: 12
♻️ Duplicate comments (2)
src/store/slices/node/actionsAsync.ts (2)
700-700
:⚠️ Potential issueIncorrect fetching action in redeemChannelTicketsThunk
The
redeemChannelTicketsThunk
is usingsetRedeemAllTicketsFetching
instead of a dedicated action for channel tickets. This could lead to unexpected loading state behavior.Consider creating and using a dedicated action for channel ticket redemption:
- dispatch(nodeActionsFetching.setRedeemAllTicketsFetching(true)); + dispatch(nodeActionsFetching.setRedeemChannelTicketsFetching(true));This would require adding the new action in the
actionsFetching.ts
file.
1659-1663
:⚠️ Potential issueInconsistent state reference in redeemChannelTicketsThunk handlers
The fulfilled and rejected handlers for
redeemChannelTicketsThunk
are settingstate.redeemAllTickets.isFetching
to false. This is inconsistent with the action they're dispatching and could cause state management issues.Consider updating to use a dedicated state property for channel tickets:
- state.redeemAllTickets.isFetching = false; + state.redeemChannelTickets.isFetching = false;This would require adding the new state property in
initialState.ts
as well.
🧹 Nitpick comments (5)
src/components/ConnectNode/modal.tsx (1)
389-394
: Good implementation of the Enter key functionality.The handleEnter function successfully complements the UI button by providing keyboard functionality, improving accessibility and user experience.
Consider removing or conditionally showing the console.log statement in production environments:
function handleEnter(event: KeyboardEvent) { if (props.open && canConnectToNode && event.key === 'Enter') { - console.log('ConnectNode event'); useNode({}); } }
src/components/Modal/node/OpenSessionModal.tsx (3)
117-123
: Complex condition for canSendMessage could be simplifiedThe condition for
canSendMessage
is quite complex and might be difficult to understand and maintain.Consider breaking it down into separate, named conditions for better readability:
- const canSendMessage = !( - selectedReceiver === null || - (sendMode !== 'directMessage' && sendMode !== 'automaticPath' && numberOfHops < 0 && path === '') || - message.length === 0 || - ((sendMode === 'directMessage' || (sendMode !== 'path' && numberOfHops < 1)) && selectedReceiver === hoprAddress) || - (sendMode === 'path' && path.length === 0) - ); + const hasReceiver = selectedReceiver !== null; + const hasValidPath = !(sendMode === 'path' && path.length === 0); + const hasMessage = message.length > 0; + const isNotSendingToSelf = !((sendMode === 'directMessage' || (sendMode !== 'path' && numberOfHops < 1)) && selectedReceiver === hoprAddress); + const hasValidHopsForMode = !(sendMode !== 'directMessage' && sendMode !== 'automaticPath' && numberOfHops < 0 && path === ''); + + const canSendMessage = hasReceiver && hasValidPath && hasMessage && isNotSendingToSelf && hasValidHopsForMode;
161-161
: Remove commented out codeThere's a commented line that should be removed as it's no longer needed and may cause confusion.
- //const validatedReceiver = validatePeerId(selectedReceiver);
183-183
: Use strict equality comparisonUsing strict equality (
===
) is preferred over loose equality (==
) in TypeScript/JavaScript.- if (sendMode == 'path') { + if (sendMode === 'path') {src/pages/node/sessions.tsx (1)
347-362
: Simplify unnecessary FragmentThe Fragment wrapping the IconButton is unnecessary since there's only one child element.
actions={ - <> <IconButton iconComponent={<GetAppIcon />} tooltipText={ <span> EXPORT <br /> {tabLabel} channels as a CSV </span> } disabled={!channelsData || Object.keys(channelsData).length === 0} onClick={handleExport} /> - </> }🧰 Tools
🪛 Biome (1.9.4)
[error] 348-361: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment(lint/complexity/noUselessFragments)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (10)
package.json
(1 hunks)src/components/ConnectNode/modal.tsx
(4 hunks)src/components/Modal/node/OpenSessionModal.tsx
(1 hunks)src/pages/node/channelsOutgoing.tsx
(3 hunks)src/pages/node/sessions.tsx
(1 hunks)src/pages/node/tickets.tsx
(5 hunks)src/router.tsx
(4 hunks)src/store/slices/node/actionsAsync.ts
(15 hunks)src/store/slices/node/actionsFetching.ts
(3 hunks)src/store/slices/node/initialState.ts
(5 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- package.json
- src/store/slices/node/initialState.ts
🧰 Additional context used
🧬 Code Definitions (6)
src/pages/node/channelsOutgoing.tsx (1)
src/components/Modal/node/OpenSessionModal.tsx (1)
OpenSessionModal
(98-433)
src/router.tsx (1)
src/store/slices/node/index.ts (1)
nodeActionsAsync
(64-64)
src/pages/node/sessions.tsx (1)
src/store/slices/node/actionsAsync.ts (1)
actionsAsync
(1693-1729)
src/store/slices/node/actionsAsync.ts (2)
src/store/slices/node/actionsFetching.ts (1)
nodeActionsFetching
(26-47)src/store/index.ts (1)
RootState
(20-20)
src/pages/node/tickets.tsx (3)
src/store/index.ts (2)
useAppDispatch
(25-25)useAppSelector
(26-26)src/store/slices/node/actionsAsync.ts (1)
actionsAsync
(1693-1729)src/future-hopr-lib-components/Button/IconButton.tsx (1)
IconButton
(55-83)
src/components/ConnectNode/modal.tsx (1)
src/store/slices/node/index.ts (1)
nodeActionsAsync
(64-64)
🪛 ESLint
src/router.tsx
[error] 347-348: Missing trailing comma.
(comma-dangle)
[error] 354-355: Missing trailing comma.
(comma-dangle)
src/pages/node/sessions.tsx
[error] 58-59: Missing trailing comma.
(comma-dangle)
[error] 65-66: Missing trailing comma.
(comma-dangle)
src/components/ConnectNode/modal.tsx
[error] 332-333: Missing trailing comma.
(comma-dangle)
[error] 339-340: Missing trailing comma.
(comma-dangle)
🪛 Biome (1.9.4)
src/pages/node/sessions.tsx
[error] 348-361: Avoid using unnecessary Fragment.
A fragment is redundant if it contains only one child, or if it is the child of a html element, and is not a keyed fragment.
Unsafe fix: Remove the Fragment
(lint/complexity/noUselessFragments)
🔇 Additional comments (27)
src/components/ConnectNode/modal.tsx (3)
153-153
: Improving code clarity with a state variable.Creating the
canConnectToNode
variable improves readability by centralizing the button enabling logic in one place.
155-160
: Good implementation of keyboard event handling.Adding the keydown event listener with proper cleanup enhances the user experience by allowing Enter key functionality. The dependencies array is comprehensive, ensuring the listener updates when relevant state changes.
477-477
: Good use of state variable for button disabled property.Replacing the direct check with the
canConnectToNode
variable improves consistency and makes the code more maintainable.src/pages/node/channelsOutgoing.tsx (2)
25-25
: Good addition of OpenSessionModal importThe import is correctly placed with other modal imports, providing a logical organization of the code.
188-189
: Appropriately increased width for Actions columnIncreasing the width from '188px' to '225px' accommodates the new OpenSessionModal component that's being added to the actions section.
src/router.tsx (3)
29-29
: Good import of SessionsPage componentThe import of the SessionsPage component is properly placed with the other page imports.
58-58
: Appropriate icon import for Sessions featureThe SettingsPhoneIcon is a suitable choice for representing sessions functionality.
162-169
: Well-structured addition of Sessions navigation itemThe Sessions menu item is correctly added to the NETWORKING section with appropriate properties.
Note: The
numberSessions
key is used, but there doesn't appear to be a corresponding entry in thenumberForDrawer
object. Consider adding this to display session counts in the drawer.src/components/Modal/node/OpenSessionModal.tsx (2)
1-58
: Well-structured imports and styled componentsThe imports are organized by category (React, HOPR Components, MUI) and the styled components are well defined with appropriate styles.
69-97
: Well-implemented utility functions and typesThe component props interface and the
sortAddresses
utility function are well-designed, providing clear types and functionality.src/store/slices/node/actionsFetching.ts (3)
21-24
: Proper action additions for ticket-related operationsThese new action creators align well with the expanded functionality for ticket management in the application. They follow the existing naming conventions and action type patterns.
43-46
: Export of new action creators follows established patternsThe new action creators are properly exported in the
nodeActionsFetching
object, maintaining the existing structure and organization of the code.
93-104
: Appropriate reducer cases added for new actionsThe new reducer cases correctly update the corresponding state properties when the actions are dispatched. The implementation follows the established pattern in the codebase.
src/pages/node/tickets.tsx (6)
17-19
: Appropriate icon imports for new functionalityThe added icon imports support the new UI elements for ticket management operations.
25-30
: Redux state selector updates for ticket functionalityState selectors have been updated from
redeemTicketsFetching
toredeemAllTicketsFetching
to align with the renamed Redux actions. New selectors forinfo
,ticketPrice
, andminimumNetworkProbability
have been added to support the additional ticket properties display.
47-58
: Refactored handleRedeemAllTickets implementationThe function has been updated to use the new
redeemAllTicketsThunk
and properly unwraps the promise to handle successful redemption.
60-71
: New handleResetTicketsStatistics functionThis new function provides the ability to reset ticket statistics, using the newly added
resetTicketStatisticsThunk
.
95-96
: Updated reloading prop for ticket redemption buttonThe IconButton now correctly references
redeemAllTicketsFetching
to show the loading state during ticket redemption.
179-207
: Well-structured table for ticket propertiesThe new table for displaying ticket properties is well-structured and includes helpful tooltips to explain each property to users. It properly displays formatted values and handles null/undefined cases.
src/store/slices/node/actionsAsync.ts (8)
43-46
: New type imports for extended functionalityThe type imports have been correctly added to support the new session and probability functionality.
76-87
: Integrated new API functionsThe API functions for minimum ticket probability, sessions, and resetting ticket statistics have been properly added to the destructured import list.
803-809
: Renamed redeemAllTicketsThunk implementationThe thunk has been properly renamed from
redeemTickets
toredeemAllTickets
to better represent its functionality of redeeming all tickets.
827-853
: New resetTicketStatisticsThunk implementationThe new thunk for resetting ticket statistics is well-implemented, following the established patterns for async thunks in the codebase.
966-992
: New getMinimumNetworkProbabilityThunk implementationThe implementation of the thunk for fetching minimum network probability follows the codebase's established patterns for async operations.
994-1020
: New getSessionsThunk implementationThe implementation of the thunk for fetching sessions follows the codebase's established patterns for async operations.
1673-1690
: Properly implemented handlers for new thunksThe fulfilled and rejected handlers for the new thunks (
getMinimumNetworkProbabilityThunk
andgetSessionsThunk
) are correctly implemented, following the established patterns in the codebase.
1720-1724
: Updated actionsAsync export objectThe actionsAsync object has been properly updated to include the new thunks, making them available for use throughout the application.
dispatch( | ||
nodeActionsAsync.getMinimumNetworkProbabilityThunk({ | ||
apiEndpoint, | ||
apiToken: apiToken ? apiToken : '', | ||
}), | ||
); | ||
dispatch( | ||
nodeActionsAsync.getSessionsThunk({ | ||
apiEndpoint, | ||
apiToken: apiToken ? apiToken : '', | ||
protocol: 'udp' | ||
}), | ||
) | ||
dispatch( | ||
nodeActionsAsync.getSessionsThunk({ | ||
apiEndpoint, | ||
apiToken: apiToken ? apiToken : '', | ||
protocol: 'tcp' | ||
}), | ||
); |
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.
Fix missing trailing commas in dispatch calls.
ESLint has flagged missing trailing commas in the session thunk dispatches.
nodeActionsAsync.getSessionsThunk({
apiEndpoint,
apiToken: apiToken ? apiToken : '',
- protocol: 'udp'
+ protocol: 'udp',
}),
nodeActionsAsync.getSessionsThunk({
apiEndpoint,
apiToken: apiToken ? apiToken : '',
- protocol: 'tcp'
+ protocol: 'tcp',
}),
📝 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.
dispatch( | |
nodeActionsAsync.getMinimumNetworkProbabilityThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
}), | |
); | |
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'udp' | |
}), | |
) | |
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'tcp' | |
}), | |
); | |
dispatch( | |
nodeActionsAsync.getMinimumNetworkProbabilityThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
}), | |
); | |
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'udp', | |
}), | |
) | |
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'tcp', | |
}), | |
); |
🧰 Tools
🪛 ESLint
[error] 332-333: Missing trailing comma.
(comma-dangle)
[error] 339-340: Missing trailing comma.
(comma-dangle)
dispatch( | ||
nodeActionsAsync.getSessionsThunk({ | ||
apiEndpoint, | ||
apiToken: apiToken ? apiToken : '', | ||
protocol: 'udp' | ||
}), | ||
) | ||
dispatch( | ||
nodeActionsAsync.getSessionsThunk({ | ||
apiEndpoint, | ||
apiToken: apiToken ? apiToken : '', | ||
protocol: 'tcp' | ||
}), | ||
); |
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.
Missing trailing commas in thunk parameters
The protocol parameter objects are missing trailing commas, which is inconsistent with the code style in the rest of the file.
Apply these fixes:
dispatch(
nodeActionsAsync.getSessionsThunk({
apiEndpoint,
apiToken: apiToken ? apiToken : '',
- protocol: 'udp'
+ protocol: 'udp',
}),
)
dispatch(
nodeActionsAsync.getSessionsThunk({
apiEndpoint,
apiToken: apiToken ? apiToken : '',
- protocol: 'tcp'
+ protocol: 'tcp',
}),
);
📝 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.
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'udp' | |
}), | |
) | |
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'tcp' | |
}), | |
); | |
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'udp', | |
}), | |
) | |
dispatch( | |
nodeActionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'tcp', | |
}), | |
); |
🧰 Tools
🪛 ESLint
[error] 347-348: Missing trailing comma.
(comma-dangle)
[error] 354-355: Missing trailing comma.
(comma-dangle)
import GetAppIcon from '@mui/icons-material/GetApp'; | ||
import { truncateEthereumAddress } from '../../utils/blockchain'; | ||
|
||
function ChannelsPage() { |
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.
🛠️ Refactor suggestion
Component name doesn't match file name
The file is named sessions.tsx
but exports a component named ChannelsPage
. This could lead to confusion when importing and using the component.
Rename the component to match the file or update the file name:
- function ChannelsPage() {
+ function SessionsPage() {
And update the export:
- export default ChannelsPage;
+ export default SessionsPage;
📝 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.
function ChannelsPage() { | |
function SessionsPage() { | |
// ... component implementation | |
} | |
export default SessionsPage; |
protocol: 'udp' | ||
}), | ||
) | ||
dispatch( | ||
actionsAsync.getSessionsThunk({ | ||
apiEndpoint, | ||
apiToken: apiToken ? apiToken : '', | ||
protocol: 'tcp' | ||
}), |
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.
Missing trailing commas in thunk parameters
The protocol parameter objects are missing trailing commas, which is inconsistent with the code style in the rest of the file.
Apply these fixes:
dispatch(
actionsAsync.getSessionsThunk({
apiEndpoint,
apiToken: apiToken ? apiToken : '',
- protocol: 'udp'
+ protocol: 'udp',
}),
)
dispatch(
actionsAsync.getSessionsThunk({
apiEndpoint,
apiToken: apiToken ? apiToken : '',
- protocol: 'tcp'
+ protocol: 'tcp',
}),
);
📝 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.
protocol: 'udp' | |
}), | |
) | |
dispatch( | |
actionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'tcp' | |
}), | |
protocol: 'udp', | |
}), | |
) | |
dispatch( | |
actionsAsync.getSessionsThunk({ | |
apiEndpoint, | |
apiToken: apiToken ? apiToken : '', | |
protocol: 'tcp', | |
}), | |
); |
🧰 Tools
🪛 ESLint
[error] 58-59: Missing trailing comma.
(comma-dangle)
[error] 65-66: Missing trailing comma.
(comma-dangle)
<IconButton | ||
iconComponent={<RotateLeftIcon />} | ||
tooltipText={ | ||
<span> | ||
RESET | ||
<br /> | ||
ticket statistics | ||
</span> | ||
} | ||
reloading={redeemAllTicketsFetching} | ||
onClick={handleResetTicketsStatistics} | ||
/> |
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.
Incorrect loading state reference for reset statistics button
The reset statistics button is using redeemAllTicketsFetching
for its loading state, but it should use a dedicated loading state related to resetting statistics.
Apply this fix:
- reloading={redeemAllTicketsFetching}
+ reloading={useAppSelector((store) => store.node.resetTicketStatistics.isFetching)}
Or add a dedicated variable at the top of the component:
+ const resetTicketStatisticsFetching = useAppSelector((store) => store.node.resetTicketStatistics.isFetching);
// Then use it in the component
- reloading={redeemAllTicketsFetching}
+ reloading={resetTicketStatisticsFetching}
📝 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.
<IconButton | |
iconComponent={<RotateLeftIcon />} | |
tooltipText={ | |
<span> | |
RESET | |
<br /> | |
ticket statistics | |
</span> | |
} | |
reloading={redeemAllTicketsFetching} | |
onClick={handleResetTicketsStatistics} | |
/> | |
// ... (other imports and code at the top of your component file) | |
import { useAppSelector } from 'path-to-your-store-hook'; | |
const TicketsPage = () => { | |
// Declare the dedicated loading state variable for resetting statistics | |
const resetTicketStatisticsFetching = useAppSelector( | |
(store) => store.node.resetTicketStatistics.isFetching | |
); | |
// Other component logic and state declarations | |
// ... | |
return ( | |
<> | |
{/* ... other component JSX ... */} | |
<IconButton | |
iconComponent={<RotateLeftIcon />} | |
tooltipText={ | |
<span> | |
RESET | |
<br /> | |
ticket statistics | |
</span> | |
} | |
reloading={resetTicketStatisticsFetching} | |
onClick={handleResetTicketsStatistics} | |
/> | |
{/* ... other component JSX ... */} | |
</> | |
); | |
}; | |
export default TicketsPage; |
// resetTicketStatisticsThunk | ||
builder.addCase(resetTicketStatisticsThunk.fulfilled, (state) => { | ||
if (!state.statistics.data) return; | ||
state.statistics.data.neglectedValue = '0'; | ||
state.statistics.data.redeemedValue = '0'; | ||
state.statistics.data.rejectedValue = '0'; | ||
state.statistics.data.winningCount = 0; | ||
}); |
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.
Missing apiEndpoint check in resetTicketStatisticsThunk handler
The fulfilled handler for resetTicketStatisticsThunk
is missing the check for whether the API endpoint matches the current one, which is present in other thunk handlers.
Apply this fix:
builder.addCase(resetTicketStatisticsThunk.fulfilled, (state) => {
+ if (action.meta.arg.apiEndpoint !== state.apiEndpoint) return;
if (!state.statistics.data) return;
state.statistics.data.neglectedValue = '0';
state.statistics.data.redeemedValue = '0';
state.statistics.data.rejectedValue = '0';
state.statistics.data.winningCount = 0;
});
Committable suggestion skipped: line range outside the PR's diff.
const isFetching = getState().node.redeemAllTickets.isFetching; | ||
if (isFetching) { |
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.
Inconsistent condition check in redeemChannelTicketsThunk
The condition check is using redeemAllTickets.isFetching
which is shared with the all tickets redemption functionality, potentially causing race conditions.
Apply this fix:
- const isFetching = getState().node.redeemAllTickets.isFetching;
+ const isFetching = getState().node.redeemChannelTickets.isFetching;
This would require adding a new state property in the initialState.
📝 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.
const isFetching = getState().node.redeemAllTickets.isFetching; | |
if (isFetching) { | |
const isFetching = getState().node.redeemChannelTickets.isFetching; | |
if (isFetching) { |
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
🧹 Nitpick comments (4)
src/components/Modal/node/OpenSessionModal.tsx (4)
23-24
: Add a trailing comma after the last import for compliance with ESLint rules.ESLint flagged a missing trailing comma (comma-dangle). This helps maintain cleaner diffs and consistent code style.
-import { - DialogTitle, - DialogActions, - CircularProgress, - TextField, - SelectChangeEvent, - Select, - MenuItem, - Autocomplete, - Tooltip, - IconButton as IconButtonMui -} from '@mui/material'; +import { + DialogTitle, + DialogActions, + CircularProgress, + TextField, + SelectChangeEvent, + Select, + MenuItem, + Autocomplete, + Tooltip, + IconButton as IconButtonMui, +} from '@mui/material';🧰 Tools
🪛 ESLint
[error] 23-24: Missing trailing comma.
(comma-dangle)
154-159
: Simplify or extract the complex send condition.The boolean logic to determine
canSendMessage
is quite large and may be difficult to maintain. Consider extracting it into a more descriptive function or simplifying the conditions within the component.
284-304
: Avoid relying on the older"Spacebar"
event key.Modern browsers use
" "
or"Space"
for the space key. Using"Spacebar"
might not work consistently.-if (e.key === ' ' || e.key === 'Spacebar') { +if (e.key === ' ') { e.preventDefault(); ... }
471-472
: Add trailing comma in JSX return elements.ESLint flagged a missing trailing comma here. Including the trailing comma in multi-line JSX can help maintain consistency and cleaner diffs.
- </IconButtonMui> - </PathNode> + </IconButtonMui>, + </PathNode>,🧰 Tools
🪛 ESLint
[error] 471-472: Missing trailing comma.
(comma-dangle)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
yarn.lock
is excluded by!**/yarn.lock
,!**/*.lock
📒 Files selected for processing (1)
src/components/Modal/node/OpenSessionModal.tsx
(1 hunks)
🧰 Additional context used
🪛 ESLint
src/components/Modal/node/OpenSessionModal.tsx
[error] 23-24: Missing trailing comma.
(comma-dangle)
[error] 471-472: Missing trailing comma.
(comma-dangle)
🔇 Additional comments (2)
src/components/Modal/node/OpenSessionModal.tsx (2)
169-174
: Repeat of previous advice: add event listener conditionally and fix dependencies.The component is adding a global keydown listener for the Enter key, potentially conflicting with other parts of the app. Also, the dependency array excludes
canSendMessage
,openModal
, andhandleSendMessage
, which may cause stale closures.Revisit the previous approach:
useEffect(() => { + if (openModal) { window.addEventListener('keydown', handleEnter as EventListener); return () => { window.removeEventListener('keydown', handleEnter as EventListener); }; + } - }, [loginData, message, selectedReceiver, sendMode]); + }, [loginData, message, selectedReceiver, sendMode, canSendMessage, openModal, handleSendMessage]);
388-400
: Confirm usage of 'listenHost' and 'sessionTarget'.These state variables are never referenced in
handleSendMessage
nor passed elsewhere. Verify whether they're needed for session initialization or can be removed.Do you want to keep them for future expansions, or should they be integrated into the payload? Please confirm.
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
🧹 Nitpick comments (2)
src/components/Modal/node/OpenSessionModal.tsx (2)
167-168
: Rename or simplify the double negative variable to improve clarity.
intermediatePathEmptyLink
is set by negating conditions twice, which is confusing. Consider a clearer name and logic, such ashasNullInIntermediatePath
orisPathValid
, for better readability.
24-25
: Add trailing commas to meet ESLint's comma-dangle requirement.The static analysis tool flagged missing trailing commas. Insert them to conform to your linting rules.
IconButton as IconButtonMui -} from '@mui/material'; +}, from '@mui/material'; ... - (elem, index)=>{ + (elem, index)=>{ ... - </PathNode> + </PathNode>,Also applies to: 165-166, 477-478
🧰 Tools
🪛 ESLint
[error] 24-25: Missing trailing comma.
(comma-dangle)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/components/Modal/node/OpenSessionModal.tsx
(1 hunks)
🧰 Additional context used
🧬 Code Definitions (1)
src/components/Modal/node/OpenSessionModal.tsx (2)
src/store/slices/node/initialState.ts (1)
AddressesType
(53-53)src/store/slices/node/actionsAsync.ts (1)
actionsAsync
(1693-1729)
🪛 ESLint
src/components/Modal/node/OpenSessionModal.tsx
[error] 24-25: Missing trailing comma.
(comma-dangle)
[error] 165-166: Missing trailing comma.
(comma-dangle)
[error] 477-478: Missing trailing comma.
(comma-dangle)
🔇 Additional comments (3)
src/components/Modal/node/OpenSessionModal.tsx (3)
197-202
: Conditionally attach the keydown listener only when the modal is open.Attaching global listeners could interfere with other components. This was recommended in a previous review.
221-279
: Verify usage of 'listenHost' and 'sessionTarget' in session creation.Although you check both fields to enable the "Open session" button, these values are never forwarded to the
sendMessageThunk
payload. Verify whether you intended to include them in the request body or needed them for a different step.
324-330
: Avoid capturing Enter key when the modal is closed.
handleEnter
triggers sending even whenopenModal
is false, potentially frustrating other parts of the UI. This was also mentioned in a prior review.
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
🧹 Nitpick comments (8)
src/pages/node/aliases.tsx (1)
94-103
: Logic improvement for alias uniqueness, but remove debugging code.The logic to remove existing aliases before creating new ones prevents duplicate mappings for the same peerId, which is a good enhancement. However, there's an unnecessary console.log statement that should be removed.
- if (peerIdsWithAliases.includes(data.peerId)) { - console.log(peerIdToAliasLink, data.peerId, peerIdToAliasLink[data.peerId]); + if (peerIdsWithAliases.includes(data.peerId)) { await dispatch( actionsAsync.removeAliasThunk({ alias: peerIdToAliasLink[data.peerId],src/components/Modal/node/OpenSessionModal.tsx (7)
173-175
: Remove debugging console log.This console.log statement appears to be leftover debugging code and should be removed.
- useEffect(()=>{ - console.log(intermediatePathError) - }, [intermediatePathError]);
198-198
: Remove commented-out code.There's a commented-out line that should be removed.
- //const validatedReceiver = validatePeerId(destination);
214-214
: Use strict equality check.Use strict equality (
===
) instead of loose equality (==
) for type safety.- if (sendMode == 'path') { + if (sendMode === 'path') {
232-232
: Remove console log statements.These console.log statements appear to be leftover debugging code and should be removed.
- console.log('@message: ', res?.challenge); handleCloseModal(); }) .catch((e) => { - console.log('@message err:', e); let errMsg = `Sending message failed`;And in the handleEnter function:
if (canOpenSession && (event as KeyboardEvent)?.key === 'Enter') { - console.log('OpenSessionModal event'); handleOpenSession(); }
Also applies to: 236-236, 286-286
344-350
: Remove commented-out code.There's a chunk of commented-out code that should be removed.
- // renderOption={(option)=>{ - // return ( - // <span> - // {JSON.stringify(option)} - // </span> - // ) - // }}
405-407
: Remove commented-out code.There's a commented-out line that should be removed.
<Autocomplete - // key={`path-node-${pathIndex}-Autocomplete`} value={pathNode}
24-25
: Fix style issues flagged by ESLint.There are several style issues flagged by ESLint that should be fixed:
- Add missing trailing commas:
IconButton as IconButtonMui - } from '@mui/material'; + } from '@mui/material'; const SFormGroup = styled(FormGroup)` flex-direction: row; - ` + `; const intermediatePathError = fullPath.findIndex( (elem, index)=>{ return elem === fullPath[index+1] - } + }, ) !== -1; </PathNode> - + , )Also applies to: 88-88, 156-157, 437-438
🧰 Tools
🪛 ESLint
[error] 24-25: Missing trailing comma.
(comma-dangle)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
src/components/Modal/node/OpenSessionModal.tsx
(1 hunks)src/pages/node/aliases.tsx
(3 hunks)src/pages/node/channelsIncoming.tsx
(4 hunks)src/pages/node/channelsOutgoing.tsx
(3 hunks)src/pages/node/peers.tsx
(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- src/pages/node/channelsOutgoing.tsx
🧰 Additional context used
🧬 Code Definitions (4)
src/pages/node/peers.tsx (1)
src/components/Modal/node/OpenSessionModal.tsx (1)
OpenSessionModal
(125-491)
src/pages/node/aliases.tsx (2)
src/store/slices/node/actionsAsync.ts (1)
actionsAsync
(1693-1729)src/components/Modal/node/OpenSessionModal.tsx (1)
OpenSessionModal
(125-491)
src/pages/node/channelsIncoming.tsx (1)
src/components/Modal/node/OpenSessionModal.tsx (1)
OpenSessionModal
(125-491)
src/components/Modal/node/OpenSessionModal.tsx (2)
src/store/slices/node/initialState.ts (1)
AddressesType
(53-53)src/store/slices/node/actionsAsync.ts (1)
actionsAsync
(1693-1729)
🪛 ESLint
src/components/Modal/node/OpenSessionModal.tsx
[error] 24-25: Missing trailing comma.
(comma-dangle)
[error] 156-157: Missing trailing comma.
(comma-dangle)
[error] 437-438: Missing trailing comma.
(comma-dangle)
🔇 Additional comments (7)
src/pages/node/peers.tsx (2)
20-20
: Good addition of the OpenSessionModal component.The OpenSessionModal import enhances the peer interaction functionality by allowing users to initiate sessions directly from the peers list.
189-191
: Implementation looks correct.The OpenSessionModal component is correctly implemented with the peerId prop, providing a consistent UX alongside other peer actions like ping, message sending, and channel management.
src/pages/node/channelsIncoming.tsx (3)
26-26
: Good addition of the OpenSessionModal component.The OpenSessionModal import enhances the channel interaction functionality by allowing users to initiate sessions directly from the channels list.
142-142
: Appropriate UI adjustments for new action button.The column width adjustments are necessary to accommodate the new OpenSessionModal button in the actions column, ensuring proper layout and spacing.
Also applies to: 157-158
315-317
: Implementation looks correct.The OpenSessionModal component is correctly implemented with the peerId prop, maintaining consistent UX with other components that use this modal.
src/pages/node/aliases.tsx (2)
30-30
: Good state management improvements.The addition of the peerId selector and alias links enhances the component's functionality by providing access to necessary state for alias management and session operations.
Also applies to: 38-39
185-187
: Implementation looks correct.The OpenSessionModal component is correctly implemented with the peerId prop, providing consistent UX alongside other peer actions.
useEffect(() => { | ||
window.addEventListener('keydown', handleEnter as EventListener); | ||
return () => { | ||
window.removeEventListener('keydown', handleEnter as EventListener); | ||
}; | ||
}, [loginData, destination, sendMode]); |
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.
🛠️ Refactor suggestion
Improve keydown event listener management.
The current implementation adds a global keydown event listener without checking if the modal is open, which could interfere with other components. Additionally, the dependencies array is incomplete.
useEffect(() => {
- window.addEventListener('keydown', handleEnter as EventListener);
- return () => {
- window.removeEventListener('keydown', handleEnter as EventListener);
- };
- }, [loginData, destination, sendMode]);
+ if (openModal) {
+ window.addEventListener('keydown', handleEnter as EventListener);
+ return () => {
+ window.removeEventListener('keydown', handleEnter as EventListener);
+ };
+ }
+ }, [loginData, destination, sendMode, canOpenSession, openModal]);
Also update the handleEnter
function:
function handleEnter(event: KeyboardEvent) {
- if (canOpenSession && (event as KeyboardEvent)?.key === 'Enter') {
+ if (openModal && canOpenSession && (event as KeyboardEvent)?.key === 'Enter') {
console.log('OpenSessionModal event');
handleOpenSession();
}
}
Summary by CodeRabbit
New Features
SessionsPage
component for managing session data and retrieving session-related information upon connecting to the node.OpenSessionModal
for managing session interactions within the messaging application.Chores