@@ -29,7 +29,7 @@ function App({ Component, pageProps }) {
29
29
const isSupportCurrentNetwork = SUPPORT_NETWORKS . includes ( chainId )
30
30
const [ backendVersion , setBackendVersion ] = useState ( "err" )
31
31
32
- const [ , actions ] = useAsync ( async ( ) => {
32
+ const [ autoLoginState , actions ] = useAsync ( async ( ) => {
33
33
if ( ! sigInLocal || ! accountInLocal ) return
34
34
const cachedProvider = await createProvider ( undefined , ( id ) => dispatch ( { type : "SET_CHAIN_ID" , chainId : id } ) )
35
35
if ( ! cachedProvider ) return
@@ -117,6 +117,7 @@ function App({ Component, pageProps }) {
117
117
118
118
119
119
const renderActionButton = ( ) => {
120
+ if ( ! [ 'success' , 'error' ] . includes ( autoLoginState . status ) ) return null
120
121
if ( ! sigInLocal || ! accountInLocal ) {
121
122
return (
122
123
< button
@@ -159,61 +160,61 @@ function App({ Component, pageProps }) {
159
160
</ div >
160
161
</ div >
161
162
162
- < div
163
- style = { { display : account && isSupportCurrentNetwork ? "block" : "none" } }
164
- className = "absolute top-8 right-8 text-right fixed "
165
- >
166
- < Menu as = "div" className = "relative inline-block text-left" >
167
- < div >
168
- < Menu . Button
169
- className = "inline-flex justify-center w-full px-2 py-2 font-medium text-white bg-black rounded-md bg-opacity-20 hover:bg-opacity-30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75" >
170
- < ChevronDownIcon
171
- className = "w-5 h-5 text-violet-200 hover:text-violet-100 "
172
- aria-hidden = "true"
173
- / >
174
- </ Menu . Button >
175
- </ div >
176
- < Transition
177
- as = { Fragment }
178
- enter = "transition ease-out duration-100 "
179
- enterFrom = "transform opacity-0 scale-95 "
180
- enterTo = "transform opacity-100 scale-100 "
181
- leave = "transition ease-in duration-75 "
182
- leaveFrom = "transform opacity-100 scale-100 "
183
- leaveTo = "transform opacity-0 scale-95"
184
- >
185
- < Menu . Items
186
- className = "absolute right-0 w-56 mt-2 origin-top-right bg-white divide-y divide-gray-100 rounded-md shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none " >
187
- < div className = "px-1 py-1" >
188
- < Menu . Item >
189
- { ( { active } ) => (
190
- < button
191
- className = { ` ${
192
- active ? "bg-blue-500 text-gray-300" : " text-gray-900"
193
- } group flex rounded-md items-center w-full px-2 py-2 text-sm` }
194
- >
195
- id: { getBrief ( account ) }
196
- </ button >
197
- ) }
198
- </ Menu . Item >
199
-
200
- < Menu . Item >
201
- { ( { active } ) => (
202
- < button
203
- onClick = { disconnectWallet }
204
- className = { ` ${
205
- active ? "bg-blue-500 text-gray-300" : " text-gray-900"
206
- } group flex rounded-md items-center w-full px-2 py-2 text-sm` }
207
- >
208
- Logout
209
- </ button >
210
- ) }
211
- </ Menu . Item >
212
- </ div >
213
- </ Menu . Items >
214
- </ Transition >
215
- </ Menu >
216
- </ div >
163
+ {
164
+ sigInLocal && account && isSupportCurrentNetwork &&
165
+ < div className = "absolute top-8 right-8 text-right fixed" >
166
+ < Menu as = "div" className = "relative inline-block text-left" >
167
+ < div >
168
+ < Menu . Button
169
+ className = "inline-flex justify-center w-full px-2 py-2 font-medium text-white bg-black rounded-md bg-opacity-20 hover:bg-opacity-30 focus:outline-none focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75" >
170
+ < ChevronDownIcon
171
+ className = "w-5 h-5 text-violet-200 hover:text-violet-100"
172
+ aria-hidden = "true "
173
+ />
174
+ </ Menu . Button >
175
+ </ div >
176
+ < Transition
177
+ as = { Fragment }
178
+ enter = "transition ease-out duration-100"
179
+ enterFrom = "transform opacity-0 scale-95 "
180
+ enterTo = "transform opacity-100 scale-100 "
181
+ leave = "transition ease-in duration-75 "
182
+ leaveFrom = "transform opacity-100 scale-100 "
183
+ leaveTo = "transform opacity-0 scale-95 "
184
+ >
185
+ < Menu . Items
186
+ className = "absolute right-0 w-56 mt-2 origin-top-right bg-white divide-y divide-gray-100 rounded-md shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none" >
187
+ < div className = "px-1 py-1 " >
188
+ < Menu . Item >
189
+ { ( { active } ) => (
190
+ < button
191
+ className = { ` ${
192
+ active ? "bg-blue-500 text-gray-300" : "text-gray-900"
193
+ } group flex rounded-md items-center w-full px-2 py-2 text-sm` }
194
+ >
195
+ id: { getBrief ( account ) }
196
+ </ button >
197
+ ) }
198
+ </ Menu . Item >
199
+
200
+ < Menu . Item >
201
+ { ( { active } ) => (
202
+ < button
203
+ onClick = { disconnectWallet }
204
+ className = { ` ${
205
+ active ? "bg-blue-500 text-gray-300" : "text-gray-900"
206
+ } group flex rounded-md items-center w-full px-2 py-2 text-sm` }
207
+ >
208
+ Logout
209
+ </ button >
210
+ ) }
211
+ </ Menu . Item >
212
+ </ div >
213
+ </ Menu . Items >
214
+ </ Transition >
215
+ </ Menu >
216
+ </ div >
217
+ }
217
218
</ nav >
218
219
< Web3Context . Provider value = { web3ContextValue } >
219
220
< Component { ...pageProps } />
0 commit comments