Skip to content
Permalink
Browse files

Work around a strangely missing count(where:)

  • Loading branch information...
saagarjha committed May 24, 2019
1 parent 9c0b2a5 commit c2088f5395dfc7e6161b2a3dabea419142665e2d
Showing with 8 additions and 6 deletions.
  1. +8 −6 iina/PlaylistViewController.swift
@@ -706,16 +706,18 @@ class PlaylistViewController: NSViewController, NSTableViewDataSource, NSTableVi

result.addItem(NSMenuItem.separator())
// network resources related operations
let count_network = rows.count (where: {player.info.playlist[$0].isNetworkResource})
if count_network != 0 {
let networkCount = rows.filter {
player.info.playlist[$0].isNetworkResource
}.count
if networkCount != 0 {
result.addItem(withTitle: NSLocalizedString("pl_menu.browser", comment: "Open in Browser"), action: #selector(self.contextOpenInBrowser(_:)))
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(withTitle: NSLocalizedString(networkCount == 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
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(_:)))
let localCount = rows.count - networkCount
if localCount != 0 {
result.addItem(withTitle: NSLocalizedString(localCount == 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(_:)))

0 comments on commit c2088f5

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