Skip to content
Permalink
Browse files

Fix playlist order when files being dragged into playlist

Ref: #2336
  • Loading branch information...
alejx committed Feb 28, 2019
1 parent 4473128 commit aa34c3f43a08c18cb29a24c78a11bf2b4fdd3193
Showing with 3 additions and 7 deletions.
  1. +1 −5 iina/DraggingDetect.swift
  2. +1 −1 iina/PlayerCore.swift
  3. +1 −1 iina/PlaylistViewController.swift
@@ -44,10 +44,9 @@ extension PlayerCore {
- Parameters:
- urls: The list as an array of `URL`.
- sorted: Whether the return array is sorted and deduplicated
- Returns: URLs of all playable files as an array of `URL`.
*/
func getPlayableFiles(in urls: [URL], sorted: Bool = false) -> [URL] {
func getPlayableFiles(in urls: [URL]) -> [URL] {
var playableFiles: [URL] = []
for url in urls {
if !url.isFileURL {
@@ -71,9 +70,6 @@ extension PlayerCore {
}
}
}
if !sorted {
return playableFiles
}
return Array(Set(playableFiles)).sorted { url1, url2 in
let folder1 = url1.deletingLastPathComponent(), folder2 = url2.deletingLastPathComponent()
if folder1.absoluteString == folder2.absoluteString {
@@ -184,7 +184,7 @@ class PlayerCore: NSObject {
return nil
}

let playableFiles = getPlayableFiles(in: urls, sorted: true)
let playableFiles = getPlayableFiles(in: urls)
let count = playableFiles.count

// check playable files count
@@ -352,7 +352,7 @@ class PlaylistViewController: NSViewController, NSTableViewDataSource, NSTableVi

@IBAction func addFileAction(_ sender: AnyObject) {
Utility.quickMultipleOpenPanel(title: "Add to playlist", canChooseDir: true) { urls in
let playableFiles = self.player.getPlayableFiles(in: urls, sorted: true)
let playableFiles = self.player.getPlayableFiles(in: urls)
if playableFiles.count != 0 {
self.player.addToPlaylist(paths: playableFiles.map { $0.path }, at: self.player.info.playlist.count)
self.player.mainWindow.playlistView.reloadData(playlist: true, chapters: false)

4 comments on commit aa34c3f

@anohren

This comment has been minimized.

Copy link
Contributor

anohren replied Mar 1, 2019

Will this affect the order of playlist files' entries when added to the playlist? Since they're an exception and shouldn't have their contents sorted.

@alejx

This comment has been minimized.

Copy link
Member Author

alejx replied Mar 1, 2019

Why not? Only newly added files will get sorted.

@anohren

This comment has been minimized.

Copy link
Contributor

anohren replied Mar 1, 2019

Is the question why items in playlist files should not get rearranged when added? Because a playlist file doesn't just represent a set of items to be played, but a list of items to be played in a particular order. The ordering is an inherent property of a playlist file.

@alejx

This comment has been minimized.

Copy link
Member Author

alejx replied Mar 2, 2019

Got your point. No, entires in playlist files are not re-arranged.

Please sign in to comment.
You can’t perform that action at this time.