mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-21 09:49:29 +00:00
make the copied playlist name unique
Changelog: changed
This commit is contained in:
parent
f86fb0ee44
commit
dd1c04bea1
2 changed files with 10 additions and 3 deletions
|
@ -170,7 +170,14 @@ class PlaylistFragment : MainFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun copyPlaylist(playlist: Playlist) {
|
private fun copyPlaylist(playlist: Playlist) {
|
||||||
StatePlaylists.instance.playlistStore.save(playlist.makeCopy())
|
var copyNumber = 1
|
||||||
|
var newName = "${playlist.name} (Copy)"
|
||||||
|
val playlists = StatePlaylists.instance.playlistStore.getItems()
|
||||||
|
while (playlists.any { it.name == newName }) {
|
||||||
|
copyNumber += 1
|
||||||
|
newName = "${playlist.name} (Copy $copyNumber)"
|
||||||
|
}
|
||||||
|
StatePlaylists.instance.playlistStore.save(playlist.makeCopy(newName))
|
||||||
UIDialogs.toast("Playlist copied")
|
UIDialogs.toast("Playlist copied")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,8 @@ class Playlist {
|
||||||
this.videos = ArrayList(list);
|
this.videos = ArrayList(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
fun makeCopy(): Playlist {
|
fun makeCopy(newName: String? = null): Playlist {
|
||||||
return Playlist("$name (Copy)", videos)
|
return Playlist(newName ?: name, videos)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue