Skip to content

Commit

Permalink
Merge branch 'cofacts:master' into feat/show-join-date#412
Browse files Browse the repository at this point in the history
  • Loading branch information
belong112 authored Dec 17, 2024
2 parents 047f7ba + 419a0d0 commit 284b18a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions components/ProfilePage/ProfilePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,16 @@ function ProfilePage({ id, slug }) {
//
const router = useRouter();
const latestSlug = data?.GetUser?.slug; // slug may update after user edits
const userId = currentUser?.id;
useEffect(() => {
if (!latestSlug) return;
const targetPath = `/user/${encodeURI(latestSlug)}`;
if (window.location.pathname !== targetPath) {
if (latestSlug === undefined) return;
const targetPath = latestSlug
? `/user/${encodeURI(latestSlug)}`
: `/user?id=${userId}`;
if (router.asPath !== targetPath) {
router.replace(targetPath);
}
}, [latestSlug, router]);
}, [latestSlug, userId, router]);

if (loading) {
return (
Expand Down

0 comments on commit 284b18a

Please sign in to comment.