fix(launcher): sort presentations by priority > sort > start_datetime > code > name
Replaced single-field sortBy() (poster→name, oral→start_datetime) with toArray() + JS comparator matching the same sort chain as Pres Mgmt. Removes the sort_by branch since the comparator handles both session types. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -90,11 +90,12 @@ let lq__event_file_obj_li = $derived.by(() => {
|
||||
});
|
||||
|
||||
// Event Presentation
|
||||
// WHY: $derived.by — same reason as above. Captures both id and sort_by in the outer
|
||||
// closure so a new Observable is created whenever the session or its type changes.
|
||||
// WHY: $derived.by — captures id in the outer closure so a new Observable is
|
||||
// created whenever the session changes. Multi-field sort requires toArray() + JS
|
||||
// comparator since Dexie's sortBy() is single-field only.
|
||||
// Order: priority DESC → sort ASC → start_datetime ASC → code ASC → name ASC
|
||||
let lq__event_presentation_obj_li = $derived.by(() => {
|
||||
const id = slct__event_session_id;
|
||||
const sort_by = type_code == 'poster' ? 'name' : 'start_datetime';
|
||||
return liveQuery(async () => {
|
||||
if (!id) return [];
|
||||
|
||||
@@ -102,10 +103,32 @@ let lq__event_presentation_obj_li = $derived.by(() => {
|
||||
console.log(`[LQ] Fetching presentations for session: ${id}`);
|
||||
}
|
||||
|
||||
return await db_events.presentation
|
||||
const results = await db_events.presentation
|
||||
.where('event_session_id')
|
||||
.equals(id)
|
||||
.sortBy(sort_by);
|
||||
.toArray();
|
||||
return results.sort((a, b) => {
|
||||
// priority DESC (true first)
|
||||
const pa = a.priority ? 1 : 0;
|
||||
const pb = b.priority ? 1 : 0;
|
||||
if (pb !== pa) return pb - pa;
|
||||
// sort ASC
|
||||
const sa = a.sort ?? 0;
|
||||
const sb = b.sort ?? 0;
|
||||
if (sa !== sb) return sa - sb;
|
||||
// start_datetime ASC
|
||||
const da = a.start_datetime ?? '';
|
||||
const db_val = b.start_datetime ?? '';
|
||||
if (da !== db_val) return da < db_val ? -1 : 1;
|
||||
// code ASC
|
||||
const ca = a.code ?? '';
|
||||
const cb = b.code ?? '';
|
||||
if (ca !== cb) return ca < cb ? -1 : 1;
|
||||
// name ASC
|
||||
const na = a.name ?? '';
|
||||
const nb = b.name ?? '';
|
||||
return na < nb ? -1 : na > nb ? 1 : 0;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user