Skip to content

Commit

Permalink
use async await
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbell committed Mar 26, 2024
1 parent f9fb25b commit e3fcd40
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/ui/preview/PreviewHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</template>

<script>
import { toRaw } from 'vue';
import { nextTick, toRaw } from 'vue';

import NotebookMenuSwitcher from '@/plugins/notebook/components/NotebookMenuSwitcher.vue';

Expand Down Expand Up @@ -107,21 +107,20 @@ export default {
};
},
watch: {
currentView() {
async currentView() {
// wait for view to render with next tick
this.$nextTick(() => {
if (this.actionCollection) {
this.unlistenToActionCollection();
}
await nextTick();
if (this.actionCollection) {
this.unlistenToActionCollection();
}

this.actionCollection = this.openmct.actions.getActionsCollection(
toRaw(this.objectPath),
toRaw(this.currentView)
);
this.actionCollection = this.openmct.actions.getActionsCollection(
toRaw(this.objectPath),
toRaw(this.currentView)
);

this.actionCollection.on('update', this.updateActionItems);
this.updateActionItems(this.actionCollection.getActionsObject());
});
this.actionCollection.on('update', this.updateActionItems);
this.updateActionItems(this.actionCollection.getActionsObject());
}
},
unmounted() {
Expand Down

0 comments on commit e3fcd40

Please sign in to comment.