fix: handle edge cases in duration editing
- Use $patch for proper Pinia reactivity when updating step duration - Only adjust current step's start time if new end is in the past Fixes #8
This commit is contained in:
@@ -241,13 +241,32 @@ export const useTaskRecordStore = defineStore('task-record-store', {
|
|||||||
startMs + params.newDurationMinutes * unitMultiplier * 1000
|
startMs + params.newDurationMinutes * unitMultiplier * 1000
|
||||||
const newEnd = toISODate(new Date(newEndMs))
|
const newEnd = toISODate(new Date(newEndMs))
|
||||||
|
|
||||||
// Adjust current step's start time for continuity
|
// Build updated step records
|
||||||
const currentStepId = record.currentStepId
|
const updatedStepRecords = { ...record.stepRecords }
|
||||||
if (currentStepId && record.stepRecords[currentStepId]) {
|
updatedStepRecords[params.stepId] = {
|
||||||
record.stepRecords[currentStepId].start = newEnd
|
...stepRecord,
|
||||||
|
end: newEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
stepRecord.end = newEnd
|
// Adjust current step's start time for continuity, but only if new end is in the past
|
||||||
|
const currentStepId = record.currentStepId
|
||||||
|
const isNewEndInPast = newEndMs <= Date.now()
|
||||||
|
if (currentStepId && updatedStepRecords[currentStepId] && isNewEndInPast) {
|
||||||
|
updatedStepRecords[currentStepId] = {
|
||||||
|
...updatedStepRecords[currentStepId],
|
||||||
|
start: newEnd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$patch({
|
||||||
|
records: {
|
||||||
|
...this.records,
|
||||||
|
[params.taskId]: {
|
||||||
|
...record,
|
||||||
|
stepRecords: updatedStepRecords
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getters: {
|
getters: {
|
||||||
|
|||||||
Reference in New Issue
Block a user