Skip to content

Commit

Permalink
fix: Overwriting of locale when redirecting to versioned cube
Browse files Browse the repository at this point in the history
...there is no need to specify the locale in pathname. Using this led to overwiting the locale, as we used the old locale, while the router was setting a new one on route change.
  • Loading branch information
bprusinowski committed Sep 12, 2023
1 parent 49153ea commit 8f27098
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ You can also check the [release page](https://github.com/visualize-admin/visuali

- Fixes
- Table docs now work correctly again
- Changing the locale when previewing a larger cube no longer triggers multiple locale switches

# [3.22.5] - 2023-09-12

Expand Down
4 changes: 2 additions & 2 deletions app/components/use-redirect-to-versioned-cube.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ describe("use redirect to versioned cube", () => {
versionedCube: { iri: "https://versioned-cube" },
});
expect(router.replace).toHaveBeenCalledWith({
pathname: "/de/browse",
pathname: "/browse",
query: {
dataset: "https://versioned-cube",
},
Expand All @@ -100,7 +100,7 @@ describe("use redirect to versioned cube", () => {
versionedCube: { iri: "https://versioned-cube2" },
});
expect(router.replace).toHaveBeenCalledWith({
pathname: "/de/browse",
pathname: "/browse",
query: {
dataset: "https://versioned-cube2",
},
Expand Down
2 changes: 1 addition & 1 deletion app/components/use-redirect-to-versioned-cube.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const useRedirectToVersionedCube = ({

if (resp) {
router.replace({
pathname: `/${locale}/browse`,
pathname: `/browse`,
query: {
...router.query,
...(router.query.iri ? { iri: resp.iri } : { dataset: resp.iri }),
Expand Down
3 changes: 1 addition & 2 deletions app/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@ export default function App({
pageProps: { session, ...pageProps },
}: AppProps) {
const { events: routerEvents, asPath, locale: routerLocale } = useRouter();
const locale = parseLocaleString(routerLocale ?? "");

useNProgress();

const locale = parseLocaleString(routerLocale ?? "");

// Immediately activate locale to avoid re-render
if (i18n.locale !== locale) {
i18n.activate(locale);
Expand Down

0 comments on commit 8f27098

Please sign in to comment.