Skip to content

Commit

Permalink
Fix: applying a new view while looking at it
Browse files Browse the repository at this point in the history
  • Loading branch information
jobelenus committed Dec 20, 2024
1 parent 7a8bc8b commit e8a0756
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions app/web/src/pages/WorkspaceSinglePage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ import {
VormInput,
} from "@si/vue-lib/design-system";
import { useChangeSetsStore } from "@/store/change_sets.store";
import { useViewsStore } from "@/store/views.store";
import { useWorkspacesStore } from "@/store/workspaces.store";
import { useAuthStore } from "@/store/auth.store";
import AppLayout from "@/components/layout/AppLayout.vue";
Expand Down Expand Up @@ -191,13 +192,29 @@ function handleUrlChange() {
const changeSetId = route.params.changeSetId as string | undefined;
if ([undefined, "null", "undefined", "auto"].includes(changeSetId ?? "")) {
const id = changeSetsStore.getAutoSelectedChangeSetId();
const newChangeSetId =
id === false || id === changeSetsStore.headChangeSetId ? "head" : id;
const viewId = route.params.viewId as string | undefined;
if (viewId) {
const viewStore = useViewsStore(newChangeSetId);
if (!viewStore.viewsById[viewId]) {
delete route.params.viewId;
const defaultView =
viewStore.viewList.find((v) => v.id === viewId) ||
viewStore.viewList[0];
if (viewStore.outlinerViewId === viewId)
viewStore.outlinerViewId = defaultView?.id ?? null;
if (viewStore.selectedViewId === viewId)
viewStore.selectedViewId = defaultView?.id ?? null;
}
}
router.replace({
name: route.name, // eslint-disable-line @typescript-eslint/no-non-null-assertion
params: {
...route.params,
changeSetId:
id === false || id === changeSetsStore.headChangeSetId ? "head" : id,
changeSetId: newChangeSetId,
},
query: { ...route.query },
});
Expand Down

0 comments on commit e8a0756

Please sign in to comment.