mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2025-12-24 02:39:18 -05:00
fix(mediarequests): properly sort season numbers in media requests (#1688)
Added an @AfterLoad() hook in MediaRequest to ensure seasons are always ordered by their ID. Previously, joinedseasons could appear in arbitrary database order, leading to jumbled UI displays. With this change,the seasons list is automatically re-sorted in ascending ID order as soon as TypeORM hydrates theentity. fix #1336
This commit is contained in:
@@ -17,6 +17,7 @@ import { DbAwareColumn } from '@server/utils/DbColumnHelper';
|
||||
import { truncate } from 'lodash';
|
||||
import {
|
||||
AfterInsert,
|
||||
AfterLoad,
|
||||
AfterUpdate,
|
||||
Column,
|
||||
Entity,
|
||||
@@ -701,6 +702,13 @@ export class MediaRequest {
|
||||
}
|
||||
}
|
||||
|
||||
@AfterLoad()
|
||||
private sortSeasons() {
|
||||
if (Array.isArray(this.seasons)) {
|
||||
this.seasons.sort((a, b) => a.id - b.id);
|
||||
}
|
||||
}
|
||||
|
||||
static async sendNotification(
|
||||
entity: MediaRequest,
|
||||
media: Media,
|
||||
|
||||
Reference in New Issue
Block a user