Explorer: Remove flatMap usage due to browser incompatibility (#11632)
This commit is contained in:
@ -2,7 +2,6 @@ import React from "react";
|
|||||||
import { Switch, Route, Redirect } from "react-router-dom";
|
import { Switch, Route, Redirect } from "react-router-dom";
|
||||||
|
|
||||||
import { ClusterModal } from "components/ClusterModal";
|
import { ClusterModal } from "components/ClusterModal";
|
||||||
import { TX_ALIASES } from "providers/transactions";
|
|
||||||
import { MessageBanner } from "components/MessageBanner";
|
import { MessageBanner } from "components/MessageBanner";
|
||||||
import { Navbar } from "components/Navbar";
|
import { Navbar } from "components/Navbar";
|
||||||
import { ClusterStatusBanner } from "components/ClusterStatusButton";
|
import { ClusterStatusBanner } from "components/ClusterStatusButton";
|
||||||
@ -13,7 +12,8 @@ import { ClusterStatsPage } from "pages/ClusterStatsPage";
|
|||||||
import { SupplyPage } from "pages/SupplyPage";
|
import { SupplyPage } from "pages/SupplyPage";
|
||||||
import { TransactionDetailsPage } from "pages/TransactionDetailsPage";
|
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() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
@ -30,19 +30,25 @@ function App() {
|
|||||||
</Route>
|
</Route>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path={TX_ALIASES.flatMap((tx) => [tx, tx + "s"]).map(
|
path={TX_ALIASES.map((tx) => `/${tx}/:signature`)}
|
||||||
(tx) => `/${tx}/:signature`
|
render={({ match, location }) => {
|
||||||
)}
|
let pathname = `/tx/${match.params.signature}`;
|
||||||
|
return <Redirect to={{ ...location, pathname }} />;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
exact
|
||||||
|
path={"/tx/:signature"}
|
||||||
render={({ match }) => (
|
render={({ match }) => (
|
||||||
<TransactionDetailsPage signature={match.params.signature} />
|
<TransactionDetailsPage signature={match.params.signature} />
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<Route
|
<Route
|
||||||
exact
|
exact
|
||||||
path={ACCOUNT_ALIASES.flatMap((account) => [
|
path={[
|
||||||
`/${account}/:address`,
|
...ADDRESS_ALIASES.map((path) => `/${path}/:address`),
|
||||||
`/${account}/:address/:tab`,
|
...ADDRESS_ALIASES.map((path) => `/${path}/:address/:tab`),
|
||||||
])}
|
]}
|
||||||
render={({ match, location }) => {
|
render={({ match, location }) => {
|
||||||
let pathname = `/address/${match.params.address}`;
|
let pathname = `/address/${match.params.address}`;
|
||||||
if (match.params.tab) {
|
if (match.params.tab) {
|
||||||
|
@ -28,8 +28,6 @@ export interface TransactionStatus {
|
|||||||
info: TransactionStatusInfo | null;
|
info: TransactionStatusInfo | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const TX_ALIASES = ["tx", "txn", "transaction"];
|
|
||||||
|
|
||||||
type State = Cache.State<TransactionStatus>;
|
type State = Cache.State<TransactionStatus>;
|
||||||
type Dispatch = Cache.Dispatch<TransactionStatus>;
|
type Dispatch = Cache.Dispatch<TransactionStatus>;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user