Skip to content

Commit

Permalink
Merge pull request #95 from AgainIoT/revert-94-main
Browse files Browse the repository at this point in the history
Revert "Unexpected bugs fixed"
  • Loading branch information
ymw0407 authored Oct 6, 2023
2 parents d64c309 + 4f34440 commit bf64708
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
14 changes: 6 additions & 8 deletions src/layout/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import MenuItem from "@mui/material/MenuItem";
import MenuIcon from "@mui/icons-material/Menu";
import LOGO from "../../src/assets/images/Logo.svg";
import axios from "axios";
import { useRecoilState } from "recoil";
import { useRecoilState, useSetRecoilState } from "recoil";
import { avatar, id, name, isLogin } from "../recoil/authorize";
import styled from "styled-components";
const ElevationScroll = (props) => {
Expand Down Expand Up @@ -48,13 +48,11 @@ export const Header = (props) => {
const [src, setSrc] = useRecoilState(avatar);
const [userId, setUserId] = useRecoilState(id);
const [userName, setUserName] = useRecoilState(name);
const [Login, setLogin] = useRecoilState(isLogin);
const setIsLogin = useSetRecoilState(isLogin);
React.useEffect(() => {
if (Login) {
setSrc(localStorage.avatar);
setUserId(localStorage.id);
setUserName(localStorage.name);
}
setSrc(localStorage.avatar);
setUserId(localStorage.id);
setUserName(localStorage.name);
}, []);
const handleOpenNavMenu = (event) => {
setAnchorElNav(event.currentTarget);
Expand All @@ -78,7 +76,7 @@ export const Header = (props) => {
"",
{ withCredentials: true },
);
setLogin(false);
setIsLogin(false);
localStorage.setItem("id", "guest");
localStorage.setItem("name", "guest");
localStorage.setItem("avatar", "");
Expand Down
8 changes: 1 addition & 7 deletions src/pages/MainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ function MainPage() {
const setIsLogin = useSetRecoilState(isLogin);

const checkIsLogin = async () => {
const loggedIn = await checkTokenValid();
if (!loggedIn) {
localStorage.removeItem("id");
localStorage.removeItem("name");
localStorage.removeItem("avatar");
}
setIsLogin(loggedIn);
setIsLogin(await checkTokenValid());
};

useEffect(() => {
Expand Down

0 comments on commit bf64708

Please sign in to comment.