@@ -3,6 +3,7 @@ import { ref, watch } from "vue";
3
3
import { SagaHistory , SagaMessage } from "@/resources/SagaHistory" ;
4
4
import { useFetchFromServiceControl } from "@/composables/serviceServiceControlUrls" ;
5
5
import Message from "@/resources/Message" ;
6
+ import { useMessageStore } from "@/stores/MessageStore" ;
6
7
const StandardKeys = [ "$type" , "Id" , "Originator" , "OriginalMessageId" ] ;
7
8
export interface SagaMessageDataItem {
8
9
key : string ;
@@ -21,15 +22,22 @@ export const useSagaDiagramStore = defineStore("sagaHistory", () => {
21
22
const fetchedMessages = ref ( new Set < string > ( ) ) ;
22
23
const messagesData = ref < SagaMessageData [ ] > ( [ ] ) ;
23
24
const MessageBodyEndpoint = "messages/{0}/body" ;
24
- // Watch for changes to sagaId and fetch saga history data
25
- watch ( sagaId , async ( newSagaId ) => {
26
- if ( ! newSagaId ) {
27
- sagaHistory . value = null ;
28
- return ;
29
- }
30
25
31
- await fetchSagaHistory ( newSagaId ) ;
32
- } ) ;
26
+ const messageStore = useMessageStore ( ) ;
27
+
28
+ //Watch for changes to messageStore.state.data.invoked_saga.has_saga
29
+ watch (
30
+ ( ) => messageStore . state . data . invoked_saga . has_saga ,
31
+ async ( newValue ) => {
32
+ if ( newValue ) {
33
+ sagaId . value = messageStore . state . data . invoked_saga . saga_id || "" ;
34
+ await fetchSagaHistory ( sagaId . value ) ;
35
+ } else {
36
+ clearSagaHistory ( ) ;
37
+ }
38
+ } ,
39
+ { immediate : true }
40
+ ) ;
33
41
34
42
// Watch for changes to showMessageData
35
43
watch ( [ showMessageData , sagaHistory ] , async ( [ show , history ] ) => {
@@ -244,7 +252,6 @@ export const useSagaDiagramStore = defineStore("sagaHistory", () => {
244
252
showMessageData,
245
253
messagesData,
246
254
setSagaId,
247
- fetchSagaHistory,
248
255
clearSagaHistory,
249
256
toggleMessageData,
250
257
} ;
0 commit comments