Skip to content

Commit

Permalink
Use start attribute for sorting (#1148)
Browse files Browse the repository at this point in the history
The weird ordering occurred because we used createdAt for sorting. To fix this issue, use the start attribute.
  • Loading branch information
MatthiasReumann authored Aug 30, 2023
1 parent 2b0e72f commit c21c40f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions web/ts/data-store/stream-playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export class StreamPlaylistProvider extends StreamableMapProvider<number, Stream
const result = await StreamPlaylist.get(streamId);
return result
.map((e) => {
e.createdAtDate = new Date(e.createdAt);
e.startDate = new Date(e.start);
return e;
})
.sort((a, b) => a.createdAtDate.getTime() - b.createdAtDate.getTime());
.sort((a, b) => (a.startDate < b.startDate ? -1 : 1));
}
}

Expand All @@ -23,7 +23,7 @@ export type StreamPlaylistEntry = {
createdAt: string;

// Client Generated
createdAtDate: Date;
startDate: Date;
};

const StreamPlaylist = {
Expand Down

0 comments on commit c21c40f

Please sign in to comment.