Skip to content

Commit 06585f0

Browse files
committed
fix: frontend stop mining loading state & stepper progress tracker
1 parent 4090814 commit 06585f0

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

backend/src/services/tasks-manager/TasksManager.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,7 @@ export default class TasksManager {
369369
: !p.stoppedAt && p.id && processIds?.includes(p.id)
370370
);
371371

372-
if (endEntireTask) {
373-
// Signal to indicate the mining is completed
374-
progressHandlerSSE.sendSSE('mining-completed', 'mining-completed');
375-
progressHandlerSSE.stop();
376-
this.ACTIVE_MINING_TASKS.delete(miningId);
377-
}
378-
379-
if (processesToStop.length) {
380-
await this.stopTask(processesToStop, true);
381-
}
372+
const promise = this.stopTask(processesToStop, true);
382373

383374
const status =
384375
fetch.stoppedAt !== undefined &&
@@ -387,8 +378,17 @@ export default class TasksManager {
387378
signature.stoppedAt !== undefined;
388379

389380
if (status) {
390-
await refineContacts(task.userId);
391-
await mailMiningComplete(miningId);
381+
// Signal to indicate the mining is completed
382+
try {
383+
await promise;
384+
await refineContacts(task.userId);
385+
await mailMiningComplete(miningId);
386+
} catch (err) {
387+
logger.error('Edge-functions failed');
388+
}
389+
this.ACTIVE_MINING_TASKS.delete(miningId);
390+
progressHandlerSSE.sendSSE('mining-completed', 'mining-completed');
391+
progressHandlerSSE.stop();
392392
}
393393
} catch (error) {
394394
logger.error('Error when deleting task', error);

frontend/src/components/Mining/StepperPanels/CleanPanel.vue

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
icon-pos="right"
2626
severity="danger"
2727
outlined
28+
:loading="$leadminerStore.isLoadingStopMining"
2829
:label="t('halt_cleaning')"
2930
@click="haltCleaning"
3031
/>
@@ -93,8 +94,6 @@ onMounted(() => {
9394
});
9495
9596
async function haltCleaning() {
96-
$leadminerStore.isLoadingStopMining = true;
97-
9897
try {
9998
await $leadminerStore.stopMining(true, null);
10099
$toast.add({
@@ -103,9 +102,7 @@ async function haltCleaning() {
103102
detail: t('cleaning_canceled'),
104103
life: 3000,
105104
});
106-
$leadminerStore.isLoadingStopMining = false;
107105
} catch (error) {
108-
$leadminerStore.isLoadingStopMining = false;
109106
if (error instanceof FetchError && error.response?.status === 404) {
110107
$toast.add({
111108
severity: 'warn',

frontend/src/components/Mining/StepperPanels/MinePanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
<Button
5656
v-else
5757
id="mine-stepper-stop-button"
58-
:loading="$leadminerStore?.isLoadingStartMining"
58+
:loading="$leadminerStore?.isLoadingStopMining"
5959
icon="pi pi-stop"
6060
icon-pos="right"
6161
severity="danger"
@@ -235,6 +235,7 @@ const { isSupported, permissionGranted, show } = useWebNotification({
235235
});
236236
237237
watch(extractionFinished, async (finished) => {
238+
console.log('im heeeeeeeeeeere', finished)
238239
if (canceled.value) {
239240
$toast.add({
240241
severity: 'info',
@@ -243,7 +244,6 @@ watch(extractionFinished, async (finished) => {
243244
life: 3000,
244245
});
245246
$stepper.next();
246-
await reloadContacts();
247247
} else if (finished) {
248248
$toast.add({
249249
severity: 'info',

frontend/src/stores/leadminer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,9 +393,9 @@ export const useLeadminerStore = defineStore('leadminer', () => {
393393
miningTask.value = undefined;
394394
fetchingFinished.value = true;
395395
cleaningFinished.value = true;
396-
isLoadingStopMining.value = false;
397396
}
398397
extractionFinished.value = true;
398+
isLoadingStopMining.value = false;
399399
} catch (err) {
400400
fetchingFinished.value = true;
401401
extractionFinished.value = true;

0 commit comments

Comments
 (0)