Skip to content

Commit

Permalink
Only show network alert once
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpetretta committed Aug 23, 2022
1 parent 7652c68 commit 8d8d7da
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion react/components/AppProvider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const AppProvider = ({ children }) => {
const [confetti, setConfetti] = useState(false)
useAccount({
onSuccess(data) {
if (data) {
if (data && !address) {
setAddress(data.address)
}
},
Expand Down
2 changes: 1 addition & 1 deletion react/components/Editor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function Editor() {
const [price, setPrice] = useState(0)
useAccount({
onSuccess(data) {
if (data) {
if (data && !address) {
setAddress(data.address)
}
},
Expand Down
25 changes: 14 additions & 11 deletions react/components/Layout.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Head from "next/head"
import { useRouter } from "next/router"
import { useState } from "react"
import toast, { Toaster } from "react-hot-toast"
import { toast, Toaster } from "react-hot-toast"
import { useAccount, useContractRead } from "wagmi"
import { contractABI, contractAddress } from "../lib/contract.js"
import Nav from "./Nav"
Expand Down Expand Up @@ -30,16 +30,19 @@ export default function Layout(props) {
console.debug("Found authorized account: ", data.address)

// Alert user to which networks are available
toast("Twitt3r only supports Goerli & Ropsten testnets!", {
duration: 8000,
position: "top-center",
style: {
color: "#FFFFFF",
backgroundColor: "#DC2626",
minWidth: "440px",
},
icon: "⚠️",
})
if (!sessionStorage.getItem("seenNetworkAlert")) {
toast("Twitt3r only supports Goerli & Ropsten testnets!", {
duration: 8000,
position: "top-center",
style: {
color: "#FFFFFF",
backgroundColor: "#DC2626",
minWidth: "440px",
},
icon: "⚠️",
})
sessionStorage.setItem("seenNetworkAlert", true)
}

// Check if this is the owner's wallet
if (
Expand Down
2 changes: 1 addition & 1 deletion react/components/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Nav() {
const [address, setAddress] = useState("")
useAccount({
onSuccess(data) {
if (data) {
if (data && !address) {
setAddress(data.address)
}
},
Expand Down
2 changes: 1 addition & 1 deletion react/components/Tweet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default function Tweet(props) {
const { tweets } = useTweets()
useAccount({
onSuccess(data) {
if (data) {
if (data && !address) {
setAddress(data.address)
}
},
Expand Down
2 changes: 1 addition & 1 deletion react/pages/404.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function Error404() {
const [address, setAddress] = useState()
useAccount({
onSuccess(data) {
if (data) {
if (data && !address) {
setAddress(data.address)
}
},
Expand Down

0 comments on commit 8d8d7da

Please sign in to comment.