Skip to content

Commit 1bacc8d

Browse files
committed
apply pollinginterval computed watch pattern to failedmessages/deletedmessages and fix merge atavisms
1 parent 4591296 commit 1bacc8d

File tree

4 files changed

+32
-46
lines changed

4 files changed

+32
-46
lines changed

src/Frontend/src/components/failedmessages/DeletedMessageGroups.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ const { archiveGroups, classifiers, selectedClassifier } = storeToRefs(store);
2727
const router = useRouter();
2828
const showRestoreGroupModal = ref(false);
2929
const selectedGroup = ref<ExtendedFailureGroupView>();
30-
const groupRestoreSuccessful = ref<boolean | null>(null);
3130
3231
async function classifierChanged(classifier: string) {
3332
store.setGrouping(classifier);
@@ -51,7 +50,6 @@ async function restoreGroup() {
5150
} else {
5251
// We're starting a restore, poll more frequently
5352
updateInterval(POLLING_INTERVAL_FAST);
54-
groupRestoreSuccessful.value = true;
5553
useShowToast(TYPE.INFO, "Info", "Group restore started...");
5654
}
5755
}

src/Frontend/src/components/failedmessages/DeletedMessages.vue

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { onMounted, ref, watch } from "vue";
2+
import { computed, onMounted, ref, watch } from "vue";
33
import { useShowToast } from "../../composables/toast";
44
import { onBeforeRouteLeave } from "vue-router";
55
import LicenseNotExpired from "../../components/LicenseNotExpired.vue";
@@ -16,12 +16,14 @@ import { useStoreAutoRefresh } from "@/composables/useAutoRefresh";
1616
import { DeletedPeriodOption, useMessagesStore } from "@/stores/MessagesStore";
1717
import LoadingSpinner from "../LoadingSpinner.vue";
1818
19+
const POLLING_INTERVAL_NORMAL = 5000;
20+
const POLLING_INTERVAL_FAST = 1000;
21+
1922
const loading = ref(false);
20-
const { autoRefresh, isRefreshing, updateInterval } = useStoreAutoRefresh("messagesStore", useMessagesStore, 5000);
23+
const { autoRefresh, isRefreshing, updateInterval } = useStoreAutoRefresh("messagesStore", useMessagesStore, POLLING_INTERVAL_NORMAL);
2124
const { store } = autoRefresh();
2225
const { messages, groupId, groupName, totalCount, pageNumber, selectedPeriod } = storeToRefs(store);
2326
24-
let pollingFaster = false;
2527
const showConfirmRestore = ref(false);
2628
const messageList = ref<IMessageList | undefined>();
2729
@@ -43,8 +45,7 @@ function isAnythingSelected() {
4345
4446
async function restoreSelectedMessages() {
4547
// We're starting a restore, poll more frequently
46-
pollingFaster = true;
47-
updateInterval(1000);
48+
updateInterval(POLLING_INTERVAL_FAST);
4849
const selectedMessages = messageList.value?.getSelectedMessages() ?? [];
4950
selectedMessages.forEach((m) => (m.restoreInProgress = true));
5051
useShowToast(TYPE.INFO, "Info", `restoring ${selectedMessages.length} messages...`);
@@ -59,24 +60,19 @@ async function periodChanged(period: DeletedPeriodOption) {
5960
loading.value = false;
6061
}
6162
62-
function isRestoreInProgress() {
63-
return messages.value.some((message) => message.restoreInProgress);
64-
}
65-
6663
onBeforeRouteLeave(() => {
6764
groupId.value = "";
6865
groupName.value = "";
6966
});
7067
71-
watch(isRefreshing, () => {
72-
// If we're currently polling at 5 seconds and there is a restore in progress, then change the polling interval to poll every 1 second
73-
if (!pollingFaster && isRestoreInProgress()) {
74-
pollingFaster = true;
75-
updateInterval(1000);
76-
} else if (pollingFaster && !isRestoreInProgress()) {
77-
// if we're currently polling every 1 second but all restores are done, change polling frequency back to every 5 seconds
78-
pollingFaster = false;
79-
updateInterval(5000);
68+
const isRestoreInProgress = computed(() => messages.value.some((message) => message.restoreInProgress));
69+
watch(isRestoreInProgress, (restoreInProgress) => {
70+
if (restoreInProgress) {
71+
// If there is a restore in progress, poll every 1 second
72+
updateInterval(POLLING_INTERVAL_FAST);
73+
} else {
74+
// If all restores are done, change polling frequency back to every 5 seconds
75+
updateInterval(POLLING_INTERVAL_NORMAL);
8076
}
8177
});
8278

src/Frontend/src/components/failedmessages/FailedMessages.vue

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { onMounted, ref, useTemplateRef, watch } from "vue";
2+
import { computed, onMounted, ref, useTemplateRef, watch } from "vue";
33
import { useShowToast } from "../../composables/toast";
44
import { downloadFileFromString } from "../../composables/fileDownloadCreator";
55
import { onBeforeRouteLeave } from "vue-router";
@@ -22,14 +22,16 @@ import { useStoreAutoRefresh } from "@/composables/useAutoRefresh";
2222
import { storeToRefs } from "pinia";
2323
import LoadingSpinner from "../LoadingSpinner.vue";
2424
25+
const POLLING_INTERVAL_NORMAL = 5000;
26+
const POLLING_INTERVAL_FAST = 1000;
27+
2528
const messageStore = useMessageStore();
2629
const messageGroupClient = createMessageGroupClient();
2730
const loading = ref(false);
28-
const { autoRefresh, isRefreshing, updateInterval } = useStoreAutoRefresh("messagesStore", useMessagesStore, 5000);
31+
const { autoRefresh, isRefreshing, updateInterval } = useStoreAutoRefresh("messagesStore", useMessagesStore, POLLING_INTERVAL_NORMAL);
2932
const { store } = autoRefresh();
3033
const { messages, groupId, groupName, totalCount, pageNumber } = storeToRefs(store);
3134
32-
let pollingFaster = false;
3335
const showDelete = ref(false);
3436
const showConfirmRetryAll = ref(false);
3537
const showConfirmDeleteAll = ref(false);
@@ -55,8 +57,7 @@ async function sortGroups(sort: SortOptions<GroupOperation>) {
5557
5658
async function retryRequested(id: string) {
5759
// We're starting a retry, poll more frequently
58-
pollingFaster = true;
59-
updateInterval(1000);
60+
updateInterval(POLLING_INTERVAL_FAST);
6061
useShowToast(TYPE.INFO, "Info", "Message retry requested...");
6162
await messageStore.retryMessages([id]);
6263
const message = messages.value.find((m) => m.id === id);
@@ -68,8 +69,7 @@ async function retryRequested(id: string) {
6869
6970
async function retrySelected() {
7071
// We're starting a retry, poll more frequently
71-
pollingFaster = true;
72-
updateInterval(1000);
72+
updateInterval(POLLING_INTERVAL_FAST);
7373
const selectedMessages = messageList.value?.getSelectedMessages() ?? [];
7474
useShowToast(TYPE.INFO, "Info", "Retrying " + selectedMessages.length + " messages...");
7575
await messageStore.retryMessages(selectedMessages.map((m) => m.id));
@@ -153,8 +153,7 @@ function isAnythingSelected() {
153153
154154
async function deleteSelectedMessages() {
155155
// We're starting a delete, poll more frequently
156-
pollingFaster = true;
157-
updateInterval(1000);
156+
updateInterval(POLLING_INTERVAL_FAST);
158157
const selectedMessages = messageList.value?.getSelectedMessages() ?? [];
159158
160159
useShowToast(TYPE.INFO, "Info", "Deleting " + selectedMessages.length + " messages...");
@@ -175,26 +174,19 @@ async function deleteGroup() {
175174
messages.value.forEach((m) => (m.deleteInProgress = true));
176175
}
177176
178-
function isRetryOrDeleteOperationInProgress() {
179-
return messages.value.some((message) => {
180-
return message.retryInProgress || message.deleteInProgress;
181-
});
182-
}
183-
184177
onBeforeRouteLeave(() => {
185178
groupId.value = "";
186179
groupName.value = "";
187180
});
188181
189-
watch(isRefreshing, () => {
190-
// If we're currently polling at 5 seconds and there is a retry or delete in progress, then change the polling interval to poll every 1 second
191-
if (!pollingFaster && isRetryOrDeleteOperationInProgress()) {
192-
pollingFaster = true;
193-
updateInterval(1000);
194-
} else if (pollingFaster && !isRetryOrDeleteOperationInProgress()) {
195-
// if we're currently polling every 1 second but all retries or deletes are done, change polling frequency back to every 5 seconds
196-
pollingFaster = false;
197-
updateInterval(5000);
182+
const isRetryOrDeleteOperationInProgress = computed(() => messages.value.some((message) => message.retryInProgress || message.deleteInProgress));
183+
watch(isRetryOrDeleteOperationInProgress, (retryOrDeleteOperationInProgress) => {
184+
// If there is a retry or delete in progress, then change the polling interval to poll every 1 second
185+
if (retryOrDeleteOperationInProgress) {
186+
updateInterval(POLLING_INTERVAL_FAST);
187+
} else {
188+
// if all retries or deletes are done, change polling frequency back to every 5 seconds
189+
updateInterval(POLLING_INTERVAL_NORMAL);
198190
}
199191
});
200192

src/Frontend/src/components/failedmessages/messageGroupClient.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export interface ErrorResponse {
99

1010
export class MessageGroupClient {
1111
serviceControlStore: ServiceControlStore;
12-
constructor(store?: ServiceControlStore) {
12+
constructor() {
1313
//this module is only called from within view setup or other pinia stores, so this call is lifecycle safe
14-
this.serviceControlStore = store ?? useServiceControlStore();
14+
this.serviceControlStore = useServiceControlStore();
1515
}
1616

1717
public async getExceptionGroups(classifier: string = "") {

0 commit comments

Comments
 (0)