Search fix. Channel update.

This commit is contained in:
softsimon 2022-05-26 18:23:57 +04:00
parent b87308e14f
commit f0ad38dec6
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
5 changed files with 14 additions and 6 deletions

View File

@ -111,7 +111,7 @@ export class SearchFormComponent implements OnInit {
selectedResult(result: any) {
if (typeof result === 'string') {
this.navigate('/address/', result);
this.search();
} else if (result.alias) {
this.navigate('/lightning/node/', result.public_key);
} else if (result.short_id) {

View File

@ -36,7 +36,11 @@ export class SearchResultsComponent implements OnChanges {
break;
case 'Enter':
event.preventDefault();
this.selectedResult.emit(this.resultsFlattened[this.activeIdx]);
if (this.resultsFlattened[this.activeIdx]) {
this.selectedResult.emit(this.resultsFlattened[this.activeIdx]);
} else {
this.selectedResult.emit(this.searchTerm);
}
this.results = null;
break;
}

View File

@ -1,6 +1,6 @@
<div class="mb-2 box-top">
<div class="box-left">
<h2 class="mb-0">{{ channel.alias || '?' }}</h2>
<h3 class="mb-0">{{ channel.alias || '?' }}</h3>
<a [routerLink]="['/lightning/node' | relativeUrl, channel.public_key]" >
{{ channel.public_key | shortenString : 12 }}
</a>

View File

@ -7,10 +7,14 @@ import { WebsocketService } from 'src/app/services/websocket.service';
styleUrls: ['./lightning-wrapper.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LightningWrapperComponent {
export class LightningWrapperComponent implements OnInit {
constructor(
private websocketService: WebsocketService,
) { }
ngOnInit() {
this.websocketService.want(['blocks']);
}
}

View File

@ -47,10 +47,10 @@ class ChannelsApi {
}
}
public async $getChannel(shortId: string): Promise<any> {
public async $getChannel(id: string): Promise<any> {
try {
const query = `SELECT n1.alias AS alias_left, n2.alias AS alias_right, channels.*, ns1.channels AS channels_left, ns1.capacity AS capacity_left, ns2.channels AS channels_right, ns2.capacity AS capacity_right FROM channels LEFT JOIN nodes AS n1 ON n1.public_key = channels.node1_public_key LEFT JOIN nodes AS n2 ON n2.public_key = channels.node2_public_key LEFT JOIN node_stats AS ns1 ON ns1.public_key = channels.node1_public_key LEFT JOIN node_stats AS ns2 ON ns2.public_key = channels.node2_public_key WHERE (ns1.id = (SELECT MAX(id) FROM node_stats WHERE public_key = channels.node1_public_key) AND ns2.id = (SELECT MAX(id) FROM node_stats WHERE public_key = channels.node2_public_key)) AND channels.id = ?`;
const [rows]: any = await DB.query(query, [shortId]);
const [rows]: any = await DB.query(query, [id]);
if (rows[0]) {
return this.convertChannel(rows[0]);
}