chore: add helpers for clipboard copy and paste#441
Conversation
📝 WalkthroughWalkthroughTwo shared async clipboard utility functions ( ChangesClipboard Utility Centralization
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pages/settings/wallets/EditWallet.tsx (1)
190-193:⚠️ Potential issue | 🟠 Major | ⚡ Quick winUse the edited wallet id for exported secret lookup.
The export flow uses
walletIdfor capability checks but switches toselectedWalletIdfornostrWalletConnectUrl. If they diverge, the wrong wallet secret can be copied.Suggested fix
- const nwcUrl = - useAppStore.getState().wallets[ - useAppStore.getState().selectedWalletId - ].nostrWalletConnectUrl; + const nwcUrl = + useAppStore.getState().wallets[walletId] + ?.nostrWalletConnectUrl;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pages/settings/wallets/EditWallet.tsx` around lines 190 - 193, The nostrWalletConnectUrl lookup is using selectedWalletId instead of walletId, which creates a mismatch when the export flow uses walletId for capability checks. Replace selectedWalletId with walletId in the wallet lookup for nostrWalletConnectUrl so that the same wallet identifier is used consistently throughout the export flow and the correct wallet's secret is copied.
🧹 Nitpick comments (1)
pages/receive/Withdraw.tsx (1)
61-63: ⚡ Quick winAwait
loadWithdrawalinpastefor consistent async flow.This avoids a floating promise and keeps behavior aligned with other paste handlers that await downstream loaders.
Suggested fix
async function paste() { const clipboardText = await readClipboardText(); if (clipboardText) { - loadWithdrawal(clipboardText); + await loadWithdrawal(clipboardText); } }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pages/receive/Withdraw.tsx` around lines 61 - 63, The loadWithdrawal function call in the paste handler is not being awaited, which creates a floating promise and breaks the consistent async flow pattern. Add the await keyword before the loadWithdrawal(clipboardText) call to ensure the promise is properly handled and the async operation completes before moving forward, keeping the behavior aligned with other paste handlers.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/utils.ts`:
- Around line 45-56: The copyToClipboard function lacks error handling for Web
platform failures. Add a try-catch block around the await
Clipboard.setStringAsync(text) call to handle potential rejections on Web due to
permission denial or clipboard unavailability. In the catch block, call
errorToast with an appropriate error message to provide user feedback when the
clipboard operation fails on Web platforms.
---
Outside diff comments:
In `@pages/settings/wallets/EditWallet.tsx`:
- Around line 190-193: The nostrWalletConnectUrl lookup is using
selectedWalletId instead of walletId, which creates a mismatch when the export
flow uses walletId for capability checks. Replace selectedWalletId with walletId
in the wallet lookup for nostrWalletConnectUrl so that the same wallet
identifier is used consistently throughout the export flow and the correct
wallet's secret is copied.
---
Nitpick comments:
In `@pages/receive/Withdraw.tsx`:
- Around line 61-63: The loadWithdrawal function call in the paste handler is
not being awaited, which creates a floating promise and breaks the consistent
async flow pattern. Add the await keyword before the
loadWithdrawal(clipboardText) call to ensure the promise is properly handled and
the async operation completes before moving forward, keeping the behavior
aligned with other paste handlers.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1e5e4896-eeab-4da6-87fe-3a27a2c0b96a
📒 Files selected for processing (9)
components/CreateInvoice.tsxlib/utils.tspages/Transaction.tsxpages/receive/Receive.tsxpages/receive/Withdraw.tsxpages/send/Address.tsxpages/send/Send.tsxpages/settings/wallets/EditWallet.tsxpages/settings/wallets/SetupWallet.tsx
Fixes the problem mentioned in #440 (comment), also DRYs up the clipboard code by moving it to utils
Summary by CodeRabbit