Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Playlist view crashes when media list is undefined #922

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,18 @@ export function PlaylistsSelection(props) {
let ret = [];
let i = 0;
while (i < playlists.length) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mgogoulos media_list is undefined for playlists with no media. This causes issues anytime this function is called and makes the playlist functionality non deterministic

const playlist = playlists[i];
const mediaList = playlist.media_list;
const isChecked = mediaList ? mediaList.indexOf(mediaId) !== -1 : false;

ret.push(
<div key={'playlist_' + playlists[i].playlist_id}>
<div key={'playlist_' + playlist.playlist_id}>
<PlaylistsSingleSelection
renderDate={date}
title={playlists[i].title}
privacy={playlists[i].status}
isChecked={-1 < playlists[i].media_list.indexOf(mediaId)}
playlistId={playlists[i].playlist_id}
title={playlist.title}
privacy={playlist.status}
isChecked={isChecked}
playlistId={playlist.playlist_id}
/>
</div>
);
Expand Down