-
Notifications
You must be signed in to change notification settings - Fork 13
Use SwapManager #265
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
Use SwapManager #265
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -116,21 +116,42 @@ const SwapLine = ({ swap }: { swap: PendingReverseSwap | PendingSubmarineSwap }) | |
| } | ||
|
|
||
| export default function SwapsList() { | ||
| const { swapProvider } = useContext(LightningContext) | ||
| const { arkadeLightning, swapManager, getSwapHistory } = useContext(LightningContext) | ||
| const [swapHistory, setSwapHistory] = useState<(PendingReverseSwap | PendingSubmarineSwap)[]>([]) | ||
|
|
||
| // Load initial swap history | ||
| useEffect(() => { | ||
| const choresOnInit = async () => { | ||
| if (!swapProvider) return | ||
| const loadHistory = async () => { | ||
| if (!arkadeLightning) return | ||
| try { | ||
| await swapProvider.refreshSwapsStatus() | ||
| setSwapHistory(await swapProvider.getSwapHistory()) | ||
| const history = await getSwapHistory() | ||
| setSwapHistory(history) | ||
| } catch (err) { | ||
| consoleError(err, 'Error fetching swap history:') | ||
| } | ||
| } | ||
| choresOnInit() | ||
| }, [swapProvider]) | ||
| loadHistory() | ||
| }, [arkadeLightning]) | ||
|
|
||
| // Subscribe to swap updates from SwapManager for real-time updates | ||
| useEffect(() => { | ||
| if (!swapManager) return | ||
|
|
||
| const unsubscribe = swapManager.onSwapUpdate((swap) => { | ||
| setSwapHistory((prev) => { | ||
| const existingIndex = prev.findIndex((s) => s.id === swap.id) | ||
| if (existingIndex >= 0) { | ||
| const updated = [...prev] | ||
| updated[existingIndex] = swap | ||
| return updated | ||
| } | ||
| // New swap, add to beginning | ||
| return [swap, ...prev] | ||
| }) | ||
|
Comment on lines
+140
to
+150
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: #!/bin/bash
# Search for PendingReverseSwap and PendingSubmarineSwap type definitions
fd -t f "\.ts$|\.tsx$" | head -20
rg -n "interface PendingReverseSwap|type PendingReverseSwap" -A 15
rg -n "interface PendingSubmarineSwap|type PendingSubmarineSwap" -A 15
rg -n "\.id\s*:|\.response\.id\s*:" -B 2 -A 2Repository: arkade-os/wallet Length of output: 599 🏁 Script executed: #!/bin/bash
# Search for swap type definitions
rg -n "type Pending(Reverse|Submarine)Swap|interface Pending(Reverse|Submarine)Swap" -A 20
# Search for .response.id usage
rg -n "\.response\.id" -B 3 -A 1
# Search for swap.id usage
rg -n "swap\.id" -B 2 -A 1
# Look for the SwapsList.tsx file and check key usage
fd "SwapsList\.tsx" -x cat -nRepository: arkade-os/wallet Length of output: 8774 Use consistent identifier for swap updates and React keys: Line 142 matches swaps by 🤖 Prompt for AI Agents |
||
| }) | ||
|
|
||
| return unsubscribe | ||
| }, [swapManager]) | ||
|
|
||
| if (swapHistory.length === 0) return <EmptySwapList /> | ||
|
|
||
|
|
||
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.