From 47bd790b7b657fedf268dd7109cb0584cca752ac Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 31 Jan 2022 14:56:12 -0300 Subject: fix: #7164 --- packages/taler-wallet-webextension/src/cta/Pay.tsx | 2 +- .../src/popup/TalerActionFound.tsx | 28 ++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'packages/taler-wallet-webextension') diff --git a/packages/taler-wallet-webextension/src/cta/Pay.tsx b/packages/taler-wallet-webextension/src/cta/Pay.tsx index 427a3a715..806338c4d 100644 --- a/packages/taler-wallet-webextension/src/cta/Pay.tsx +++ b/packages/taler-wallet-webextension/src/cta/Pay.tsx @@ -357,7 +357,7 @@ export function PaymentRequestView({ kind="neutral" /> )} - {contractTerms.products && ( + {contractTerms.products && contractTerms.products.length > 0 && ( )} diff --git a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx index 45c4203e8..5de457614 100644 --- a/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx +++ b/packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx @@ -29,6 +29,24 @@ export interface Props { onDismiss: () => void; } +async function getCurrentTab(): Promise { + let queryOptions = { active: true, currentWindow: true }; + const tab = await new Promise((res, rej) => { + chrome.tabs.query(queryOptions, (tabs) => { + res(tabs[0]); + }); + }); + return tab; +} + +async function navigateTo(url?: string) { + if (!url) return; + const tab = await getCurrentTab(); + if (!tab.id) return; + await chrome.tabs.update(tab.id, { url }); + window.close(); +} + export function TalerActionFound({ url, onDismiss }: Props) { const uriType = classifyTalerUri(url); return ( @@ -40,7 +58,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has pay action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open pay page @@ -52,7 +70,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a withdrawal action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open withdraw page @@ -64,7 +82,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a tip action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open tip page @@ -76,7 +94,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a notify reserve action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Notify @@ -88,7 +106,7 @@ export function TalerActionFound({ url, onDismiss }: Props) {

This page has a refund action.

{ - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open refund page -- cgit v1.2.3