web/satellite: patch listing token history issue

This change patches an issue where a user who has not claimed a wallet
would see the error "Can not list token payment history" on the all
projects dashboard.

Issue: https://github.com/storj/storj/issues/6358

Change-Id: I0783fae2c4441be4495b9c8bd82cf6dbe6eea557
This commit is contained in:
Wilfred Asomani 2023-09-29 11:26:53 +00:00 committed by Storj Robot
parent c34202f5e2
commit b069b9b038

View File

@ -273,7 +273,12 @@ export class PaymentsHttpApi implements PaymentsApi {
const path = `${this.ROOT_PATH}/wallet/payments`;
const response = await this.client.get(path);
const json = await response.json();
if (!response.ok) {
if (json.error.includes('wallet does not exist')) {
// wallet does not exist automatically means that there are no payments
return [];
}
throw new APIError({
status: response.status,
message: 'Can not list token payment history',
@ -281,7 +286,6 @@ export class PaymentsHttpApi implements PaymentsApi {
});
}
const json = await response.json();
if (!json) return [];
if (json.payments) {
return json.payments.map(item =>
@ -311,11 +315,15 @@ export class PaymentsHttpApi implements PaymentsApi {
const path = `${this.ROOT_PATH}/wallet/payments-with-confirmations`;
const response = await this.client.get(path);
const json = await response.json();
if (!response.ok) {
if (json.error.includes('wallet does not exist')) {
// wallet does not exist automatically means that there are no payments
return [];
}
throw new Error('Can not list token payment with confirmations');
}
const json = await response.json();
if (json && json.length) {
return json.map(item =>
new PaymentWithConfirmations(