Sort schedule blocks by start time instead of order_index
Backend queries and model relationship now order by time_start. Frontend also sorts blocks client-side for reliability across all views. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -24,9 +24,16 @@ export const useScheduleStore = defineStore('schedule', () => {
|
||||
return Math.round((completedBlockIds.value.length / blocks.value.length) * 100)
|
||||
})
|
||||
|
||||
function sortBlocksByTime(arr) {
|
||||
return (arr || []).slice().sort((a, b) => {
|
||||
const toMin = (t) => { if (!t) return 0; const [h, m] = t.split(':').map(Number); return h * 60 + m }
|
||||
return toMin(a.time_start) - toMin(b.time_start)
|
||||
})
|
||||
}
|
||||
|
||||
function applySnapshot(snapshot) {
|
||||
session.value = snapshot.session
|
||||
blocks.value = snapshot.blocks || []
|
||||
blocks.value = sortBlocksByTime(snapshot.blocks)
|
||||
completedBlockIds.value = snapshot.completed_block_ids || []
|
||||
isPaused.value = false
|
||||
if (snapshot.child) child.value = snapshot.child
|
||||
|
||||
Reference in New Issue
Block a user