fix: Old Reolink media items shown instead of more recent ones (#2081)

- Closes: #2078
This commit is contained in:
Dermot Duffy
2025-06-02 20:55:09 -07:00
committed by GitHub
parent 956a2e523c
commit a3d062eec5
3 changed files with 112 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
import { orderBy } from 'lodash-es';
import { BrowseMediaMetadata, RichBrowseMedia } from './types';
// Unlike sorting of view items (see card-controller/view/sort.ts), for browse
// media we often need to sort by most recent first to apply an item count
// cutoff from the most recent (this differs from how items may be sorted prior
// to presentation).
//
// See: https://github.com/dermotduffy/advanced-camera-card/issues/2078
export const sortMostRecentFirst = (
media: RichBrowseMedia<BrowseMediaMetadata>[],
): RichBrowseMedia<BrowseMediaMetadata>[] => {
return orderBy(media, (media) => media._metadata?.startDate, 'desc');
};