@@ -5,12 +5,40 @@ import RepoLayout from "@/app/repo/layout.tsx";
5
5
import ExploreLayout from "@/app/explore/layout.tsx" ;
6
6
import MarketLayout from "@/app/market/layout.tsx" ;
7
7
import CommunityLayout from "@/app/community/layout.tsx" ;
8
+ import useUser from "@/state/useUser.tsx" ;
9
+ import { useEffect } from "react" ;
10
+ import { UserApi } from "@/api/UserApi.tsx" ;
11
+ import { AppWrite } from "@/api/Http.tsx" ;
12
+ import { UserModel } from "@/types.ts" ;
13
+ import { toast } from "@pheralb/toast" ;
8
14
9
15
function App ( ) {
16
+ const api = new UserApi ( ) ;
17
+ const user = useUser ( ) ;
18
+ useEffect ( ( ) => {
19
+ const handle = async ( ) => {
20
+ const now = await api . GetNow ( ) ;
21
+ const app :AppWrite < UserModel > = JSON . parse ( now . data ) ;
22
+ if ( app . code === 401 ) {
23
+ if ( user . dash !== undefined || user . user !== undefined ) {
24
+ user . logout ( ) ;
25
+ toast . info ( {
26
+ text : "Login expired, please log in again" ,
27
+ } )
28
+ }
29
+ }
30
+ } ;
31
+ handle ( ) . then ( ) . catch ( )
32
+ } , [ ] ) ;
10
33
return (
11
34
< Routes >
12
35
< Route path = { "/" } element = { < RootLayout /> } >
13
36
< Route path = { "explore" } element = { < ExploreLayout /> } />
37
+ {
38
+ user . dash && (
39
+ < Route path = { "" } element = { < ExploreLayout /> } />
40
+ )
41
+ }
14
42
< Route path = { "market" } element = { < MarketLayout /> } />
15
43
< Route path = { "community" } element = { < CommunityLayout /> } />
16
44
< Route path = { ":username" } element = { < LayoutUser /> } >
0 commit comments