Skip to content

Commit

Permalink
feat: remove playlist duplicates
Browse files Browse the repository at this point in the history
closes #87
  • Loading branch information
MSOB7YY committed Jan 6, 2024
1 parent f7f20db commit 45c16d5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions lib/ui/dialogs/general_popup_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,19 @@ Future<void> showGeneralPopupDialog(
);
}

Future<void> removePlaylistDuplicates() async {
if (!shoulShowPlaylistUtils()) return;
final pl = PlaylistController.inst.getPlaylist(playlistName!);
if (pl == null) return;
final removed = pl.tracks.removeDuplicates((element) => element.track);
await PlaylistController.inst.updatePropertyInPlaylist(pl.name, modifiedDate: currentTimeMS);
await PlaylistController.inst.onPlaylistTracksChanged(pl); // to write m3u
snackyy(
icon: Broken.filter_remove,
message: "${lang.REMOVED} ${removed.displayTrackKeyword}",
);
}

Future<void> exportPlaylist() async {
// function button won't be visible if playlistName == null.
if (!shoulShowPlaylistUtils()) return;
Expand Down Expand Up @@ -573,6 +586,18 @@ Future<void> showGeneralPopupDialog(
const SizedBox(width: 8.0),
Expanded(child: bigIcon(Broken.edit_2, lang.RENAME_PLAYLIST, renamePlaylist)),
const SizedBox(width: 8.0),
Expanded(
child: bigIcon(
Broken.edit_2,
lang.REMOVE_DUPLICATES,
removePlaylistDuplicates,
iconWidget: const StackedIcon(
baseIcon: Broken.copy,
secondaryIcon: Broken.broom,
),
),
),
const SizedBox(width: 8.0),
Expanded(child: bigIcon(Broken.pen_remove, lang.DELETE_PLAYLIST, deletePlaylist)),
if (PlaylistController.inst.getPlaylist(playlistName ?? '')?.m3uPath == null) ...[
const SizedBox(width: 8.0),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies:
playlist_manager:
git:
url: https://github.com/namidaco/playlist_manager
ref: 35f89cbf7048bac92f0594a9ed2fc27696a81a89
ref: 8ddc4ac8476d0960016f73fd7d2d50dcaf754245
history_manager:
git:
url: https://github.com/namidaco/history_manager
Expand Down

0 comments on commit 45c16d5

Please sign in to comment.