Skip to content

Commit

Permalink
fix: redirect to newest group slug
Browse files Browse the repository at this point in the history
  • Loading branch information
leafty committed Jan 3, 2025
1 parent 6889409 commit d96c3be
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
13 changes: 12 additions & 1 deletion client/src/features/groupsV2/show/GroupPageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,19 @@ export default function GroupPageContainer() {
replace: true,
}
);
} else if (
slug &&
namespace?.namespace_kind === "group" &&
namespace.slug !== slug
) {
navigate(
generatePath(ABSOLUTE_ROUTES.v2.groups.show.root, {
slug: namespace.slug,
}),
{ replace: true }
);
}
}, [namespace?.namespace_kind, navigate, slug]);
}, [namespace?.namespace_kind, namespace?.slug, navigate, slug]);

if (!slug) {
return <LazyNotFound />;
Expand Down
17 changes: 13 additions & 4 deletions client/src/features/usersV2/show/UserShow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,21 @@ export default function UserShow() {
if (username && namespace?.namespace_kind === "group") {
navigate(
generatePath(ABSOLUTE_ROUTES.v2.groups.show.root, { slug: username }),
{
replace: true,
}
{ replace: true }
);
} else if (
username &&
namespace?.namespace_kind === "user" &&
namespace.slug !== username
) {
navigate(
generatePath(ABSOLUTE_ROUTES.v2.users.show, {
username: namespace.slug,
}),
{ replace: true }
);
}
}, [namespace?.namespace_kind, navigate, username]);
}, [namespace?.namespace_kind, namespace?.slug, navigate, username]);

if (isLoading) {
return <Loader className="align-self-center" />;
Expand Down

0 comments on commit d96c3be

Please sign in to comment.