@@ -11,6 +11,7 @@ import { onBeforeMount, onUnmounted, ref, watch } from "vue";
1111import RefreshConfig from " ../RefreshConfig.vue" ;
1212import useAutoRefresh from " @/composables/autoRefresh.ts" ;
1313import throttle from " lodash/throttle" ;
14+ import LoadingSpinner from " @/components/LoadingSpinner.vue" ;
1415
1516const store = useAuditStore ();
1617const { messages, totalCount, sortBy, messageFilterString, selectedEndpointName, itemsPerPage, dateRange } = storeToRefs (store );
@@ -87,16 +88,16 @@ function navigateToMessage(message: Message) {
8788 });
8889}
8990
90- let firstLoad = true ;
91+ const firstLoad = ref ( true ) ;
9192
9293onBeforeMount (() => {
9394 setQuery ();
9495
9596 // without setTimeout, this happens before the store is properly initialised, and therefore the query route values aren't applied to the refresh
96- // TODO: is there a better way to achieve this?
97- setTimeout ( async () => await Promise .all ([dataRetriever .executeAndResetTimer (), store .loadEndpoints ()]), 0 );
98-
99- firstLoad = false ;
97+ setTimeout ( async () => {
98+ await Promise .all ([dataRetriever .executeAndResetTimer (), store .loadEndpoints ()]);
99+ firstLoad . value = false ;
100+ }, 0 ) ;
100101});
101102
102103watch (
@@ -109,7 +110,7 @@ watch(
109110);
110111
111112const watchHandle = watch ([() => route .query , itemsPerPage , sortBy , messageFilterString , selectedEndpointName , dateRange ], async () => {
112- if (firstLoad ) {
113+ if (firstLoad . value ) {
113114 return ;
114115 }
115116
@@ -164,6 +165,7 @@ watch(autoRefreshValue, (newValue) => dataRetriever.updateTimeout(newValue));
164165 </div >
165166 </div >
166167 <div class =" row results-table" >
168+ <LoadingSpinner v-if =" firstLoad" />
167169 <template v-for =" message in messages " :key =" message .id " >
168170 <div class =" item" @click =" navigateToMessage(message)" >
169171 <div class =" status" >
0 commit comments