Commit 19b89264 authored by Carola's avatar Carola Committed by Felix Paul Kühne
Browse files

library: fix removing shows and albums (close #10043)


Signed-off-by: Felix Paul Kühne's avatarFelix Paul Kühne <fkuehne@videolan.org>
parent 23b9f70a
......@@ -347,8 +347,36 @@
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
[self removeMediaObject: _foundMedia[indexPath.row]];
if (editingStyle == UITableViewCellEditingStyleDelete) {
//Delete all tracks from an album
if ([_foundMedia[indexPath.row] isKindOfClass:[MLAlbum class]]) {
MLAlbum *album = _foundMedia[indexPath.row];
NSSet *iterAlbumTrack = [NSSet setWithSet:album.tracks];
for (MLAlbumTrack *track in iterAlbumTrack) {
NSSet *iterFiles = [NSSet setWithSet:track.files];
for (MLFile *file in iterFiles) {
[self removeMediaObject:file];
}
}
//Delete all episodes from a show
} else if ([_foundMedia[indexPath.row] isKindOfClass:[MLShow class]]) {
MLShow *show = _foundMedia[indexPath.row];
NSSet *iterShowEpisodes = [NSSet setWithSet:show.episodes];
for (MLShowEpisode *episode in iterShowEpisodes) {
NSSet *iterFiles = [NSSet setWithSet:episode.files];
for (MLFile *file in iterFiles) {
[self removeMediaObject:file];
}
}
//everything else
} else {
[self removeMediaObject: _foundMedia[indexPath.row]];
}
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment