From 44cf47b86d4da0b3f6df5f70080b98e22ec0fbfd Mon Sep 17 00:00:00 2001 From: nymkappa Date: Wed, 17 Aug 2022 10:23:14 +0200 Subject: [PATCH] Fix node channel list pagination --- backend/src/api/explorer/channels.api.ts | 14 ++++++++------ .../channels-list/channels-list.component.html | 6 +++++- .../channels-list/channels-list.component.ts | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/backend/src/api/explorer/channels.api.ts b/backend/src/api/explorer/channels.api.ts index 67003be57..d3de56796 100644 --- a/backend/src/api/explorer/channels.api.ts +++ b/backend/src/api/explorer/channels.api.ts @@ -218,23 +218,25 @@ class ChannelsApi { // Channels originating from node let query = ` - SELECT node2.alias, node2.public_key, channels.status, channels.node1_fee_rate, + SELECT COALESCE(node2.alias, SUBSTRING(node2_public_key, 0, 20)) AS alias, COALESCE(node2.public_key, node2_public_key) AS public_key, + channels.status, channels.node1_fee_rate, channels.capacity, channels.short_id, channels.id FROM channels - JOIN nodes AS node2 ON node2.public_key = channels.node2_public_key + LEFT JOIN nodes AS node2 ON node2.public_key = channels.node2_public_key WHERE node1_public_key = ? AND channels.status ${channelStatusFilter} `; - const [channelsFromNode]: any = await DB.query(query, [public_key, index, length]); + const [channelsFromNode]: any = await DB.query(query, [public_key]); // Channels incoming to node query = ` - SELECT node1.alias, node1.public_key, channels.status, channels.node2_fee_rate, + SELECT COALESCE(node1.alias, SUBSTRING(node1_public_key, 0, 20)) AS alias, COALESCE(node1.public_key, node1_public_key) AS public_key, + channels.status, channels.node2_fee_rate, channels.capacity, channels.short_id, channels.id FROM channels - JOIN nodes AS node1 ON node1.public_key = channels.node1_public_key + LEFT JOIN nodes AS node1 ON node1.public_key = channels.node1_public_key WHERE node2_public_key = ? AND channels.status ${channelStatusFilter} `; - const [channelsToNode]: any = await DB.query(query, [public_key, index, length]); + const [channelsToNode]: any = await DB.query(query, [public_key]); let allChannels = channelsFromNode.concat(channelsToNode); allChannels.sort((a, b) => { diff --git a/frontend/src/app/lightning/channels-list/channels-list.component.html b/frontend/src/app/lightning/channels-list/channels-list.component.html index b95cddf8d..780c0fdf6 100644 --- a/frontend/src/app/lightning/channels-list/channels-list.component.html +++ b/frontend/src/app/lightning/channels-list/channels-list.component.html @@ -19,7 +19,11 @@ - + +
No channels to display
diff --git a/frontend/src/app/lightning/channels-list/channels-list.component.ts b/frontend/src/app/lightning/channels-list/channels-list.component.ts index 6172a4a99..6a0732522 100644 --- a/frontend/src/app/lightning/channels-list/channels-list.component.ts +++ b/frontend/src/app/lightning/channels-list/channels-list.component.ts @@ -47,7 +47,7 @@ export class ChannelsListComponent implements OnInit, OnChanges { } ngOnChanges(): void { - this.channelStatusForm.get('status').setValue(this.defaultStatus, { emitEvent: false }); + this.channelStatusForm.get('status').setValue(this.defaultStatus, { emitEvent: true }); this.channelsPage$.next(1); this.channels$ = merge( @@ -70,7 +70,7 @@ export class ChannelsListComponent implements OnInit, OnChanges { map((response) => { return { channels: response.body, - totalItems: parseInt(response.headers.get('x-total-count'), 10) + 1 + totalItems: parseInt(response.headers.get('x-total-count'), 10) }; }), );