Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,45 @@ export class ClipboardDetailsComponent extends BaseClipboardComponent {

onVerify(): void {
(async () => {
var result = await this.queryPayments(this.clipboardItem?.value ?? "")
const value = this.clipboardItem?.value;

if (!value) {
return;
}

const result = await this.queryPayments(value);

if (result) {
this.clipboardItemChange.emit(result as PaymentClipboardItem);
} else {
this.toastrService.error(`Payment not found.`);
return;
}

this.showPaymentNotFoundToast(value);
})();
}

private showPaymentNotFoundToast(value: string): void {
this.toastrService.error(
`For more info on why this payment was not found click <a href="#" class="payment-link">here</a>.`,
'Payment not found',
{
enableHtml: true,
tapToDismiss: false
}
);

setTimeout(() => {
const link = document.querySelector('.toast-error .payment-link');
if (link) {
link.addEventListener('click', (e) => {
e.preventDefault();
const url = `${this.serverService.baseUrl}/v2/verify/${encodeURIComponent(value)}`;
window.electron.openUrl(url);
});
}
}, 100);
}

private async queryPayments(value: string): Promise<PaymentClipboardItem | null> {
try {
const paymentClipboardItems = await lastValueFrom(this.serverService.getPayment(value));
Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/services/server.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class ServerService {
return this.httpClient.get<PaymentClipboardItem[]>(`${this.baseUrl}/v2/payments/${encodeURIComponent(value)}`);
}

private get baseUrl(): string {
get baseUrl(): string {
if (environment.production == false) {
return 'http://localhost:3000';
}
Expand Down
Loading