Skip to content

Commit

Permalink
Fix monkeypatched vue-router event links. App is no longer available
Browse files Browse the repository at this point in the history
here, so we use the event bus.  Not ideal, but this keeps the structure
the same for now.
  • Loading branch information
dannon committed Nov 16, 2023
1 parent 484dcc0 commit 92acf03
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions client/src/entry/analysis/modules/Analysis.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup>
import { useEventBus } from "@vueuse/core";
import { onMounted, onUnmounted, ref } from "vue";
import { useRouter } from "vue-router";
import { usePanels } from "@/composables/usePanels";
Expand All @@ -11,10 +11,11 @@ import FlexPanel from "@/components/Panels/FlexPanel.vue";
import ToolPanel from "@/components/Panels/ToolPanel.vue";
import DragAndDropModal from "@/components/Upload/DragAndDropModal.vue";
const router = useRouter();
const showCenter = ref(false);
const { showActivityBar, showToolbox, showPanels } = usePanels();
const { on, off } = useEventBus("router-push");
// methods
function hideCenter() {
showCenter.value = false;
Expand All @@ -28,11 +29,11 @@ function onLoad() {
onMounted(() => {
// Using a custom event here which, in contrast to watching $route,
// always fires when a route is pushed instead of validating it first.
router.app.$on("router-push", hideCenter);
on(hideCenter);
});
onUnmounted(() => {
router.app.$off("router-push", hideCenter);
off(hideCenter);
});
</script>

Expand Down
4 changes: 3 additions & 1 deletion client/src/entry/analysis/router-push.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { useEventBus } from "@vueuse/core";
import { type RouteLocationRaw, type Router } from "vue-router";

import { getGalaxyInstance } from "@/app";
import { addSearchParams } from "@/utils/url";

const { emit } = useEventBus("router-push");
/**
* Is called before the regular router.push() and allows us to provide logs,
* handle the window manager, avoid duplication warnings, and force a component
Expand Down Expand Up @@ -36,7 +38,7 @@ export function patchRouterPush(router: Router) {
}

// Always emit event, even when a duplicate route is pushed
// this.app.emit("router-push");
emit();

// Avoid console warning when user clicks to revisit the same route
return originalPush.call(this, location).catch((err: Error) => {
Expand Down

0 comments on commit 92acf03

Please sign in to comment.