Skip to content

Commit

Permalink
refactor: dont show tabs at all if rsk log endpoint isnt available
Browse files Browse the repository at this point in the history
  • Loading branch information
jackstar12 committed Jan 8, 2025
1 parent c7bb7d3 commit 4b43d3c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
1 change: 0 additions & 1 deletion src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ const dict = {
"Scanning for refundable swaps in your Rootstock Wallet...",
connected_wallet_no_swaps:
"The connected Rootstock Wallet does NOT contain any refundable swaps.",
rsk_log_endpoint_not_available: "Log endpoint not available",
refund_external_swap: "Refund External Swap",
history_no_swaps: "Looks like you didn't do any swaps yet.",
refund_address_header:
Expand Down
44 changes: 25 additions & 19 deletions src/pages/RefundExternal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,7 @@ const RefundRsk = () => {
});

return (
<Show
when={import.meta.env.VITE_RSK_LOG_SCAN_ENDPOINT !== undefined}
fallback={<p>{t("rsk_log_endpoint_not_available")}</p>}>
<>
<Switch fallback={<p>{t("refund_external_explainer_rsk")}</p>}>
<Match when={logRefundableSwaps().length > 0}>
<SwapListLogs swaps={logRefundableSwaps} />
Expand All @@ -201,7 +199,7 @@ const RefundRsk = () => {
</Switch>
<hr />
<ConnectWallet addressOverride={refundScanProgress} />
</Show>
</>
);
};

Expand All @@ -216,6 +214,12 @@ const RefundExternal = () => {

const selected = () => params.type ?? tabBtc.value;

const rskAvailable =
import.meta.env.VITE_RSK_LOG_SCAN_ENDPOINT !== undefined;
if (!rskAvailable) {
log.warn("RSK log scan endpoint not available");
}

return (
<Show when={wasmSupported()} fallback={<ErrorWasm />}>
<div id="refund">
Expand All @@ -224,21 +228,23 @@ const RefundExternal = () => {
<SettingsCog />
<h2>{t("refund_external_swap")}</h2>
</header>
<div class="tabs">
<For each={[tabBtc, tabRsk]}>
{(tab) => (
<div
class={`tab ${selected() === tab.value ? "active" : ""}`}
onClick={() =>
navigate(
`/refund/external/${tab.value}`,
)
}>
{tab.name}
</div>
)}
</For>
</div>
<Show when={rskAvailable}>
<div class="tabs">
<For each={[tabBtc, tabRsk]}>
{(tab) => (
<div
class={`tab ${selected() === tab.value ? "active" : ""}`}
onClick={() =>
navigate(
`/refund/external/${tab.value}`,
)
}>
{tab.name}
</div>
)}
</For>
</div>
</Show>
<Show when={selected() === tabBtc.value}>
<RefundBtcLike />
</Show>
Expand Down

0 comments on commit 4b43d3c

Please sign in to comment.