8000 fix pending payment disappear by boufni95 · Pull Request #360 · shocknet/wallet2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix pending payment disappear #360

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

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Components/Background.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,11 @@ export const Background = () => {
return
}
if (optimisticOperations.length > 0) {
dispatch(removeOptimisticOperation(sourceId));
optimisticOperations.forEach(o => {
if (totalData.find(e => e.operationId === o.operationId)) {
dispatch(removeOptimisticOperation([o.operationId]));
}
})
}

const accumulatedHistory = {
Expand Down
17 changes: 13 additions & 4 deletions src/Pages/Send/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,15 @@ export const Send = () => {

}, [dispatch, optimisticOperations, router, selectedSource, note, destination]);


const updateOptmisiticOpId = useCallback((operation_id: string, newId: string) => {
const newOps = optimisticOperations.map(op => {
if (op.operationId === operation_id) {
return { ...op, operationId: newId }
}
return op
})
dispatch(updateOptimisticOperation(newOps))
}, [dispatch, optimisticOperations]);

const handleSubmit = useCallback(async () => {
if (destination.type === InputClassification.UNKNOWN) {
Expand Down Expand Up @@ -273,7 +281,7 @@ export const Send = () => {
case InputClassification.NOFFER: {
if (!amount) {
toast.error(<Toast title="Error" message={"no amount provided to spontaneous offer"} />)
dispatch(removeOptimisticOperation(selectedSource.id))
dispatch(removeOptimisticOperation([optimisticOperationId]));
return
}
const invoice = await createNofferInvoice(destination.noffer!, selectedSource.keys, amount);
Expand All @@ -284,10 +292,11 @@ export const Send = () => {
payRes = await handlePayBitcoinAddress(selectedSource, destination.data, amount, satsPerByte)
}
}
updateOptmisiticOpId(optimisticOperationId, payRes.operation_id)
if (selectedSource.pubSource) {
dispatch(procOperationsUpdateHook())
} else {
dispatch(removeOptimisticOperation(selectedSource.id));
dispatch(removeOptimisticOperation([payRes.operation_id]));
const timestamp = Date.now() / 1000;
dispatch(setLatestLnurlOperation({
pub: selectedSource.id,
Expand Down Expand Up @@ -324,7 +333,7 @@ export const Send = () => {
} else {
console.log("Unknown error occured", err);
}
dispatch(removeOptimisticOperation(selectedSource.id));
dispatch(removeOptimisticOperation([optimisticOperationId]));
}
setSendRunning(false);

Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Stats/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const Stats = () => {
toast.error('Error fetching metrics ' + res.reason)
return
}
console.log(res)
console.log({ appMetrics: res })
const apps = Object.keys(res.apps)
console.log(apps)
const usageData = {} as UsageData
Expand Down
6 changes: 3 additions & 3 deletions src/State/Slices/HistorySlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,11 @@ const historySlice = createSlice({
}
update(state)
},
updateOptimisticOperation: (state, action: PayloadAction<(Types.UserOperation & { source: string, sourceLabel: string, optLabel?: string })[]>) =>{
updateOptimisticOperation: (state, action: PayloadAction<(Types.UserOperation & { source: string, sourceLabel: string, optLabel?: string })[]>) => {
state.optimisticOperations = action.payload;
},
removeOptimisticOperation: (state, action: PayloadAction<string>) => {
state.optimisticOperations = state.optimisticOperations.filter(op => op.source !== action.payload)
removeOptimisticOperation: (state, action: PayloadAction<string[]>) => {
state.optimisticOperations = state.optimisticOperations.filter(op => !action.payload.includes(op.operationId));
},
procOperationsUpdateHook: (state) => {
state.operationsUpdateHook = Math.random()
Expand Down
0