From 279000eeb327a5d3064eb352bdd1dbf6211c3bc8 Mon Sep 17 00:00:00 2001 From: Justin Starry Date: Fri, 14 Aug 2020 22:58:38 +0800 Subject: [PATCH] Explorer: Remove flatMap usage due to browser incompatibility (#11632) --- explorer/src/App.tsx | 24 ++++++++++++------- explorer/src/providers/transactions/index.tsx | 2 -- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/explorer/src/App.tsx b/explorer/src/App.tsx index ebbfde1fe7..f40ec15baf 100644 --- a/explorer/src/App.tsx +++ b/explorer/src/App.tsx @@ -2,7 +2,6 @@ import React from "react"; import { Switch, Route, Redirect } from "react-router-dom"; import { ClusterModal } from "components/ClusterModal"; -import { TX_ALIASES } from "providers/transactions"; import { MessageBanner } from "components/MessageBanner"; import { Navbar } from "components/Navbar"; import { ClusterStatusBanner } from "components/ClusterStatusButton"; @@ -13,7 +12,8 @@ import { ClusterStatsPage } from "pages/ClusterStatsPage"; import { SupplyPage } from "pages/SupplyPage"; import { TransactionDetailsPage } from "pages/TransactionDetailsPage"; -const ACCOUNT_ALIASES = ["account", "accounts", "addresses"]; +const ADDRESS_ALIASES = ["account", "accounts", "addresses"]; +const TX_ALIASES = ["txs", "txn", "txns", "transaction", "transactions"]; function App() { return ( @@ -30,19 +30,25 @@ function App() { [tx, tx + "s"]).map( - (tx) => `/${tx}/:signature` - )} + path={TX_ALIASES.map((tx) => `/${tx}/:signature`)} + render={({ match, location }) => { + let pathname = `/tx/${match.params.signature}`; + return ; + }} + /> + ( )} /> [ - `/${account}/:address`, - `/${account}/:address/:tab`, - ])} + path={[ + ...ADDRESS_ALIASES.map((path) => `/${path}/:address`), + ...ADDRESS_ALIASES.map((path) => `/${path}/:address/:tab`), + ]} render={({ match, location }) => { let pathname = `/address/${match.params.address}`; if (match.params.tab) { diff --git a/explorer/src/providers/transactions/index.tsx b/explorer/src/providers/transactions/index.tsx index 5f65974f31..7782e2772b 100644 --- a/explorer/src/providers/transactions/index.tsx +++ b/explorer/src/providers/transactions/index.tsx @@ -28,8 +28,6 @@ export interface TransactionStatus { info: TransactionStatusInfo | null; } -export const TX_ALIASES = ["tx", "txn", "transaction"]; - type State = Cache.State; type Dispatch = Cache.Dispatch;