diff options
author | Sebastian <sebasjm@gmail.com> | 2022-01-31 14:56:12 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2022-01-31 14:56:12 -0300 |
commit | 47bd790b7b657fedf268dd7109cb0584cca752ac (patch) | |
tree | fb0d7d5857438edee3ef5e6ecc96340b0538204f /packages/taler-wallet-webextension/src | |
parent | c47311b4a70d384d08389959c50faa2a6e7d0e91 (diff) | |
download | wallet-core-47bd790b7b657fedf268dd7109cb0584cca752ac.tar.xz |
fix: #7164
Diffstat (limited to 'packages/taler-wallet-webextension/src')
-rw-r--r-- | packages/taler-wallet-webextension/src/cta/Pay.tsx | 2 | ||||
-rw-r--r-- | packages/taler-wallet-webextension/src/popup/TalerActionFound.tsx | 28 |
2 files changed, 24 insertions, 6 deletions
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 && ( <ProductList products={contractTerms.products} /> )} </section> 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<chrome.tabs.Tab> { + let queryOptions = { active: true, currentWindow: true }; + const tab = await new Promise<chrome.tabs.Tab>((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) { <p>This page has pay action.</p> <ButtonSuccess onClick={() => { - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open pay page @@ -52,7 +70,7 @@ export function TalerActionFound({ url, onDismiss }: Props) { <p>This page has a withdrawal action.</p> <ButtonSuccess onClick={() => { - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open withdraw page @@ -64,7 +82,7 @@ export function TalerActionFound({ url, onDismiss }: Props) { <p>This page has a tip action.</p> <ButtonSuccess onClick={() => { - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open tip page @@ -76,7 +94,7 @@ export function TalerActionFound({ url, onDismiss }: Props) { <p>This page has a notify reserve action.</p> <ButtonSuccess onClick={() => { - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Notify @@ -88,7 +106,7 @@ export function TalerActionFound({ url, onDismiss }: Props) { <p>This page has a refund action.</p> <ButtonSuccess onClick={() => { - chrome.tabs.create({ url: actionForTalerUri(uriType, url) }); + navigateTo(actionForTalerUri(uriType, url)); }} > Open refund page |