|
1 | 1 | import { acceptHMRUpdate, defineStore, storeToRefs } from "pinia"; |
2 | | -import { computed, reactive, ref } from "vue"; |
| 2 | +import { computed, reactive, ref, watch } from "vue"; |
3 | 3 | import Header from "@/resources/Header"; |
4 | 4 | import type EndpointDetails from "@/resources/EndpointDetails"; |
5 | 5 | import { FailedMessage, ExceptionDetails, FailedMessageStatus } from "@/resources/FailedMessage"; |
6 | | -import { useEditRetryStore } from "@/stores/EditRetryStore"; |
7 | 6 | import { useConfigurationStore } from "@/stores/ConfigurationStore"; |
8 | 7 | import Message, { MessageStatus } from "@/resources/Message"; |
9 | 8 | import moment from "moment/moment"; |
10 | 9 | import { parse, stringify } from "lossless-json"; |
11 | 10 | import xmlFormat from "xml-formatter"; |
12 | 11 | import { DataContainer } from "./DataContainer"; |
13 | 12 | import { useServiceControlStore } from "./ServiceControlStore"; |
| 13 | +import { EditAndRetryConfig } from "@/resources/Configuration"; |
14 | 14 |
|
15 | 15 | interface Model { |
16 | 16 | id?: string; |
@@ -62,19 +62,24 @@ export const useMessageStore = defineStore("MessageStore", () => { |
62 | 62 | const headers = ref<DataContainer<Header[]>>({ data: [] }); |
63 | 63 | const body = ref<DataContainer<{ value?: string; content_type?: string; no_content?: boolean }>>({ data: {} }); |
64 | 64 | const state = reactive<DataContainer<Model>>({ data: { failure_metadata: {}, failure_status: {}, dialog_status: {}, invoked_saga: {} } }); |
| 65 | + const edit_and_retry_config = ref<EditAndRetryConfig>({ enabled: false, locked_headers: [], sensitive_headers: [] }); |
| 66 | + const conversationData = ref<DataContainer<Message[]>>({ data: [] }); |
| 67 | + |
65 | 68 | let bodyLoadedId = ""; |
66 | 69 | let conversationLoadedId = ""; |
67 | | - const conversationData = ref<DataContainer<Message[]>>({ data: [] }); |
68 | | - const editRetryStore = useEditRetryStore(); |
| 70 | + |
69 | 71 | const configStore = useConfigurationStore(); |
70 | 72 | const serviceControlStore = useServiceControlStore(); |
| 73 | + const { serviceControlUrl } = storeToRefs(serviceControlStore); |
71 | 74 |
|
72 | | - const { config: edit_and_retry_config } = storeToRefs(editRetryStore); |
73 | 75 | const { configuration } = storeToRefs(configStore); |
74 | 76 | const error_retention_period = computed(() => moment.duration(configuration.value?.data_retention?.error_retention_period).asHours()); |
75 | 77 |
|
76 | | - // eslint-disable-next-line promise/catch-or-return,promise/prefer-await-to-then,promise/valid-params |
77 | | - Promise.all([editRetryStore.loadConfig(), configStore.refresh()]).then(); |
| 78 | + watch(serviceControlUrl, loadConfig, { immediate: true }); |
| 79 | + async function loadConfig() { |
| 80 | + const [, data] = await serviceControlStore.fetchTypedFromServiceControl<EditAndRetryConfig>("edit/config"); |
| 81 | + edit_and_retry_config.value = data; |
| 82 | + } |
78 | 83 |
|
79 | 84 | function reset() { |
80 | 85 | state.data = { failure_metadata: {}, failure_status: {}, dialog_status: {}, invoked_saga: {} }; |
|
0 commit comments