feat: add channel id to channel select dropdown (#531)

* feat: add channel id to channel select dropdown

* fix: removed unnecessary complication in implementation and fix path issue

* fix: remove unneeded variables on objects
This commit is contained in:
AmbossKeegan 2023-05-26 05:53:27 -03:00 committed by GitHub
parent 6ea7d97ac8
commit 3ecf7c5646
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 8 deletions

View file

@ -1,8 +1,8 @@
import React from 'react';
import { shorten } from '../../../../src/components/generic/helpers';
import { Channel } from '../../../../src/graphql/types';
import { useGetChannelsWithPeersQuery } from '../../../../src/graphql/queries/__generated__/getChannels.generated';
import { SelectWithDeco } from '../SelectWithDeco';
import { Channel } from '../../../graphql/types';
import { ValueProp } from '..';
type ChannelSelectProps = {
@ -27,13 +27,14 @@ export const ChannelSelect = ({
if (!channel?.partner_public_key) {
return null;
}
let label = shorten(channel.partner_public_key);
if (channel.partner_node_info.node?.alias) {
label = `${channel.partner_node_info.node.alias} (${shorten(
channel.partner_public_key
)})`;
}
const label = `${channel.id}
${
channel?.partner_node_info?.node?.alias
? ` - ${channel.partner_node_info.node.alias}`
: ''
} -
${shorten(channel.partner_public_key)}`;
return {
value: channel.partner_public_key,
@ -46,7 +47,7 @@ export const ChannelSelect = ({
const finalPeers = value
.map(v => {
const peer = channels.find(p => p?.partner_public_key === v.value);
return peer ? peer : null;
return peer?.id ? peer : null;
})
.filter(Boolean);
if (finalPeers.length) {

View file

@ -77,6 +77,7 @@ export type GetChannelsWithPeersQuery = {
__typename?: 'Query';
getChannels: Array<{
__typename?: 'Channel';
id: string;
partner_public_key: string;
partner_node_info: {
__typename?: 'Node';
@ -195,6 +196,7 @@ export type GetChannelsQueryResult = Apollo.QueryResult<
export const GetChannelsWithPeersDocument = gql`
query GetChannelsWithPeers($active: Boolean) {
getChannels(active: $active) {
id
partner_public_key
partner_node_info {
node {

View file

@ -62,6 +62,7 @@ export const GET_CHANNELS = gql`
export const GET_CHANNELS_WITH_PEERS = gql`
query GetChannelsWithPeers($active: Boolean) {
getChannels(active: $active) {
id
partner_public_key
partner_node_info {
node {