Skip to content

Commit be6a9ef

Browse files
committed
Fix task polling overriding user input
1 parent 9321ccc commit be6a9ef

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

packages/kolibri-common/components/SyncSchedule/EditDeviceSyncSchedule.vue

+13-7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
:style="selectorStyle"
3232
:options="selectArray"
3333
:label="$tr('frequency')"
34+
@select="handleUserInput"
3435
/>
3536
</KGridItem>
3637
</KGrid>
@@ -43,6 +44,7 @@
4344
:style="selectorStyle"
4445
:options="getDays"
4546
:label="$tr('day')"
47+
@select="handleUserInput"
4648
/>
4749
</KGridItem>
4850
</KGrid>
@@ -55,6 +57,7 @@
5557
:style="selectorStyle"
5658
:options="SyncTime"
5759
:label="$tr('time')"
60+
@select="handleUserInput"
5861
/>
5962
</KGridItem>
6063
</KGrid>
@@ -78,7 +81,7 @@
7881
<KCheckbox
7982
:checked="retryFlag"
8083
:disabled="currentTaskRunning"
81-
@change="retryFlag = !retryFlag"
84+
@change="handleRetryCheckboxChange"
8285
>
8386
{{ $tr('checkboxLabel') }}
8487
</KCheckbox>
@@ -222,9 +225,9 @@
222225
device: null,
223226
now: null,
224227
selectedItem: {},
225-
// tasks: [],
226228
selectedDay: {},
227229
selectedTime: {},
230+
userHasEdited: false,
228231
};
229232
},
230233
computed: {
@@ -321,7 +324,7 @@
321324
},
322325
watch: {
323326
currentTask() {
324-
if (this.currentTask) {
327+
if (this.currentTask && !this.userHasEdited) {
325328
const enqueueAt = new Date(Date.parse(this.currentTask.scheduled_datetime));
326329
const day = enqueueAt.getDay();
327330
const hours = enqueueAt.getHours();
@@ -438,12 +441,8 @@
438441
})
439442
.catch(() => {
440443
this.createTaskFailedSnackbar();
441-
// if (this.currentTask) {
442-
// this.fetchSyncTasks();
443-
// }
444444
});
445445
},
446-
447446
goBack() {
448447
this.$router.push(this.goBackRoute);
449448
},
@@ -461,6 +460,13 @@
461460
this.device = device;
462461
});
463462
},
463+
handleUserInput() {
464+
this.userHasEdited = true;
465+
},
466+
handleRetryCheckboxChange() {
467+
this.retryFlag = !this.retryFlag;
468+
this.handleUserInput();
469+
},
464470
},
465471
$trs: {
466472
editSyncScheduleTitle: {

packages/kolibri-common/composables/useTaskPooling.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1+
import logger from 'kolibri-logging';
12
import { ref, onMounted, onUnmounted } from 'vue';
23
import { useTimeoutPoll } from '@vueuse/core';
34
import TaskResource from 'kolibri/apiResources/TaskResource';
45

56
const taskPollers = new Map();
67

8+
const logging = logger.getLogger(__filename);
9+
710
export default function useTaskPooling(queueName) {
811
if (!taskPollers.has(queueName)) {
912
const consumers = ref(0);
@@ -14,7 +17,7 @@ export default function useTaskPooling(queueName) {
1417
try {
1518
tasks.value = await TaskResource.list({ queue: queueName });
1619
} catch (e) {
17-
console.error(e);
20+
logging.error('Error while fetching tasks', e);
1821
}
1922
},
2023
5000,
@@ -25,11 +28,10 @@ export default function useTaskPooling(queueName) {
2528
}
2629

2730
const poller = taskPollers.get(queueName);
28-
poller.consumers.value++;
29-
3031

3132
onMounted(() => {
32-
if (!poller.isActive) {
33+
poller.consumers.value++;
34+
if (!poller.isActive.value) {
3335
poller.resume();
3436
}
3537
});

0 commit comments

Comments
 (0)