Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add channel id to channel select dropdown #531

Merged
merged 4 commits into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ type NodeSocialInfo {

type NodeType {
alias: String!
id: String
public_key: String!
}

Expand Down
13 changes: 7 additions & 6 deletions src/client/src/components/select/specific/ChannelSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.partner_node_info.node?.id}
${
channel?.partner_node_info?.node?.alias
? ` - ${channel.partner_node_info.node.alias}`
: ''
} -
${shorten(channel.partner_public_key)}`;

return {
value: channel.partner_public_key,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/client/src/graphql/queries/getChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export const GET_CHANNELS_WITH_PEERS = gql`
partner_node_info {
node {
alias
id
AmbossKeegan marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/client/src/graphql/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -788,6 +788,7 @@ export type NodeSocialInfo = {
export type NodeType = {
__typename?: 'NodeType';
alias: Scalars['String'];
id?: Maybe<Scalars['String']>;
public_key: Scalars['String'];
};

Expand Down
5 changes: 4 additions & 1 deletion src/server/modules/api/channels/channels.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ export class ChannelsResolver {
...channel,
partner_fee_info: { localKey: public_key },
channel_age: getChannelAge(channel.id, current_block_height),
partner_node_info: { publicKey: channel.partner_public_key },
partner_node_info: {
publicKey: channel.partner_public_key,
id: channel.id,
},
}));
}

Expand Down
12 changes: 8 additions & 4 deletions src/server/modules/api/node/node.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class NodeFieldResolver {
@ResolveField()
async node(
@Parent()
{ publicKey }: { publicKey: string },
{ publicKey, id: channelId }: { publicKey: string; id: string },
@CurrentUser() { id }: UserId
) {
if (!publicKey) {
Expand All @@ -155,11 +155,15 @@ export class NodeFieldResolver {
getNodeAlias(pubkey: $pubkey)
}
`,
{ pubkey: publicKey }
{ pubkey: publicKey, id: channelId || null }
);

if (data?.getNodeAlias && !error) {
return { alias: data.getNodeAlias, public_key: publicKey };
return {
alias: data.getNodeAlias,
public_key: publicKey,
id: channelId || null,
};
}

const [info, nodeError] = await toWithError(
Expand All @@ -168,6 +172,6 @@ export class NodeFieldResolver {

if (nodeError || !info) return null;

return { ...info, public_key: publicKey };
return { ...info, public_key: publicKey, id: channelId || null };
}
}
2 changes: 2 additions & 0 deletions src/server/modules/api/node/node.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export class NodeType {
alias: string;
@Field()
public_key: string;
@Field({ nullable: true })
id: string;
AmbossKeegan marked this conversation as resolved.
Show resolved Hide resolved
}

@ObjectType()
Expand Down