Skip to content

Commit

Permalink
2314: sort playlists based on weight (or else drag and drop does not …
Browse files Browse the repository at this point in the history
…make any sense)
  • Loading branch information
sinejespersen committed Oct 23, 2024
1 parent 11bbeb1 commit f10897b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ All notable changes to this project will be documented in this file.
- Change bootstrap column class from `col-md-8` -> `col-md-12`
- update api.generated.ts to match [related pr](https://github.com/os2display/display-api-service/pull/213)
- Add @rtk-incubator/rtk-query-codegen-openapi to package.json in `src/redux/api`
- Sort playlists based on weight in drag/drop component

## [2.1.0] - 2024-10-23

Expand Down
10 changes: 6 additions & 4 deletions src/components/playlist-drag-and-drop/playlist-drag-and-drop.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ function PlaylistDragAndDrop({
if (selectedPlaylistsByRegion) {
setTotalItems(selectedPlaylistsByRegion["hydra:totalItems"]);
const newPlaylists = selectedPlaylistsByRegion["hydra:member"].map(
({ playlist }) => {
return playlist;
}
({ playlist, weight }) => ({ ...playlist, weight })
);

setSelectedData([...selectedData, ...newPlaylists]);
const selected = [...selectedData, ...newPlaylists].sort(
(a, b) => a.weight - b.weight
);

setSelectedData(selected);
callbackToinitializePlaylists(selectedPlaylistsByRegion);
}
}, [selectedPlaylistsByRegion]);
Expand Down

0 comments on commit f10897b

Please sign in to comment.