All files / src/components FlowsLayout.vue

81.81% Statements 9/11
100% Branches 2/2
66.66% Functions 2/3
81.81% Lines 9/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54              7x                                                       6x   6x       6x   6x 6x 6x 6x   6x          
<template>
  <FlowsHeader />
  <RibbonsBanner />
  <FlowsSidebar />
  <AppMain>
    <!-- Keyed on the active flow: a flow switch remounts the page, which then
         reads the new flow's permissions and loads the new flow's data like
         a fresh visit, instead of each page having to watch the flow. -->
    <RouterView :key="authStore.currentFlow ?? ''" />
  </AppMain>
  <!-- Opened over any page (menu, Entities, Flows) through useFlowEditSidebar -->
  <FlowEditSidebar />
  <MissingNicknameModal />
  <ProductWalkthrough />
</template>
 
<script setup lang="ts">
import { onMounted, onUnmounted } from 'vue'
import FlowsHeader from './FlowsHeader.vue'
import RibbonsBanner from './RibbonsBanner.vue'
import FlowsSidebar from './FlowsSidebar.vue'
import AppMain from './AppMain.vue'
import MissingNicknameModal from './MissingNicknameModal.vue'
import FlowEditSidebar from './FlowEditSidebar.vue'
import ProductWalkthrough from './ProductWalkthrough.vue'
import { useMessagesSocket } from '@/composables/useMessagesSocket'
import { usePermissionsRefresh } from '@/composables/usePermissionsRefresh'
import { useFlowScopedReset } from '@/composables/useFlowScopedReset'
import { useAuthStore } from '@/stores/auth'
 
// Disable automatic attribute inheritance since we have multiple root elements
defineOptions({
  inheritAttrs: false
})
 
const authStore = useAuthStore()
// Drops the previous flow's data from the stores on every flow switch
useFlowScopedReset()
 
// Mounted once app-wide (not per-page) so the realtime DM connection and its
// reconnect backoff survive route navigation.
const messagesSocket = useMessagesSocket()
// Reloads stale permissions when the tab comes back (see usePermissionsRefresh.ts)
const permissionsRefresh = usePermissionsRefresh()
onMounted(() => {
  void messagesSocket.connect()
  permissionsRefresh.start()
})
onUnmounted(() => {
  messagesSocket.stop()
  permissionsRefresh.stop()
})
</script>