Skip to content

Commit

Permalink
load home folder by default
Browse files Browse the repository at this point in the history
  • Loading branch information
ciur committed Jul 29, 2024
1 parent cf4ec8a commit ecddde0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 12 additions & 2 deletions ui2/src/app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,38 @@
import {useEffect} from "react"
import "@mantine/core/styles.css"
import {AppShell} from "@mantine/core"
import {Outlet} from "react-router-dom"
import {Outlet, useNavigate} from "react-router-dom"
import {useSelector} from "react-redux"

import NavBar from "@/components/NavBar"
import Header from "@/components/Header/Header"
import {
selectCurrentUserError,
selectCurrentUserStatus
selectCurrentUserStatus,
selectCurrentUser
} from "@/slices/currentUser"

import "./App.css"
import {selectNavBarWidth} from "@/slices/navBar"
import Uploader from "@/components/Uploader"

function App() {
const navigate = useNavigate()
const status = useSelector(selectCurrentUserStatus)
const error = useSelector(selectCurrentUserError)
const navBarWidth = useSelector(selectNavBarWidth)
const user = useSelector(selectCurrentUser)

if (status == "failed") {
return <>{error}</>
}

useEffect(() => {
if (status == "succeeded" && user) {
navigate(`/home/${user.home_folder_id}`)
}
}, [status])

return (
<>
<AppShell
Expand Down
11 changes: 7 additions & 4 deletions ui2/src/slices/currentUser.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {createSlice, createAsyncThunk, PayloadAction} from "@reduxjs/toolkit"
import axios from "@/httpClient"
import type {SliceState, User, UserDetails} from "@/types"
import type {SliceState, SliceStateStatus, User, UserDetails} from "@/types"
import {store} from "@/app/store"
import {storeHomeNode, storeInboxNode} from "./dualPanel/dualPanel"

Expand Down Expand Up @@ -61,6 +61,9 @@ const currentUserSlice = createSlice({

export default currentUserSlice.reducer

export const selectCurrentUser = (state: any) => state.currentUser.data
export const selectCurrentUserStatus = (state: any) => state.currentUser.status
export const selectCurrentUserError = (state: any) => state.currentUser.error
export const selectCurrentUser = (state: any): User =>
state.currentUser.data as User
export const selectCurrentUserStatus = (state: any): SliceStateStatus =>
state.currentUser.status as SliceStateStatus
export const selectCurrentUserError = (state: any): string =>
state.currentUser.error as string

0 comments on commit ecddde0

Please sign in to comment.