-
Notifications
You must be signed in to change notification settings - Fork 9
Feature/sync lists delete upvote #596
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -132,18 +132,30 @@ export const ListDetails = ({ admins, listId, listDetails, savedUsers }: ListDet | |||||||||
| admins.includes(viewer.accountId ?? "") || listDetails.owner?.id === viewer.accountId; | ||||||||||
|
|
||||||||||
| const handleUpvote = () => { | ||||||||||
| const onChainId = Number(listDetails.on_chain_id); | ||||||||||
|
|
||||||||||
|
Comment on lines
+135
to
+136
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
If 🛡️ Proposed guard const handleUpvote = () => {
const onChainId = Number(listDetails.on_chain_id);
+ if (Number.isNaN(onChainId)) return;
if (isUpvoted) {📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||
| if (isUpvoted) { | ||||||||||
| listsContractClient | ||||||||||
| .remove_upvote({ list_id: Number(listDetails.on_chain_id) }) | ||||||||||
| .catch((error) => console.error("Error upvoting:", error)); | ||||||||||
| .remove_upvote({ list_id: onChainId }) | ||||||||||
| .then(async ({ txHash }) => { | ||||||||||
| if (txHash && viewer.accountId) { | ||||||||||
| await syncApi.listRemoveUpvote(onChainId, txHash, viewer.accountId).catch(() => {}); | ||||||||||
| } | ||||||||||
| }) | ||||||||||
| .catch((error) => console.error("Error removing upvote:", error)); | ||||||||||
|
|
||||||||||
| dispatch.listEditor.handleListToast({ | ||||||||||
| name: truncate(listDetails?.name ?? "", 15), | ||||||||||
| type: ListFormModalType.DOWNVOTE, | ||||||||||
| }); | ||||||||||
| } else { | ||||||||||
| listsContractClient | ||||||||||
| .upvote({ list_id: Number(listDetails.on_chain_id) }) | ||||||||||
| .upvote({ list_id: onChainId }) | ||||||||||
| .then(async ({ txHash }) => { | ||||||||||
| if (txHash && viewer.accountId) { | ||||||||||
| await syncApi.listUpvote(onChainId, txHash, viewer.accountId).catch(() => {}); | ||||||||||
| } | ||||||||||
| }) | ||||||||||
| .catch((error) => console.error("Error upvoting:", error)); | ||||||||||
|
|
||||||||||
| dispatch.listEditor.handleListToast({ | ||||||||||
|
|
||||||||||
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.
dataForList?.on_chain_idis passed directly withoutNumber()conversion, unlikeListDetails.tsx.In
ListDetails.tsx(Line 135), the same value is converted viaNumber(listDetails.on_chain_id), but here the raw value from the API is passed to both the contract method (which expectslist_id: number) andsyncApi. Ifon_chain_idis a string from the API response, this could cause a type mismatch at the contract level.Apply the same normalization used in
ListDetails.tsx:🔧 Proposed fix
const handleUpvote = (e: React.MouseEvent) => { e.stopPropagation(); + const onChainId = Number(dataForList?.on_chain_id); + if (Number.isNaN(onChainId)) return; if (isUpvoted) { listsContractClient - .remove_upvote({ list_id: dataForList?.on_chain_id }) + .remove_upvote({ list_id: onChainId }) .then(async ({ txHash }) => { if (txHash && viewer.accountId) { await syncApi - .listRemoveUpvote(dataForList?.on_chain_id, txHash, viewer.accountId) + .listRemoveUpvote(onChainId, txHash, viewer.accountId) .catch(() => {}); } }) .catch((error) => console.error("Error removing upvote:", error)); // ... } else { listsContractClient - .upvote({ list_id: dataForList?.on_chain_id }) + .upvote({ list_id: onChainId }) .then(async ({ txHash }) => { if (txHash && viewer.accountId) { await syncApi - .listUpvote(dataForList?.on_chain_id, txHash, viewer.accountId) + .listUpvote(onChainId, txHash, viewer.accountId) .catch(() => {}); } }) .catch((error) => console.error("Error upvoting:", error));🤖 Prompt for AI Agents