fix localStorage build
This commit is contained in:
@@ -16,7 +16,7 @@ import axios from "axios";
|
|||||||
const CLOSED_KEY = "new-ui-notif-closed";
|
const CLOSED_KEY = "new-ui-notif-closed";
|
||||||
|
|
||||||
function NotificationBar() {
|
function NotificationBar() {
|
||||||
const isClosed = localStorage.getItem(CLOSED_KEY);
|
// const isClosed = localStorage.getItem(CLOSED_KEY);
|
||||||
|
|
||||||
// const [isVisible, setIsVisible] = useState(
|
// const [isVisible, setIsVisible] = useState(
|
||||||
// isClosed === "true" ? false : true
|
// isClosed === "true" ? false : true
|
||||||
|
|||||||
@@ -66,17 +66,23 @@ const allNetworksOptions = [
|
|||||||
|
|
||||||
function Body() {
|
function Body() {
|
||||||
let addressFromURL: string | null = null;
|
let addressFromURL: string | null = null;
|
||||||
|
let showAddressCache: string | null = null;
|
||||||
let urlFromURL: string | null = null;
|
let urlFromURL: string | null = null;
|
||||||
let urlFromCache: string | null = null;
|
let urlFromCache: string | null = null;
|
||||||
let chainFromURL: string | null = null;
|
let chainFromURL: string | null = null;
|
||||||
|
let tenderlyForkIdCache: string | null = null;
|
||||||
|
|
||||||
if (typeof window !== "undefined") {
|
if (typeof window !== "undefined") {
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
addressFromURL = urlParams.get("address");
|
addressFromURL = urlParams.get("address");
|
||||||
urlFromURL = urlParams.get("url");
|
urlFromURL = urlParams.get("url");
|
||||||
urlFromCache = localStorage.getItem("appUrl");
|
|
||||||
chainFromURL = urlParams.get("chain");
|
chainFromURL = urlParams.get("chain");
|
||||||
}
|
}
|
||||||
|
if (typeof localStorage !== "undefined") {
|
||||||
|
showAddressCache = localStorage.getItem("showAddress");
|
||||||
|
urlFromCache = localStorage.getItem("appUrl");
|
||||||
|
tenderlyForkIdCache = localStorage.getItem("tenderlyForkId");
|
||||||
|
}
|
||||||
let networkIdViaURL = 1;
|
let networkIdViaURL = 1;
|
||||||
if (chainFromURL) {
|
if (chainFromURL) {
|
||||||
for (let i = 0; i < allNetworksOptions.length; i++) {
|
for (let i = 0; i < allNetworksOptions.length; i++) {
|
||||||
@@ -103,10 +109,10 @@ function Body() {
|
|||||||
|
|
||||||
const [provider, setProvider] = useState<ethers.providers.JsonRpcProvider>();
|
const [provider, setProvider] = useState<ethers.providers.JsonRpcProvider>();
|
||||||
const [showAddress, setShowAddress] = useState(
|
const [showAddress, setShowAddress] = useState(
|
||||||
addressFromURL ?? localStorage.getItem("showAddress") ?? ""
|
addressFromURL ?? showAddressCache ?? ""
|
||||||
); // gets displayed in input. ENS name remains as it is
|
); // gets displayed in input. ENS name remains as it is
|
||||||
const [address, setAddress] = useState(
|
const [address, setAddress] = useState(
|
||||||
addressFromURL ?? localStorage.getItem("showAddress") ?? ""
|
addressFromURL ?? showAddressCache ?? ""
|
||||||
); // internal resolved address
|
); // internal resolved address
|
||||||
const [isAddressValid, setIsAddressValid] = useState(true);
|
const [isAddressValid, setIsAddressValid] = useState(true);
|
||||||
const [uri, setUri] = useState("");
|
const [uri, setUri] = useState("");
|
||||||
@@ -133,7 +139,7 @@ function Body() {
|
|||||||
const [iframeKey, setIframeKey] = useState(0); // hacky way to reload iframe when key changes
|
const [iframeKey, setIframeKey] = useState(0); // hacky way to reload iframe when key changes
|
||||||
|
|
||||||
const [tenderlyForkId, setTenderlyForkId] = useState(
|
const [tenderlyForkId, setTenderlyForkId] = useState(
|
||||||
localStorage.getItem("tenderlyForkId") ?? ""
|
tenderlyForkIdCache ?? ""
|
||||||
);
|
);
|
||||||
const [sendTxnData, setSendTxnData] = useState<TxnDataType[]>([]);
|
const [sendTxnData, setSendTxnData] = useState<TxnDataType[]>([]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user