Skip to content

Commit cc2e8ee

Browse files
committed
fix: fetching only one request and replacing it in the requests array
1 parent fa51c63 commit cc2e8ee

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

packages/invoice-dashboard/src/lib/view-requests.svelte

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
signer = wallet?.accounts[0]?.address;
6969
}
7070
71-
$: isRequestPayed, getRequests(), (activeRequest = undefined);
71+
$: isRequestPayed, getOneRequest(activeRequest);
7272
7373
onMount(() => {
7474
currencyManager = initializeCurrencyManager(currencies);
@@ -93,6 +93,28 @@
9393
}
9494
};
9595
96+
const getOneRequest = async (activeRequest: any) => {
97+
try {
98+
loading = true;
99+
100+
const _request = await requestNetwork?.fromRequestId(
101+
activeRequest?.requestId!
102+
);
103+
104+
requests = requests?.filter(
105+
(request) => request.requestId !== activeRequest.requestId
106+
);
107+
requests = [...requests, _request.getData()].sort(
108+
(a, b) => b.timestamp - a.timestamp
109+
);
110+
111+
loading = false;
112+
} catch (error) {
113+
loading = false;
114+
console.error("Failed to fetch request:", error);
115+
}
116+
};
117+
96118
$: {
97119
if (requests && loading) {
98120
loading = false;

0 commit comments

Comments
 (0)