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

fix reloading issue, when user click refresh button it shows 404 page. #1260

Merged
merged 2 commits into from
Sep 18, 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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function App() {
setUser(authUser);
} else {
setUser(null);
navigate("/dummygram/login");
navigate("/login");
}
});
return () => {
Expand All @@ -116,7 +116,7 @@ function App() {
<ErrorBoundary inApp={true}>
<Routes>
<Route
path="/dummygram"
path="/"
element={
<ErrorBoundary inApp={true}>
<Wrapper
Expand Down Expand Up @@ -322,10 +322,10 @@ function Wrapper({ user, setUser, setRowMode }) {
}, []);

const isCenteredScroll =
location.pathname === "/dummygram/favourites" ||
location.pathname === "/dummygram/about" ||
location.pathname === "/dummygram/guidelines" ||
location.pathname === "/dummygram/contributors";
location.pathname === "/favourites" ||
location.pathname === "/about" ||
location.pathname === "/guidelines" ||
location.pathname === "/contributors";

return (
<div className="app">
Expand All @@ -334,8 +334,7 @@ function Wrapper({ user, setUser, setRowMode }) {
user={user}
setUser={setUser}
/>
{(location.pathname == "/dummygram/login" ||
location.pathname == "/dummygram/signup") && (
{(location.pathname == "/login" || location.pathname == "/signup") && (
<Darkmode themeClass="themeButton themeButton-login" />
)}

Expand Down
6 changes: 3 additions & 3 deletions src/components/CommunityChat/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const ChatBox = () => {
docRef
.get()
.then((doc) => {
navigate(`/dummygram/user/${doc.data().username}`);
navigate(`/user/${doc.data().username}`);
})
.catch((error) => {
enqueueSnackbar(`Error Occured: ${error}`, {
Expand Down Expand Up @@ -185,7 +185,7 @@ const ChatBox = () => {
if (user) {
setUser(user);
} else {
navigate("/dummygram/login");
navigate("/login");
}
});

Expand Down Expand Up @@ -268,7 +268,7 @@ const ChatBox = () => {
<>
<div className="chat-main-container">
<div className="closeBtn">
<HighlightOffRoundedIcon onClick={() => navigate("/dummygram/")} />
<HighlightOffRoundedIcon onClick={() => navigate("/")} />
</div>

{isLoading ? (
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditProfile/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const EditProfile = ({ userData, username, setIsEditing, setUserData }) => {
await updateUser(oldImg)
.then(() => {
setUserData(editedData);
navigate(`/dummygram/user/${newUsername}`);
navigate(`/user/${newUsername}`);
playSuccessSound();
enqueueSnackbar("Upload Successfull", {
variant: "success",
Expand Down
4 changes: 2 additions & 2 deletions src/components/FriendsComponent/Locked/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ const LockedFriendPage = ({ name }) => {
className="profile_lock_img"
/>
<h3>
Add <Link to={`/dummygram/user/${name}`}>{name}</Link> as friend to
unlock their friend list!
Add <Link to={`/user/${name}`}>{name}</Link> as friend to unlock their
friend list!
</h3>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/FriendsComponent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ const FriendsComponent = () => {
src={photoURL ? photoURL : blankImg}
alt={"user pic"}
className="friend_page_friend_avatar"
onClick={() => navigate(`/dummygram/user/${username}`)}
onClick={() => navigate(`/user/${username}`)}
/>
<div>
<h3
className="friend_page_friend_name"
onClick={() => navigate(`/dummygram/user/${username}`)}
onClick={() => navigate(`/user/${username}`)}
>
{displayName ? displayName : "user"}
</h3>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Guest/GuestSignInBtn/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const GuestSignInBtn = ({ show }) => {
enqueueSnackbar("Guest Sign In successfull", {
variant: "success",
});
navigate("/dummygram");
navigate("/");
})
.catch((error) => {
playErrorSound();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Guest/GuestSignUpBtn/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const GuestSignUpBtn = () => {
<div className="guest-sign-up-button-container">
<button
className="guest-sign-up-button"
onClick={() => navigate("/dummygram/signup")}
onClick={() => navigate("/signup")}
>
Sign Up
</button>
Expand Down
12 changes: 6 additions & 6 deletions src/components/Navbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Navbar({ onClick, user, setUser }) {
setUser(authUser);
} else {
setUser(null);
navigate("/dummygram/login");
navigate("/login");
}
});
return () => {
Expand All @@ -96,15 +96,15 @@ function Navbar({ onClick, user, setUser }) {
}, [user]);

return (
location.pathname !== "/dummygram/login" &&
location.pathname !== "/dummygram/signup" && (
location.pathname !== "/login" &&
location.pathname !== "/signup" && (
<div className="app__header">
{windowWidth > 600 ? (
<span className="nav_text_logo">
<Logo />
</span>
) : (
<span onClick={() => navigate("/dummygram")}>
<span onClick={() => navigate("/")}>
<img src={appLogo} alt="dummygram" className="nav_img_logo" />
</span>
)}
Expand Down Expand Up @@ -149,7 +149,7 @@ function Navbar({ onClick, user, setUser }) {
key={id}
className="searched_user_li"
onClick={() =>
navigate(`/dummygram/user/${user.username}`)
navigate(`/user/${user.username}`)
}
>
<img
Expand Down Expand Up @@ -184,7 +184,7 @@ function Navbar({ onClick, user, setUser }) {
<div
className="rowConvert"
id="chat-icon"
onClick={() => navigate("/dummygram/chat")}
onClick={() => navigate("/chat")}
>
<ChatIcon className="chatIcon" />
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/Notification/index.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import "./index.css";

import { Loader } from "../../reusableComponents";
import React, { useEffect, useState } from "react";
import { auth, db } from "../../lib/firebase";
import firebase from "firebase/compat/app";

import { Box } from "@mui/material";
import { Link } from "react-router-dom";
import { Loader } from "../../reusableComponents";
import { SideBar } from "../index";
import firebase from "firebase/compat/app";
import { useSnackbar } from "notistack";

function Notifications() {
Expand Down Expand Up @@ -161,7 +161,7 @@ function Notifications() {
{message} from{" "}
<Link
className="friend-request-sender-name"
to={`/dummygram/user/${username ? username : ""}`}
to={`/user/${username ? username : ""}`}
>
{name ? name : ""}.
</Link>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Post/CommentBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const CommentBox = ({
disabled={comment.trim().length < 1}
type="submit"
onClick={(e) =>
isAnonymous ? navigate("/dummygram/signup") : postComment(e)
isAnonymous ? navigate("/signup") : postComment(e)
}
style={{
padding: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Post/CommentDialogBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const CommentDialogBox = ({ postId, comments, user, fullScreen }) => {
<div>
<Link
className="comment-doer"
to={`/dummygram/${
to={`/${
isAnonymous
? "signup"
: `user/${userComment.content.username}`
Expand Down
4 changes: 2 additions & 2 deletions src/components/Post/LikesDialogBox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const trimBio = (bio, maxLength = 90) => {

const renderUser = ({ uid, username, photoURL, name, bio }) => (
<div key={uid} className="likedby_list_item">
<Link to={`/dummygram/user/${username}`} style={{ color: "var(--color)" }}>
<Link to={`/user/${username}`} style={{ color: "var(--color)" }}>
<img
src={photoURL ? photoURL : blankProfileImg}
alt={name}
Expand All @@ -25,7 +25,7 @@ const renderUser = ({ uid, username, photoURL, name, bio }) => (
<div>
<section className="like_user_data">
<Link
to={`/dummygram/user/${username}`}
to={`/user/${username}`}
style={{ textDecoration: "none" }}
>
<h3 className="like_user_name">{name}</h3>
Expand Down
14 changes: 5 additions & 9 deletions src/components/Post/PostHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ const PostHeader = ({ postId, user, postData, postHasImages, timestamp }) => {
alt={displayName}
src={avatar}
onClick={() =>
navigate(
"/dummygram/" + (isAnonymous ? "signup" : "user/" + username),
)
navigate("/" + (isAnonymous ? "signup" : "user/" + username))
}
onMouseEnter={showProfileDialogBox}
onMouseLeave={hideProfileDialogBox}
Expand All @@ -145,9 +143,7 @@ const PostHeader = ({ postId, user, postData, postHasImages, timestamp }) => {
<div className="header-data">
<h3
onClick={() => {
navigate(
"/dummygram/" + (isAnonymous ? "signup" : "posts/" + postId),
);
navigate("/" + (isAnonymous ? "signup" : "posts/" + postId));
}}
className="post__username"
>
Expand All @@ -156,7 +152,7 @@ const PostHeader = ({ postId, user, postData, postHasImages, timestamp }) => {
<p className="post__time">{time}</p>
</div>
<div className="social__icon__last">
{!location.pathname.includes("/dummygram/user") && (
{!location.pathname.includes("/user") && (
<IconButton
aria-label="more"
id="long-button"
Expand All @@ -165,7 +161,7 @@ const PostHeader = ({ postId, user, postData, postHasImages, timestamp }) => {
aria-haspopup="true"
onClick={(event) =>
isAnonymous
? navigate("/dummygram/signup")
? navigate("/signup")
: setAnchorEl(event.currentTarget)
}
sx={{
Expand Down Expand Up @@ -200,7 +196,7 @@ const PostHeader = ({ postId, user, postData, postHasImages, timestamp }) => {
{postHasImages && (
<MenuItem onClick={handleDownload}> Download </MenuItem>
)}
<MenuItem onClick={() => navigate(`/dummygram/user/${username}`)}>
<MenuItem onClick={() => navigate(`/user/${username}`)}>
Visit Profile
</MenuItem>
</Menu>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Post/PostNav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PostNav = ({

const handleOnClick = async () => {
if (isAnonymous) {
navigate("/dummygram/signup");
navigate("/signup");
} else {
try {
const data = await savePost(postId);
Expand All @@ -50,7 +50,7 @@ const PostNav = ({
<Flexbetween
sx={{ cursor: "pointer" }}
onClick={() =>
isAnonymous ? navigate("/dummygram/signup") : likesHandler()
isAnonymous ? navigate("/signup") : likesHandler()
}
>
<IconButton>
Expand All @@ -75,7 +75,7 @@ const PostNav = ({
sx={{ cursor: "pointer" }}
onClick={() => {
isAnonymous
? navigate("/dummygram/signup")
? navigate("/signup")
: setisCommentOpen(true);
}}
>
Expand All @@ -93,7 +93,7 @@ const PostNav = ({
sx={{ cursor: "pointer" }}
onClick={() => {
if (isAnonymous) {
navigate("/dummygram/signup");
navigate("/signup");
} else {
setOpenShareModal((prev) => !prev);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/ProfileDialogBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ const ProfileDialogBox = ({ mouseOnProfileImg, userData }) => {
src={avatar ? avatar : profileAvatar}
alt={name}
className="dialog-box-img"
onClick={() => navigate(`/dummygram/user/${username}`)}
onClick={() => navigate(`/user/${username}`)}
/>
<div
className="dialog-box-name-container"
style={{ marginTop: "10px" }}
>
<h4
className="dialog-box-display-name"
onClick={() => navigate(`/dummygram/user/${username}`)}
onClick={() => navigate(`/user/${username}`)}
>
{name}
</h4>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ReadMore/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const ReadMore = ({ children, postId, picCap = false, readMore = true }) => {
onClick={() => {
toggleReadMore();
if (!id) {
navigate(`/dummygram/posts/${postId}`);
navigate(`/posts/${postId}`);
}
}}
style={{
Expand Down
2 changes: 1 addition & 1 deletion src/components/SettingsComponents/DeleteAccount/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const DeleteAccount = ({ user }) => {
await Promise.all(deleteImagePromises);

localStorage.removeItem("user");
navigate("/dummygram/login");
navigate("/login");
enqueueSnackbar("User deleted successfully", {
variant: "success",
});
Expand Down
Loading
Loading