Remove all but cluster url param when navigating
This commit is contained in:
parent
d5421266f5
commit
03f7d28aff
|
@ -12,6 +12,7 @@ import { ACCOUNT_ALIASES, ACCOUNT_ALIASES_PLURAL } from "./providers/accounts";
|
|||
import TabbedPage from "components/TabbedPage";
|
||||
import TopAccountsCard from "components/TopAccountsCard";
|
||||
import SupplyCard from "components/SupplyCard";
|
||||
import { pickCluster } from "utils/url";
|
||||
|
||||
function App() {
|
||||
return (
|
||||
|
@ -22,7 +23,9 @@ function App() {
|
|||
<div className="container">
|
||||
<div className="row align-items-end">
|
||||
<div className="col">
|
||||
<Link to={location => ({ ...location, pathname: "/" })}>
|
||||
<Link
|
||||
to={location => ({ ...pickCluster(location), pathname: "/" })}
|
||||
>
|
||||
<img src={Logo} width="250" alt="Solana Explorer" />
|
||||
</Link>
|
||||
</div>
|
||||
|
|
|
@ -2,6 +2,7 @@ import React from "react";
|
|||
import { Link } from "react-router-dom";
|
||||
import { useClusterModal } from "providers/cluster";
|
||||
import ClusterStatusButton from "components/ClusterStatusButton";
|
||||
import { pickCluster } from "utils/url";
|
||||
|
||||
export type Tab = "Transactions" | "Accounts" | "Supply";
|
||||
|
||||
|
@ -64,7 +65,7 @@ function NavLink({
|
|||
|
||||
return (
|
||||
<Link
|
||||
to={location => ({ ...location, pathname: href })}
|
||||
to={location => ({ ...pickCluster(location), pathname: href })}
|
||||
className={classes}
|
||||
>
|
||||
{tab}
|
||||
|
|
|
@ -1,9 +1,26 @@
|
|||
import { useLocation } from "react-router-dom";
|
||||
import { Location } from "history";
|
||||
|
||||
export function useQuery() {
|
||||
return new URLSearchParams(useLocation().search);
|
||||
}
|
||||
|
||||
export function pickCluster(location: Location): Location {
|
||||
const cluster = new URLSearchParams(location.search).get("cluster");
|
||||
|
||||
let search = "";
|
||||
if (cluster) {
|
||||
const params = new URLSearchParams();
|
||||
params.set("cluster", cluster);
|
||||
search = params.toString();
|
||||
}
|
||||
|
||||
return {
|
||||
...location,
|
||||
search
|
||||
};
|
||||
}
|
||||
|
||||
export function findGetParameter(parameterName: string): string | null {
|
||||
let result = null,
|
||||
tmp = [];
|
||||
|
|
Loading…
Reference in New Issue