Skip to content

Commit

Permalink
activist-org#856 fix route bug on reroute to about for orgs and events
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtavis committed Apr 30, 2024
1 parent 9815cdf commit f2fc016
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
20 changes: 15 additions & 5 deletions frontend/pages/events/[id]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,27 @@ const windowWidth = ref(window.innerWidth);
const handleResize = () => {
windowWidth.value = window.innerWidth;
if (window.innerWidth > Breakpoint.SMALL) {
navigateTo(`${id}/about`);
window.removeEventListener("resize", handleResize);
if (windowWidth.value > Breakpoint.SMALL) {
const { locale } = useI18n();
const currentRoute = useRoute();
console.log(`Hey 1: ${currentRoute.path}`);
if (
currentRoute.path !== `/${locale.value}/events/${id}/about` ||
currentRoute.path === `/${locale.value}/events/${id}/`
) {
navigateTo(`/${locale.value}/events/${id}/about`);
}
}
};
onMounted(() => {
// Verify that the user is on a mobile device.
handleResize();
// Add event listener to handle resizing.
window.addEventListener("resize", handleResize);
});
onUnmounted(() => {
window.removeEventListener("resize", handleResize);
});
</script>
20 changes: 15 additions & 5 deletions frontend/pages/organizations/[id]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -158,17 +158,27 @@ const windowWidth = ref(window.innerWidth);
const handleResize = () => {
windowWidth.value = window.innerWidth;
if (window.innerWidth > Breakpoint.SMALL) {
navigateTo(`${id}/about`);
window.removeEventListener("resize", handleResize);
if (windowWidth.value > Breakpoint.SMALL) {
const { locale } = useI18n();
const currentRoute = useRoute();
console.log(`Hey 1: ${currentRoute.path}`);
if (
currentRoute.path !== `/${locale.value}/organizations/${id}/about` ||
currentRoute.path === `/${locale.value}/organizations/${id}/`
) {
navigateTo(`/${locale.value}/organizations/${id}/about`);
}
}
};
onMounted(() => {
// Verify that the user is on a mobile device.
handleResize();
// Add event listener to handle resizing.
window.addEventListener("resize", handleResize);
});
onUnmounted(() => {
window.removeEventListener("resize", handleResize);
});
</script>

0 comments on commit f2fc016

Please sign in to comment.