Standardized robust chronological sorting across modules.

Updated '_process_generic_props' in multiple libraries to ensure 'updated' timestamp always falls back to 'created_on' or epoch start, preventing null values from breaking newest-first ordering in IndexedDB.

Aligned Recovery Meetings and Archives list views to use these pre-computed sort keys for consistent UI behavior even when 'updated_on' is null.
This commit is contained in:
Scott Idem
2026-02-16 15:40:00 -05:00
parent fdfba0f752
commit f34e24aa02
8 changed files with 32 additions and 27 deletions

View File

@@ -143,21 +143,15 @@
})
.toArray();
// Sort local results matching UI selection
// Sort local results matching UI selection (Refactored 2026-02-16)
if ($idaa_loc.recovery_meetings.qry__order_by === 'name') {
local_results.sort((a, b) =>
(a.name ?? '').localeCompare(b.name ?? '')
);
} else {
local_results.sort((a, b) => {
const dateA = a.updated_on
? new Date(a.updated_on).getTime()
: 0;
const dateB = b.updated_on
? new Date(b.updated_on).getTime()
: 0;
return dateB - dateA;
});
// Robust Chronological Sort using pre-computed tmp_sort_1
// Handles Priority, Manual Sort, and the updated_on/created_on fallback
local_results.sort((a, b) => (b.tmp_sort_1 ?? '').localeCompare(a.tmp_sort_1 ?? ''));
}
local_ids = local_results
@@ -226,6 +220,13 @@
return true;
});
// RE-SORT: Ensure perfect chronological order even if API puts NULLs last (Refactored 2026-02-16)
if ($idaa_loc.recovery_meetings.qry__order_by === 'name') {
api_results.sort((a, b) => (a.name ?? '').localeCompare(b.name ?? ''));
} else {
api_results.sort((a, b) => (b.tmp_sort_1 ?? '').localeCompare(a.tmp_sort_1 ?? ''));
}
const api_ids = api_results
.map((e: any) => String(e.id))
.filter(Boolean);