fix sync task record that reset every times
This commit is contained in:
@@ -39,15 +39,16 @@ const duration = computed(() => {
|
||||
return null
|
||||
}
|
||||
|
||||
// When in pause, it can happen to
|
||||
// have a tick where now is behind new Date().
|
||||
const mostRecentDate = new Date(
|
||||
Math.max(new Date(now.value).getTime(), new Date().getTime())
|
||||
const compareDate = new Date(
|
||||
record.value?.breakTime?.start ??
|
||||
// When in pause, it can happen to
|
||||
// have a tick where now is behind new Date().
|
||||
Math.max(new Date(now.value).getTime(), new Date().getTime())
|
||||
)
|
||||
|
||||
return formatDiffInMinutes(
|
||||
stepRecord.value.start,
|
||||
stepRecord.value?.end ?? toISODate(new Date(mostRecentDate))
|
||||
stepRecord.value?.end ?? toISODate(new Date(compareDate))
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ export const useTaskRecordStore = defineStore('task-record-store', {
|
||||
}),
|
||||
actions: {
|
||||
syncTaskRecord(task: Task) {
|
||||
if (!(task.id in this.records)) {
|
||||
const isTaskRecorded = task.id in this.records
|
||||
|
||||
if (!isTaskRecorded) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -26,13 +28,11 @@ export const useTaskRecordStore = defineStore('task-record-store', {
|
||||
const taskRecordStepIds = Object.keys(record.stepRecords)
|
||||
const taskStepIds = new Set(task.steps.map((step) => step.id))
|
||||
|
||||
const hasSameSteps =
|
||||
taskRecordStepIds.length === taskStepIds.size &&
|
||||
taskRecordStepIds.every((taskRecordStepId) =>
|
||||
taskStepIds.has(taskRecordStepId)
|
||||
)
|
||||
const hasRecordedStepsStillInTask = taskRecordStepIds.every(
|
||||
(taskRecordStepId) => taskStepIds.has(taskRecordStepId)
|
||||
)
|
||||
|
||||
if (!hasSameSteps) {
|
||||
if (!hasRecordedStepsStillInTask) {
|
||||
this.records[task.id] = new TaskRecord(task.id)
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user