|
497 | 497 | hour12: false, |
498 | 498 | }); |
499 | 499 | }, |
500 | | - async handleStartTimer() { |
501 | | - if (!this.task.id || this.isLoadingTimer) return; |
| 500 | + async handleStartTimer() { |
| 501 | + if (!this.task.id || this.isLoadingTimer) return; |
502 | 502 |
|
503 | | - this.isLoadingTimer = true; |
504 | | - try { |
505 | | - const updatedTask = await startTaskTimeCounter(this.task.id); |
506 | | - Object.assign(this.task, updatedTask); |
507 | | - this.$store.commit('incrementReloadTasksKey'); |
508 | | - this.$emit('timer-started', updatedTask); |
| 503 | + this.isLoadingTimer = true; |
| 504 | + try { |
| 505 | + const updatedTask = await startTaskTimeCounter(this.task.id); |
| 506 | + Object.assign(this.task, updatedTask); |
| 507 | + this.$store.commit('updateSingleTask', updatedTask); |
| 508 | + this.$emit('timer-started', updatedTask); |
509 | 509 |
|
510 | | - const taskStatus = this.statuses.find( |
511 | | - (s) => s.id === this.task.status_id, |
512 | | - ); |
513 | | - if (taskStatus && taskStatus.type === 'default') { |
514 | | - const activeStatus = this.statuses.find((s) => s.type === 'active'); |
515 | | - if (activeStatus) { |
516 | | - const shouldSwitch = confirm( |
517 | | - `Task "${this.task.title}" is in backlog. Switch to "${activeStatus.name}" status?`, |
518 | | - ); |
519 | | - if (shouldSwitch) { |
520 | | - await updateTaskStatus(this.task.id, activeStatus.id); |
521 | | - this.task.status_id = activeStatus.id; |
522 | | - this.$store.commit('incrementReloadTasksKey'); |
523 | | - } |
| 510 | + const taskStatus = this.statuses.find( |
| 511 | + (s) => s.id === this.task.status_id, |
| 512 | + ); |
| 513 | + if (taskStatus && taskStatus.type === 'default') { |
| 514 | + const activeStatus = this.statuses.find((s) => s.type === 'active'); |
| 515 | + if (activeStatus) { |
| 516 | + const shouldSwitch = confirm( |
| 517 | + `Task "${this.task.title}" is in backlog. Switch to "${activeStatus.name}" status?`, |
| 518 | + ); |
| 519 | + if (shouldSwitch) { |
| 520 | + await updateTaskStatus(this.task.id, activeStatus.id); |
| 521 | + this.task.status_id = activeStatus.id; |
| 522 | + this.$store.commit('updateSingleTask', this.task); |
524 | 523 | } |
525 | 524 | } |
526 | | - } catch (e) { |
527 | | - console.error('Failed to start timer:', e); |
528 | | - } finally { |
529 | | - this.isLoadingTimer = false; |
530 | 525 | } |
531 | | - }, |
532 | | - async handleStopTimer() { |
533 | | - if (!this.task.id || this.isLoadingTimer) return; |
| 526 | + } catch (e) { |
| 527 | + console.error('Failed to start timer:', e); |
| 528 | + } finally { |
| 529 | + this.isLoadingTimer = false; |
| 530 | + } |
| 531 | + }, |
| 532 | + async handleStopTimer() { |
| 533 | + if (!this.task.id || this.isLoadingTimer) return; |
534 | 534 |
|
535 | | - this.isLoadingTimer = true; |
536 | | - try { |
537 | | - const updatedTask = await stopTaskTimeCounter(this.task.id); |
538 | | - Object.assign(this.task, updatedTask); |
539 | | - this.$store.commit('incrementReloadTasksKey'); |
540 | | - this.$emit('timer-stopped', updatedTask); |
541 | | - } catch (e) { |
542 | | - console.error('Failed to stop timer:', e); |
543 | | - } finally { |
544 | | - this.isLoadingTimer = false; |
545 | | - } |
546 | | - }, |
| 535 | + this.isLoadingTimer = true; |
| 536 | + try { |
| 537 | + const updatedTask = await stopTaskTimeCounter(this.task.id); |
| 538 | + Object.assign(this.task, updatedTask); |
| 539 | + this.$store.commit('updateSingleTask', updatedTask); |
| 540 | + this.$emit('timer-stopped', updatedTask); |
| 541 | + } catch (e) { |
| 542 | + console.error('Failed to stop timer:', e); |
| 543 | + } finally { |
| 544 | + this.isLoadingTimer = false; |
| 545 | + } |
| 546 | + }, |
547 | 547 | updateTimer() { |
548 | 548 | if (!this.task.start_time) { |
549 | 549 | return; |
|
0 commit comments