-
Notifications
You must be signed in to change notification settings - Fork 5
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: update referendum comments #1548
Conversation
WalkthroughThis pull request introduces enhancements to the comment handling system in the governance module. A new Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
cb5971e
to
6effb62
Compare
Still some Unknown NANs |
Resolved as much as possible. |
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: 6
Outside diff range and nitpick comments (1)
packages/extension-polkagate/src/fullscreen/governance/post/Comment.tsx (1)
152-160
: Consider renaming thenoSource
prop for clarity.The
noSource
prop determines whether the comment is from Polkassembly or SubSquare. The namenoSource
might be misleading, as it suggests the absence of a source.Consider renaming it to
isPolkassembly
orisFromPolkassembly
to enhance readability and make the code self-explanatory.
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- packages/extension-polkagate/src/fullscreen/governance/post/Comment.tsx (3 hunks)
- packages/extension-polkagate/src/fullscreen/governance/utils/helpers.ts (3 hunks)
Additional comments not posted (3)
packages/extension-polkagate/src/fullscreen/governance/post/Comment.tsx (3)
169-170
: Successfully integratedVoteType
component to display voter decisions.The inclusion of the
VoteType
component correctly displays each commenter's vote type, fulfilling one of the key objectives outlined in the PR. This enhancement provides readers with valuable context about the voting stance of each commenter.
175-179
: Consistent display of source labels based on comment origin.The conditional rendering of 'Polkassembly' or 'SubSquare' labels accurately reflects the source of each comment, improving transparency for users.
183-183
: Proper placement of theEditedTag
component.The
EditedTag
is appropriately rendered, ensuring that edited comments are clearly indicated to users, which enhances trust and transparency.
packages/extension-polkagate/src/fullscreen/governance/utils/helpers.ts
Outdated
Show resolved
Hide resolved
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
🧹 Outside diff range and nitpick comments (2)
packages/extension-polkagate/src/hooks/useReferendum.ts (2)
47-47
: Initialize State Variable with Explicit DefaultThe state variable
referendumCommentsSS
is initialized without an explicit default value. To prevent potential undefined behavior, consider initializing it withnull
or an empty array, depending on how it's used later in the code.Suggested change:
-const [referendumCommentsSS, setReferendumCommentsSS] = useState<CommentType[] | null>(); +const [referendumCommentsSS, setReferendumCommentsSS] = useState<CommentType[] | null>(null);
386-389
: Handle Errors When Fetching CommentsCurrently, errors when fetching comments using
getReferendumCommentsSS
are logged but not handled gracefully:getReferendumCommentsSS(chainName, id).then((res) => { setReferendumCommentsSS(res); }).catch(console.error);Consider providing user feedback or setting an appropriate state to handle the error in the UI.
Suggested change:
getReferendumCommentsSS(chainName, id).then((res) => { setReferendumCommentsSS(res); -}).catch(console.error); +}).catch((error) => { + console.error(error); + // Optionally set an error state or fallback + setReferendumCommentsSS(null); +});
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- packages/extension-polkagate/src/fullscreen/governance/utils/helpers.ts (11 hunks)
- packages/extension-polkagate/src/hooks/useReferendum.ts (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/extension-polkagate/src/fullscreen/governance/utils/helpers.ts
🔇 Additional comments (3)
packages/extension-polkagate/src/hooks/useReferendum.ts (3)
11-11
: Verify Type Definitions and ImportsThe import statement adds
CommentType
,Referendum
,ReferendumHistory
,ReferendumPA
,ReferendumSb
, andTopMenu
from'../fullscreen/governance/utils/types'
. Ensure that these types are correctly defined and exported in the specified path to prevent any type errors or import issues.
17-17
: Confirm Availability of Imported Helper FunctionsThe import now includes
getReferendumCommentsSS
andisFinished
from'../fullscreen/governance/utils/helpers'
. Please verify that these functions are properly implemented and exported in the helpers module.
326-326
: Ensure Accurate Timestamp HandlingWhen setting the
created_at
property, multiple sources are considered:created_at: referendumPA?.created_at || (referendumSb?.created_block_timestamp && referendumSb.created_block_timestamp * 1000) || createdAtOC,Ensure that the timestamps from different sources are in the same format (e.g., milliseconds since the epoch) to prevent discrepancies in date display. Also, verify that
createdAtOC
is correctly calculated.
## [0.13.1](v0.13.0...v0.13.1) (2024-09-28) ### Bug Fixes * update referendum comments ([#1548](#1548)) ([da77ba5](da77ba5))
Close: #1495
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Enhancements
Bug Fixes