mirror of
https://github.com/apotdevin/thunderhub.git
synced 2025-02-23 14:40:27 +01:00
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:
parent
6ea7d97ac8
commit
3ecf7c5646
3 changed files with 12 additions and 8 deletions
|
@ -1,8 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shorten } from '../../../../src/components/generic/helpers';
|
import { shorten } from '../../../../src/components/generic/helpers';
|
||||||
import { Channel } from '../../../../src/graphql/types';
|
|
||||||
import { useGetChannelsWithPeersQuery } from '../../../../src/graphql/queries/__generated__/getChannels.generated';
|
import { useGetChannelsWithPeersQuery } from '../../../../src/graphql/queries/__generated__/getChannels.generated';
|
||||||
import { SelectWithDeco } from '../SelectWithDeco';
|
import { SelectWithDeco } from '../SelectWithDeco';
|
||||||
|
import { Channel } from '../../../graphql/types';
|
||||||
import { ValueProp } from '..';
|
import { ValueProp } from '..';
|
||||||
|
|
||||||
type ChannelSelectProps = {
|
type ChannelSelectProps = {
|
||||||
|
@ -27,13 +27,14 @@ export const ChannelSelect = ({
|
||||||
if (!channel?.partner_public_key) {
|
if (!channel?.partner_public_key) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
let label = shorten(channel.partner_public_key);
|
|
||||||
|
|
||||||
if (channel.partner_node_info.node?.alias) {
|
const label = `${channel.id}
|
||||||
label = `${channel.partner_node_info.node.alias} (${shorten(
|
${
|
||||||
channel.partner_public_key
|
channel?.partner_node_info?.node?.alias
|
||||||
)})`;
|
? ` - ${channel.partner_node_info.node.alias}`
|
||||||
}
|
: ''
|
||||||
|
} -
|
||||||
|
${shorten(channel.partner_public_key)}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
value: channel.partner_public_key,
|
value: channel.partner_public_key,
|
||||||
|
@ -46,7 +47,7 @@ export const ChannelSelect = ({
|
||||||
const finalPeers = value
|
const finalPeers = value
|
||||||
.map(v => {
|
.map(v => {
|
||||||
const peer = channels.find(p => p?.partner_public_key === v.value);
|
const peer = channels.find(p => p?.partner_public_key === v.value);
|
||||||
return peer ? peer : null;
|
return peer?.id ? peer : null;
|
||||||
})
|
})
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
if (finalPeers.length) {
|
if (finalPeers.length) {
|
||||||
|
|
|
@ -77,6 +77,7 @@ export type GetChannelsWithPeersQuery = {
|
||||||
__typename?: 'Query';
|
__typename?: 'Query';
|
||||||
getChannels: Array<{
|
getChannels: Array<{
|
||||||
__typename?: 'Channel';
|
__typename?: 'Channel';
|
||||||
|
id: string;
|
||||||
partner_public_key: string;
|
partner_public_key: string;
|
||||||
partner_node_info: {
|
partner_node_info: {
|
||||||
__typename?: 'Node';
|
__typename?: 'Node';
|
||||||
|
@ -195,6 +196,7 @@ export type GetChannelsQueryResult = Apollo.QueryResult<
|
||||||
export const GetChannelsWithPeersDocument = gql`
|
export const GetChannelsWithPeersDocument = gql`
|
||||||
query GetChannelsWithPeers($active: Boolean) {
|
query GetChannelsWithPeers($active: Boolean) {
|
||||||
getChannels(active: $active) {
|
getChannels(active: $active) {
|
||||||
|
id
|
||||||
partner_public_key
|
partner_public_key
|
||||||
partner_node_info {
|
partner_node_info {
|
||||||
node {
|
node {
|
||||||
|
|
|
@ -62,6 +62,7 @@ export const GET_CHANNELS = gql`
|
||||||
export const GET_CHANNELS_WITH_PEERS = gql`
|
export const GET_CHANNELS_WITH_PEERS = gql`
|
||||||
query GetChannelsWithPeers($active: Boolean) {
|
query GetChannelsWithPeers($active: Boolean) {
|
||||||
getChannels(active: $active) {
|
getChannels(active: $active) {
|
||||||
|
id
|
||||||
partner_public_key
|
partner_public_key
|
||||||
partner_node_info {
|
partner_node_info {
|
||||||
node {
|
node {
|
||||||
|
|
Loading…
Add table
Reference in a new issue