-
Notifications
You must be signed in to change notification settings - Fork 16
feat: allow resetting qrcode #605
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
base: master
Are you sure you want to change the base?
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 |
|---|---|---|
|
|
@@ -54,6 +54,7 @@ export interface WidgetContainerProps | |
| donationAddress?: string | ||
| donationRate?: number | ||
| convertedCurrencyObj?: CurrencyObject; | ||
| resetKey?: number; | ||
| } | ||
|
|
||
| const snackbarOptionsSuccess: OptionsObject = { | ||
|
|
@@ -138,6 +139,7 @@ export const WidgetContainer: React.FunctionComponent<WidgetContainerProps> = | |
| donationRate, | ||
| convertedCurrencyObj, | ||
| setConvertedCurrencyObj, | ||
| resetKey, | ||
| ...widgetProps | ||
| } = props; | ||
| const [internalCurrencyObj, setInternalCurrencyObj] = useState<CurrencyObject>(); | ||
|
|
@@ -161,6 +163,13 @@ export const WidgetContainer: React.FunctionComponent<WidgetContainerProps> = | |
|
|
||
| const [shiftCompleted, setShiftCompleted] = useState(false); | ||
|
|
||
| useEffect(() => { | ||
| if (resetKey !== undefined && resetKey > 0) { | ||
| setSuccess(false); | ||
| setShiftCompleted(false); | ||
| } | ||
| }, [resetKey]); | ||
|
Comment on lines
+166
to
+171
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. 🧩 Analysis chain🏁 Script executed: # First, examine the WidgetContainer.tsx file to understand state declarations
wc -l react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 182 🏁 Script executed: # Get the state declarations and useEffect hook in question
head -200 react/lib/components/Widget/WidgetContainer.tsx | tail -150Repository: PayButton/paybutton Length of output: 4297 🏁 Script executed: # Search for thisPaymentId usage in the file
rg -n 'thisPaymentId' react/lib/components/Widget/WidgetContainer.tsx -A 2 -B 2Repository: PayButton/paybutton Length of output: 767 🏁 Script executed: # Search for altpaymentShift usage
rg -n 'altpaymentShift|setAltpaymentShift' react/lib/components/Widget/WidgetContainer.tsx -A 2 -B 2Repository: PayButton/paybutton Length of output: 982 🏁 Script executed: # Search for currencyObj usage and initialization
rg -n 'currencyObj|setCurrencyObj' react/lib/components/Widget/WidgetContainer.tsx -A 2 -B 2Repository: PayButton/paybutton Length of output: 1744 🏁 Script executed: # Look for any existing reset logic or patterns for payment resets
rg -n 'reset|Reset' react/lib/components/Widget/WidgetContainer.tsx -A 2 -B 2Repository: PayButton/paybutton Length of output: 552 🏁 Script executed: # Find the Widget component to understand paymentId usage
fd -e tsx -e ts Widget.tsx | grep -v node_modules | head -5Repository: PayButton/paybutton Length of output: 150 🏁 Script executed: # Search for where paymentId is generated or used in payment verification
rg -n 'setThisPaymentId|setInternalPaymentId|new.*[Pp]aymentId|generatePaymentId|paymentId.*=' react/lib/components/Widget/ -A 2 -B 2Repository: PayButton/paybutton Length of output: 1972 🏁 Script executed: # Check if altpaymentShift comes from parent state management
rg -n 'setAltpaymentShift' react/lib/components/ -B 3 -A 1 | head -40Repository: PayButton/paybutton Length of output: 2990 🏁 Script executed: # Understand the transaction flow - where does paymentId get used for tracking
rg -n 'thisPaymentId' react/lib/components/ -B 2 -A 2Repository: PayButton/paybutton Length of output: 1727 🏁 Script executed: # Check how Widget component handles paymentId generation
rg -n 'setPaymentId\|generatePaymentId' react/lib/components/Widget/Widget.tsx -B 3 -A 3Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Look at the larger context of the resetKey useEffect - understand what happens after reset
sed -n '165,200p' react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 1227 🏁 Script executed: # Check if there are other resetKey patterns or payment flow resets elsewhere
rg -n 'setSuccess\|setShiftCompleted' react/lib/components/Widget/WidgetContainer.tsx -B 2 -A 2Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Understand if internalPaymentId auto-resets or if it persists across attempts
rg -n 'internalPaymentId\|internalAltpayment' react/lib/components/Widget/Widget.tsx -B 2 -A 2Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Search for where setPaymentId is called to understand payment ID generation
rg -n 'setPaymentId\|setThisPaymentId' react/lib/components/ -A 1 -B 1 | head -60Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Look at Widget component's payment ID handling
sed -n '180,220p' react/lib/components/Widget/Widget.tsxRepository: PayButton/paybutton Length of output: 1697 🏁 Script executed: # Search for payment ID generation logic
rg -n 'uuid\|generateId\|crypto.*random\|Math\.random' react/lib/components/Widget/ | head -20Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Check the Widget component structure around line 338 where setPaymentId callback is passed
sed -n '330,350p' react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 571 🏁 Script executed: # Search for where setPaymentId is actually used in Widget
rg -n 'setPaymentId' react/lib/components/Widget/Widget.tsx -B 2 -A 2Repository: PayButton/paybutton Length of output: 1224 🏁 Script executed: # Check how payment ID flows through - find where it's generated
rg -n 'paymentId.*uuid\|paymentId.*=\|paymentId.*function' react/lib/components/Widget/ -A 2Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Look for form generation or payment ID creation logic
rg -n 'createUnsignedTx\|createTxOutput\|getPaymentAddress' react/lib/components/Widget/Widget.tsx -B 1 -A 3 | head -50Repository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Check the complete context around the Widget component props/usage
sed -n '300,345p' react/lib/components/Widget/WidgetContainer.tsxRepository: PayButton/paybutton Length of output: 1566 🏁 Script executed: # Check if payment ID reset happens elsewhere or if there are comments about payment flow
rg -n 'payment.*reset\|reset.*payment' react/lib/components/Widget/ -iRepository: PayButton/paybutton Length of output: 45 🏁 Script executed: # Look at the larger context around line 641 to understand payment ID generation flow
sed -n '630,670p' react/lib/components/Widget/Widget.tsxRepository: PayButton/paybutton Length of output: 1062 🏁 Script executed: # Check if updateConvertedCurrencyObj context shows when payment ID is reset
sed -n '315,330p' react/lib/components/Widget/Widget.tsxRepository: PayButton/paybutton Length of output: 1014 Consider resetting When a payment attempt completes and Note: 🤖 Prompt for AI Agents |
||
|
|
||
| const paymentClient = getAltpaymentClient() | ||
|
|
||
| const addrType = getCurrencyTypeFromAddress(to); | ||
|
|
||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 335
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 306
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 1005
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 214
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 730
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 100
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 1082
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 2042
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 108
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 1490
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 365
🏁 Script executed:
Repository: PayButton/paybutton
Length of output: 847
Reset
altpaymentShiftinhandleSendAnotherto avoid stale shift data on subsequent payments.When a user clicks "Send Another Payment" after an altpayment transaction, the
altpaymentShiftstate persists at the parent level. This causes the next payment to initialize with stale shift data, potentially causing incorrect pair selection or shift initialization.Add
setAltpaymentShift(undefined)tohandleSendAnother:Suggested change
const handleSendAnother = (): void => { clearAutoCloseTimer(); setSuccess(false); + setAltpaymentShift(undefined); setResetKey(prev => prev + 1); };📝 Committable suggestion
🤖 Prompt for AI Agents