Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed profile image mulfunction #93

Merged
merged 3 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/Logo.svg" />
<link rel="icon" href="%PUBLIC_URL%/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
Expand Down
14 changes: 8 additions & 6 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, useSetRecoilState } from "recoil";
import { useRecoilState } from "recoil";
import { avatar, id, name, isLogin } from "../recoil/authorize";
import styled from "styled-components";
const ElevationScroll = (props) => {
Expand Down Expand Up @@ -48,11 +48,13 @@ export const Header = (props) => {
const [src, setSrc] = useRecoilState(avatar);
const [userId, setUserId] = useRecoilState(id);
const [userName, setUserName] = useRecoilState(name);
const setIsLogin = useSetRecoilState(isLogin);
const [Login, setLogin] = useRecoilState(isLogin);
React.useEffect(() => {
setSrc(localStorage.avatar);
setUserId(localStorage.id);
setUserName(localStorage.name);
if (Login) {
setSrc(localStorage.avatar);
setUserId(localStorage.id);
setUserName(localStorage.name);
}
}, []);
const handleOpenNavMenu = (event) => {
setAnchorElNav(event.currentTarget);
Expand All @@ -76,7 +78,7 @@ export const Header = (props) => {
"",
{ withCredentials: true },
);
setIsLogin(false);
setLogin(false);
localStorage.setItem("id", "guest");
localStorage.setItem("name", "guest");
localStorage.setItem("avatar", "");
Expand Down
8 changes: 7 additions & 1 deletion src/pages/MainPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ function MainPage() {
const setIsLogin = useSetRecoilState(isLogin);

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

useEffect(() => {
Expand Down
Loading