Skip to content
Permalink
Browse files

Check single based on qualified items instead of number of selected rows

  • Loading branch information...
alejx committed Feb 7, 2019
1 parent 0595aba commit 6f65389844cea6f813b71d730c733d32ccd66e41
Showing with 6 additions and 4 deletions.
  1. +6 −4 iina/PlaylistViewController.swift
@@ -706,14 +706,16 @@ class PlaylistViewController: NSViewController, NSTableViewDataSource, NSTableVi

result.addItem(NSMenuItem.separator())
// network resources related operations
if rows.contains (where: {player.info.playlist[$0].isNetworkResource}) {
let count_network = rows.count (where: {player.info.playlist[$0].isNetworkResource})
if count_network != 0 {
result.addItem(withTitle: NSLocalizedString("pl_menu.browser", comment: "Open in Browser"), action: #selector(self.contextOpenInBrowser(_:)))
result.addItem(withTitle: NSLocalizedString(isSingleItem ? "pl_menu.copy_url" : "pl_menu.copy_url_multi", comment: "Copy URL(s)"), action: #selector(self.contextCopyURL(_:)))
result.addItem(withTitle: NSLocalizedString(count_network == 1 ? "pl_menu.copy_url" : "pl_menu.copy_url_multi", comment: "Copy URL(s)"), action: #selector(self.contextCopyURL(_:)))
result.addItem(NSMenuItem.separator())
}
// file related operations
if rows.contains (where: {!player.info.playlist[$0].isNetworkResource}) {
result.addItem(withTitle: NSLocalizedString(isSingleItem ? "pl_menu.delete" : "pl_menu.delete_multi", comment: "Delete"), action: #selector(self.contextMenuDeleteFile(_:)))
let count_non_network = rows.count - count_network
if count_non_network != 0 {
result.addItem(withTitle: NSLocalizedString(count_non_network == 1 ? "pl_menu.delete" : "pl_menu.delete_multi", comment: "Delete"), action: #selector(self.contextMenuDeleteFile(_:)))
// result.addItem(withTitle: NSLocalizedString(isSingleItem ? "pl_menu.delete_after_play" : "pl_menu.delete_after_play_multi", comment: "Delete After Playback"), action: #selector(self.contextMenuDeleteFileAfterPlayback(_:)))
result.addItem(withTitle: NSLocalizedString("pl_menu.reveal_in_finder", comment: "Reveal in Finder"), action: #selector(self.contextMenuRevealInFinder(_:)))

2 comments on commit 6f65389

@Noctem

This comment has been minimized.

Copy link

replied May 24, 2019

@saagarjha

This comment has been minimized.

Copy link
Member

replied May 24, 2019

Thanks; apparently count(where:)'s implementation was pulled so I replaced it with filter/count instead.

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