Skip to content

Commit

Permalink
Season order fix and episode React keys are now unique (#585)
Browse files Browse the repository at this point in the history
* Season order fix and episode React keys are now unique

* Move season sorting to backend rather than frontend
  • Loading branch information
niamu authored Nov 29, 2023
1 parent ff29114 commit a36fabb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion dim-database/src/season.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ impl Season {
) -> Result<Vec<Self>, DatabaseError> {
Ok(sqlx::query_as!(
Self,
r#"SELECT id as "id!", season_number, tvshowid, added, poster as "poster?" FROM season WHERE tvshowid = ?"#,
r#"SELECT id as "id!", season_number, tvshowid, added, poster as "poster?"
FROM season
WHERE tvshowid = ?
ORDER BY season_number ASC"#,
tv_id
)
.fetch_all(&mut *conn)
Expand Down
4 changes: 2 additions & 2 deletions ui/src/Pages/Media/Episodes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ function MediaEpisodes(props) {
{episodes.length === 0 && <p className="desc">Empty</p>}
{episodes.length > 0 && (
<div className="episodes" ref={episodesDiv}>
{episodes.map((ep, i) => (
{episodes.map((ep) => (
<SelectMediaFile
key={i}
key={ep.id}
title={`Episode ${ep.episode}`}
mediaID={ep.id}
>
Expand Down
4 changes: 2 additions & 2 deletions ui/src/Pages/Media/Seasons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ function MediaSeasons(props) {
<section>
<h2>Seasons</h2>
<div className={`seasons ${season && "selected"}`}>
{seasons.map(({ id, season_number, poster }, i) => (
{seasons.map(({ id, season_number, poster }) => (
<div
className={`season ${id === season && "active"}`}
key={i}
key={id}
onClick={() => setSeason(id)}
>
<CardImage src={poster} />
Expand Down

0 comments on commit a36fabb

Please sign in to comment.