Fix lint issues.
This commit is contained in:
parent
8f1379360c
commit
40ada2ba5a
@ -105,8 +105,7 @@ final class AppDefaults {
|
||||
if let appGroupID = Bundle.main.object(forInfoDictionaryKey: "AppGroup") as? String,
|
||||
let appGroupDefaults = UserDefaults(suiteName: appGroupID) {
|
||||
return appGroupDefaults
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return UserDefaults.standard
|
||||
}
|
||||
}
|
||||
@ -427,8 +426,7 @@ private extension AppDefaults {
|
||||
static func setSortDirection(for key: String, _ value: ComparisonResult) {
|
||||
if value == .orderedAscending {
|
||||
setInt(for: key, ComparisonResult.orderedAscending.rawValue)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
setInt(for: key, ComparisonResult.orderedDescending.rawValue)
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,7 @@ import Sparkle
|
||||
var appDelegate: AppDelegate!
|
||||
|
||||
@NSApplicationMain
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider, SPUStandardUserDriverDelegate, SPUUpdaterDelegate
|
||||
{
|
||||
class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, UNUserNotificationCenterDelegate, UnreadCountProvider, SPUStandardUserDriverDelegate, SPUUpdaterDelegate {
|
||||
|
||||
private struct WindowRestorationIdentifiers {
|
||||
static let mainWindow = "mainWindow"
|
||||
@ -139,8 +138,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
let cacheFolder: String
|
||||
if let userCacheFolder = try? FileManager.default.url(for: .cachesDirectory, in: .userDomainMask, appropriateFor: nil, create: false).path {
|
||||
cacheFolder = userCacheFolder
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let bundleIdentifier = (Bundle.main.infoDictionary!["CFBundleIdentifier"]! as! String)
|
||||
cacheFolder = (NSTemporaryDirectory() as NSString).appendingPathComponent(bundleIdentifier)
|
||||
}
|
||||
@ -166,8 +164,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
|
||||
do {
|
||||
try self.softwareUpdater.start()
|
||||
}
|
||||
catch {
|
||||
} catch {
|
||||
NSLog("Failed to start software updater with error: \(error)")
|
||||
}
|
||||
|
||||
@ -214,7 +211,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
refreshTimer = AccountRefreshTimer()
|
||||
syncTimer = ArticleStatusSyncTimer()
|
||||
|
||||
UNUserNotificationCenter.current().requestAuthorization(options:[.badge]) { (granted, error) in }
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge]) { (_, _) in }
|
||||
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (settings) in
|
||||
if settings.authorizationStatus == .authorized {
|
||||
@ -298,7 +295,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
|
||||
ArticleThemeDownloader.shared.cleanUp()
|
||||
|
||||
AccountManager.shared.sendArticleStatusAll() {
|
||||
AccountManager.shared.sendArticleStatusAll {
|
||||
self.isShutDownSyncDone = true
|
||||
}
|
||||
|
||||
@ -318,7 +315,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
return
|
||||
}
|
||||
if key == Feed.FeedSettingKey.homePageURL || key == Feed.FeedSettingKey.faviconURL {
|
||||
let _ = faviconDownloader.favicon(for: feed)
|
||||
_ = faviconDownloader.favicon(for: feed)
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,8 +527,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
|
||||
if inspectorWindowController!.isOpen {
|
||||
inspectorWindowController!.window!.performClose(self)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
inspectorWindowController!.objects = objectsForInspector()
|
||||
inspectorWindowController!.showWindow(self)
|
||||
}
|
||||
@ -581,7 +577,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations,
|
||||
Browser.open(URL.releaseNotes.absoluteString, inBackground: false)
|
||||
}
|
||||
|
||||
|
||||
@IBAction func openHowToSupport(_ sender: Any?) {
|
||||
|
||||
Browser.open("https://github.com/brentsimmons/NetNewsWire/blob/main/Technotes/HowToSupportNetNewsWire.markdown", inBackground: false)
|
||||
@ -918,7 +913,7 @@ extension AppDelegate : ScriptingAppDelegate {
|
||||
extension AppDelegate: NSWindowRestoration {
|
||||
|
||||
@objc static func restoreWindow(withIdentifier identifier: NSUserInterfaceItemIdentifier, state: NSCoder, completionHandler: @escaping (NSWindow?, Error?) -> Void) {
|
||||
var mainWindow: NSWindow? = nil
|
||||
var mainWindow: NSWindow?
|
||||
if identifier.rawValue == WindowRestorationIdentifiers.mainWindow {
|
||||
mainWindow = appDelegate.createAndShowMainWindow().window
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ struct Browser {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
/// Opens a URL in the default browser.
|
||||
///
|
||||
/// - Parameters:
|
||||
@ -34,7 +33,6 @@ struct Browser {
|
||||
open(urlString, inBackground: invert ? !AppDefaults.shared.openInBrowserInBackground : AppDefaults.shared.openInBrowserInBackground)
|
||||
}
|
||||
|
||||
|
||||
/// Opens a URL in the default browser.
|
||||
///
|
||||
/// - Parameters:
|
||||
@ -52,7 +50,7 @@ struct Browser {
|
||||
configuration.activates = false
|
||||
}
|
||||
|
||||
NSWorkspace.shared.open(preparedURL, configuration: configuration) { (runningApplication, error) in
|
||||
NSWorkspace.shared.open(preparedURL, configuration: configuration) { (_, error) in
|
||||
guard error != nil else { return }
|
||||
if let defaultBrowser = defaultBrowser {
|
||||
defaultBrowser.openURL(url, inBackground: inBackground)
|
||||
|
@ -59,4 +59,3 @@ final class CrashReportWindowController: NSWindowController {
|
||||
close()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ final class FeedInspectorViewController: NSViewController, Inspector {
|
||||
self.feed?.isNotifyAboutNewArticles = (self.isNotifyAboutNewArticlesCheckBox?.state ?? .off) == .on ? true : false
|
||||
}
|
||||
} else {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in
|
||||
self.updateNotificationSettings()
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
@ -130,7 +130,6 @@ private extension FeedInspectorViewController {
|
||||
feed = singleFeed
|
||||
}
|
||||
|
||||
|
||||
@objc func updateUI() {
|
||||
updateImage()
|
||||
updateName()
|
||||
|
@ -19,7 +19,6 @@ protocol Inspector: AnyObject {
|
||||
|
||||
typealias InspectorViewController = Inspector & NSViewController
|
||||
|
||||
|
||||
final class InspectorWindowController: NSWindowController {
|
||||
|
||||
class var shouldOpenAtStartup: Bool {
|
||||
@ -28,7 +27,7 @@ final class InspectorWindowController: NSWindowController {
|
||||
|
||||
var objects: [Any]? {
|
||||
didSet {
|
||||
let _ = window
|
||||
_ = window
|
||||
currentInspector = inspector(for: objects)
|
||||
}
|
||||
}
|
||||
@ -67,21 +66,19 @@ final class InspectorWindowController: NSWindowController {
|
||||
|
||||
if let savedOrigin = originFromDefaults() {
|
||||
window?.setFlippedOriginAdjustingForScreen(savedOrigin)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
window?.flippedOrigin = NSPoint(x: 256, y: 256)
|
||||
}
|
||||
}
|
||||
|
||||
func inspector(for objects: [Any]?) -> InspectorViewController {
|
||||
|
||||
var fallbackInspector: InspectorViewController? = nil
|
||||
var fallbackInspector: InspectorViewController?
|
||||
|
||||
for inspector in inspectors {
|
||||
if inspector.isFallbackInspector {
|
||||
fallbackInspector = inspector
|
||||
}
|
||||
else if let objects = objects, inspector.canInspect(objects) {
|
||||
} else if let objects = objects, inspector.canInspect(objects) {
|
||||
return inspector
|
||||
}
|
||||
}
|
||||
|
@ -39,8 +39,7 @@ private extension NothingInspectorViewController {
|
||||
if let objects = objects, objects.count > 1 {
|
||||
nothingTextField?.isHidden = true
|
||||
multipleTextField?.isHidden = false
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
nothingTextField?.isHidden = false
|
||||
multipleTextField?.isHidden = true
|
||||
}
|
||||
|
@ -165,4 +165,3 @@ private extension AddFeedController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ final class AddFeedWindowController : NSWindowController {
|
||||
}
|
||||
|
||||
func runSheetOnWindow(_ hostWindow: NSWindow) {
|
||||
hostWindow.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
|
||||
hostWindow.beginSheet(window!) { (_: NSApplication.ModalResponse) in
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,7 +89,7 @@ final class AddFeedWindowController : NSWindowController {
|
||||
|
||||
if normalizedURLString.isEmpty {
|
||||
cancelSheet()
|
||||
return;
|
||||
return
|
||||
}
|
||||
guard let url = URL(string: normalizedURLString) else {
|
||||
cancelSheet()
|
||||
|
@ -25,7 +25,7 @@ class AddFolderWindowController : NSWindowController {
|
||||
|
||||
func runSheetOnWindow(_ w: NSWindow) {
|
||||
hostWindow = w
|
||||
hostWindow!.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) -> Void in
|
||||
hostWindow!.beginSheet(window!) { (returnCode: NSApplication.ModalResponse) in
|
||||
|
||||
if returnCode == NSApplication.ModalResponse.OK {
|
||||
self.addFolderIfNeeded()
|
||||
|
@ -38,7 +38,7 @@ final class DetailContainerView: NSView {
|
||||
|
||||
override func draw(_ dirtyRect: NSRect) {
|
||||
NSColor.controlBackgroundColor.set()
|
||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
||||
let r = dirtyRect.intersection(bounds)
|
||||
r.fill()
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,7 @@ final class DetailStatusBarView: NSView {
|
||||
if let link = linkForDisplay {
|
||||
urlLabel.stringValue = link
|
||||
self.isHidden = false
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
urlLabel.stringValue = ""
|
||||
self.isHidden = true
|
||||
}
|
||||
@ -68,11 +67,8 @@ private extension DetailStatusBarView {
|
||||
func updateLinkForDisplay() {
|
||||
if let mouseoverLink = mouseoverLink, !mouseoverLink.isEmpty {
|
||||
linkForDisplay = mouseoverLink.strippingHTTPOrHTTPSScheme
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
linkForDisplay = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -58,7 +58,7 @@ final class DetailWebView: WKWebView {
|
||||
|
||||
override func setFrameSize(_ newSize: NSSize) {
|
||||
super.setFrameSize(newSize)
|
||||
if (!inLiveResize) {
|
||||
if !inLiveResize {
|
||||
bigSurOffsetFix()
|
||||
}
|
||||
}
|
||||
@ -128,4 +128,3 @@ private extension DetailWebView {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ final class DetailWebViewController: NSViewController {
|
||||
|
||||
private var isShowingExtractedArticle: Bool {
|
||||
switch state {
|
||||
case .extracted(_, _, _):
|
||||
case .extracted:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
@ -281,7 +281,7 @@ private extension DetailWebViewController {
|
||||
}
|
||||
|
||||
func reloadHTMLMaintainingScrollPosition() {
|
||||
fetchScrollInfo() { scrollInfo in
|
||||
fetchScrollInfo { scrollInfo in
|
||||
self.windowScrollY = scrollInfo?.offsetY
|
||||
self.reloadHTML()
|
||||
}
|
||||
@ -320,7 +320,7 @@ private extension DetailWebViewController {
|
||||
func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) {
|
||||
let javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: window.pageYOffset}; x"
|
||||
|
||||
webView.evaluateJavaScript(javascriptString) { (info, error) in
|
||||
webView.evaluateJavaScript(javascriptString) { (info, _) in
|
||||
guard let info = info as? [String: Any] else {
|
||||
completion(nil)
|
||||
return
|
||||
|
@ -10,7 +10,7 @@ import AppKit
|
||||
|
||||
final class IconView: NSView {
|
||||
|
||||
var iconImage: IconImage? = nil {
|
||||
var iconImage: IconImage? {
|
||||
didSet {
|
||||
if iconImage !== oldValue {
|
||||
imageView.image = iconImage?.image
|
||||
@ -76,7 +76,7 @@ final class IconView: NSView {
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
resizeSubviews(withOldSize: NSZeroSize)
|
||||
resizeSubviews(withOldSize: NSSize.zero)
|
||||
}
|
||||
|
||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||
@ -89,7 +89,7 @@ final class IconView: NSView {
|
||||
|
||||
let color = NSApplication.shared.effectiveAppearance.isDarkMode ? IconView.darkBackgroundColor : IconView.lightBackgroundColor
|
||||
color.set()
|
||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
||||
let r = dirtyRect.intersection(bounds)
|
||||
r.fill()
|
||||
}
|
||||
}
|
||||
@ -104,7 +104,7 @@ private extension IconView {
|
||||
|
||||
func rectForImageView() -> NSRect {
|
||||
guard !(iconImage?.isSymbol ?? false) else {
|
||||
return NSMakeRect(0.0, 0.0, bounds.size.width, bounds.size.height)
|
||||
return NSRect(x: 0.0, y: 0.0, width: bounds.size.width, height: bounds.size.height)
|
||||
}
|
||||
|
||||
guard let image = iconImage?.image else {
|
||||
@ -116,22 +116,21 @@ private extension IconView {
|
||||
if imageSize.height == imageSize.width {
|
||||
if imageSize.height >= viewSize.height * 0.75 {
|
||||
// Close enough to viewSize to scale up the image.
|
||||
return NSMakeRect(0.0, 0.0, viewSize.width, viewSize.height)
|
||||
return NSRect(x: 0.0, y: 0.0, width: viewSize.width, height: viewSize.height)
|
||||
}
|
||||
let offset = floor((viewSize.height - imageSize.height) / 2.0)
|
||||
return NSMakeRect(offset, offset, imageSize.width, imageSize.height)
|
||||
}
|
||||
else if imageSize.height > imageSize.width {
|
||||
return NSRect(x: offset, y: offset, width: imageSize.width, height: imageSize.height)
|
||||
} else if imageSize.height > imageSize.width {
|
||||
let factor = viewSize.height / imageSize.height
|
||||
let width = imageSize.width * factor
|
||||
let originX = floor((viewSize.width - width) / 2.0)
|
||||
return NSMakeRect(originX, 0.0, width, viewSize.height)
|
||||
return NSRect(x: originX, y: 0.0, width: width, height: viewSize.height)
|
||||
}
|
||||
|
||||
// Wider than tall: imageSize.width > imageSize.height
|
||||
let factor = viewSize.width / imageSize.width
|
||||
let height = imageSize.height * factor
|
||||
let originY = floor((viewSize.height - height) / 2.0)
|
||||
return NSMakeRect(0.0, originY, viewSize.width, height)
|
||||
return NSRect(x: 0.0, y: originY, width: viewSize.width, height: height)
|
||||
}
|
||||
}
|
||||
|
@ -33,4 +33,3 @@ final class MainWindowKeyboardHandler: KeyboardDelegate {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
private var activityManager = ActivityManager()
|
||||
|
||||
private var isShowingExtractedArticle = false
|
||||
private var articleExtractor: ArticleExtractor? = nil
|
||||
private var articleExtractor: ArticleExtractor?
|
||||
private var sharingServicePickerDelegate: NSSharingServicePickerDelegate?
|
||||
|
||||
private let windowAutosaveName = NSWindow.FrameAutosaveName("MainWindow")
|
||||
@ -45,17 +45,17 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
private var sidebarViewController: SidebarViewController?
|
||||
private var timelineContainerViewController: TimelineContainerViewController?
|
||||
private var detailViewController: DetailViewController?
|
||||
private var currentSearchField: NSSearchField? = nil
|
||||
private var currentSearchField: NSSearchField?
|
||||
private let articleThemeMenuToolbarItem = NSMenuToolbarItem(itemIdentifier: .articleThemeMenu)
|
||||
private var searchString: String? = nil
|
||||
private var lastSentSearchString: String? = nil
|
||||
private var searchString: String?
|
||||
private var lastSentSearchString: String?
|
||||
private var timelineSourceMode: TimelineSourceMode = .regular {
|
||||
didSet {
|
||||
timelineContainerViewController?.showTimeline(for: timelineSourceMode)
|
||||
detailViewController?.showDetail(for: timelineSourceMode)
|
||||
}
|
||||
}
|
||||
private var searchSmartFeed: SmartFeed? = nil
|
||||
private var searchSmartFeed: SmartFeed?
|
||||
private var restoreArticleWindowScrollY: CGFloat?
|
||||
|
||||
// MARK: - NSWindowController
|
||||
@ -283,7 +283,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
return
|
||||
}
|
||||
detailViewController.canScrollUp { (canScroll) in
|
||||
if (canScroll) {
|
||||
if canScroll {
|
||||
NSCursor.setHiddenUntilMouseMoves(true)
|
||||
detailViewController.scrollPageUp(sender)
|
||||
}
|
||||
@ -340,8 +340,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
// TODO: handle search mode
|
||||
if timelineViewController.canGoToNextUnread(wrappingToTop: false) {
|
||||
goToNextUnreadInTimeline(wrappingToTop: false)
|
||||
}
|
||||
else if sidebarViewController.canGoToNextUnread(wrappingToTop: true) {
|
||||
} else if sidebarViewController.canGoToNextUnread(wrappingToTop: true) {
|
||||
sidebarViewController.goToNextUnread(wrappingToTop: true)
|
||||
|
||||
// If we ended up on the same timelineViewController, we may need to wrap
|
||||
@ -414,7 +413,7 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations {
|
||||
}
|
||||
|
||||
@IBAction func markAllAsReadAndGoToNextUnread(_ sender: Any?) {
|
||||
currentTimelineViewController?.markAllAsRead() {
|
||||
currentTimelineViewController?.markAllAsRead {
|
||||
self.nextUnread(sender)
|
||||
}
|
||||
}
|
||||
@ -1322,4 +1321,3 @@ private extension MainWindowController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -141,4 +141,3 @@ extension NNW3Feed: OPMLRepresentable {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -94,8 +94,7 @@ class ExportOPMLWindowController: NSWindowController {
|
||||
let opmlString = OPMLExporter.OPMLString(with: account, title: filename)
|
||||
do {
|
||||
try opmlString.write(to: url, atomically: true, encoding: String.Encoding.utf8)
|
||||
}
|
||||
catch let error as NSError {
|
||||
} catch let error as NSError {
|
||||
NSApplication.shared.presentError(error)
|
||||
}
|
||||
}
|
||||
|
@ -105,4 +105,3 @@ class ImportOPMLWindowController: NSWindowController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -73,7 +73,7 @@ class SidebarCell : NSTableCellView {
|
||||
}()
|
||||
|
||||
private let faviconImageView = IconView()
|
||||
private let unreadCountView = UnreadCountView(frame: NSZeroRect)
|
||||
private let unreadCountView = UnreadCountView(frame: NSRect.zero)
|
||||
|
||||
override var backgroundStyle: NSView.BackgroundStyle {
|
||||
didSet {
|
||||
@ -99,7 +99,7 @@ class SidebarCell : NSTableCellView {
|
||||
if let cellAppearance = cellAppearance {
|
||||
titleView.font = cellAppearance.textFieldFont
|
||||
}
|
||||
resizeSubviews(withOldSize: NSZeroSize)
|
||||
resizeSubviews(withOldSize: NSSize.zero)
|
||||
}
|
||||
|
||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||
@ -165,4 +165,3 @@ private extension SidebarCell {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -32,4 +32,3 @@ struct SidebarCellAppearance: Equatable {
|
||||
self.textFieldFont = NSFont.systemFont(ofSize: textFieldFontSize)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ struct SidebarCellLayout {
|
||||
|
||||
var rTextField = NSRect(x: 0.0, y: 0.0, width: textFieldSize.width, height: textFieldSize.height)
|
||||
if shouldShowImage {
|
||||
rTextField.origin.x = NSMaxX(rFavicon) + appearance.imageMarginRight
|
||||
rTextField.origin.x = rFavicon.maxX + appearance.imageMarginRight
|
||||
}
|
||||
rTextField = rTextField.centeredVertically(in: bounds)
|
||||
|
||||
@ -42,17 +42,17 @@ struct SidebarCellLayout {
|
||||
var rUnread = NSRect.zero
|
||||
if !unreadCountIsHidden {
|
||||
rUnread.size = unreadCountSize
|
||||
rUnread.origin.x = NSMaxX(bounds) - unreadCountSize.width
|
||||
rUnread.origin.x = bounds.maxX - unreadCountSize.width
|
||||
rUnread = rUnread.centeredVertically(in: bounds)
|
||||
let textFieldMaxX = NSMinX(rUnread) - appearance.unreadCountMarginLeft
|
||||
if NSMaxX(rTextField) > textFieldMaxX {
|
||||
rTextField.size.width = textFieldMaxX - NSMinX(rTextField)
|
||||
let textFieldMaxX = rUnread.minX - appearance.unreadCountMarginLeft
|
||||
if rTextField.maxX > textFieldMaxX {
|
||||
rTextField.size.width = textFieldMaxX - rTextField.minX
|
||||
}
|
||||
}
|
||||
self.unreadCountRect = rUnread
|
||||
|
||||
if NSMaxX(rTextField) > NSMaxX(bounds) {
|
||||
rTextField.size.width = NSMaxX(bounds) - NSMinX(rTextField)
|
||||
if rTextField.maxX > bounds.maxX {
|
||||
rTextField.size.width = bounds.maxX - rTextField.minX
|
||||
}
|
||||
self.titleRect = rTextField
|
||||
}
|
||||
|
@ -39,4 +39,3 @@ import RSCore
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ struct PasteboardFeed: Hashable {
|
||||
let feedID = dictionary[Key.feedID]
|
||||
let editedName = dictionary[Key.editedName]
|
||||
|
||||
var accountType: AccountType? = nil
|
||||
var accountType: AccountType?
|
||||
if let accountTypeString = dictionary[Key.accountType], let accountTypeInt = Int(accountTypeString) {
|
||||
accountType = AccountType(rawValue: accountTypeInt)
|
||||
}
|
||||
@ -72,8 +72,7 @@ struct PasteboardFeed: Hashable {
|
||||
var pasteboardType: NSPasteboard.PasteboardType?
|
||||
if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIInternalType) {
|
||||
pasteboardType = FeedPasteboardWriter.feedUTIInternalType
|
||||
}
|
||||
else if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIType) {
|
||||
} else if pasteboardItem.types.contains(FeedPasteboardWriter.feedUTIType) {
|
||||
pasteboardType = FeedPasteboardWriter.feedUTIType
|
||||
}
|
||||
if let foundType = pasteboardType {
|
||||
@ -87,8 +86,7 @@ struct PasteboardFeed: Hashable {
|
||||
// Check for URL or a string that may be a URL.
|
||||
if pasteboardItem.types.contains(.URL) {
|
||||
pasteboardType = .URL
|
||||
}
|
||||
else if pasteboardItem.types.contains(.string) {
|
||||
} else if pasteboardItem.types.contains(.string) {
|
||||
pasteboardType = .string
|
||||
}
|
||||
if let foundType = pasteboardType {
|
||||
@ -161,7 +159,6 @@ extension Feed: @retroactive PasteboardWriterOwner {
|
||||
static let feedUTIInternal = "com.ranchero.NetNewsWire-Evergreen.internal.feed"
|
||||
static let feedUTIInternalType = NSPasteboard.PasteboardType(rawValue: feedUTIInternal)
|
||||
|
||||
|
||||
init(feed: Feed) {
|
||||
self.feed = feed
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ struct PasteboardFolder: Hashable {
|
||||
static let accountID = "accountID"
|
||||
}
|
||||
|
||||
|
||||
let name: String
|
||||
let folderID: String?
|
||||
let accountID: String?
|
||||
|
@ -16,7 +16,7 @@ import Account
|
||||
|
||||
let treeController: TreeController
|
||||
static let dragOperationNone = NSDragOperation(rawValue: 0)
|
||||
private var draggedNodes: Set<Node>? = nil
|
||||
private var draggedNodes: Set<Node>?
|
||||
|
||||
init(treeController: TreeController) {
|
||||
self.treeController = treeController
|
||||
@ -159,8 +159,7 @@ private extension SidebarOutlineDataSource {
|
||||
for feed in draggedFeeds {
|
||||
if feed.isLocalFeed {
|
||||
hasLocalFeed = true
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
hasNonLocalFeed = true
|
||||
}
|
||||
if hasLocalFeed && hasNonLocalFeed {
|
||||
|
@ -119,7 +119,7 @@ extension SidebarViewController {
|
||||
NotificationCenter.default.post(Notification(name: .DidUpdateFeedPreferencesFromContextMenu))
|
||||
}
|
||||
} else {
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
if feed.isNotifyAboutNewArticles == nil { feed.isNotifyAboutNewArticles = false }
|
||||
@ -362,4 +362,3 @@ private extension SidebarViewController {
|
||||
return articles
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,6 @@ protocol SidebarDelegate: AnyObject {
|
||||
menu.takeItems(from: contextualMenu)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - NSOutlineViewDelegate
|
||||
|
||||
func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? {
|
||||
@ -563,7 +562,6 @@ private extension SidebarViewController {
|
||||
treeControllerDelegate.addFilterException(folderFeedID)
|
||||
}
|
||||
|
||||
|
||||
func queueRebuildTreeAndRestoreSelection() {
|
||||
rebuildTreeAndRestoreSelectionQueue.add(self, #selector(rebuildTreeAndRestoreSelection))
|
||||
}
|
||||
@ -819,7 +817,7 @@ private extension SidebarViewController {
|
||||
}
|
||||
|
||||
func applyToAvailableCells(_ completion: (SidebarCell, Node) -> Void) {
|
||||
outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) -> Void in
|
||||
outlineView.enumerateAvailableRowViews { (rowView: NSTableRowView, row: Int) in
|
||||
guard let cell = cellForRowView(rowView), let node = nodeForRow(row) else {
|
||||
return
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ class UnreadCountView : NSView {
|
||||
}
|
||||
|
||||
private var intrinsicContentSizeIsValid = false
|
||||
private var _intrinsicContentSize = NSZeroSize
|
||||
private var _intrinsicContentSize = NSSize.zero
|
||||
|
||||
override var intrinsicContentSize: NSSize {
|
||||
if !intrinsicContentSizeIsValid {
|
||||
var size = NSZeroSize
|
||||
var size = NSSize.zero
|
||||
if unreadCount > 0 {
|
||||
size = textSize()
|
||||
size.width += (Appearance.padding.left + Appearance.padding.right)
|
||||
@ -59,7 +59,7 @@ class UnreadCountView : NSView {
|
||||
|
||||
private func textSize() -> NSSize {
|
||||
if unreadCount < 1 {
|
||||
return NSZeroSize
|
||||
return NSSize.zero
|
||||
}
|
||||
|
||||
if let cachedSize = UnreadCountView.textSizeCache[unreadCount] {
|
||||
@ -76,9 +76,9 @@ class UnreadCountView : NSView {
|
||||
|
||||
private func textRect() -> NSRect {
|
||||
let size = textSize()
|
||||
var r = NSZeroRect
|
||||
var r = NSRect.zero
|
||||
r.size = size
|
||||
r.origin.x = (NSMaxX(bounds) - Appearance.padding.right) - r.size.width
|
||||
r.origin.x = (bounds.maxX - Appearance.padding.right) - r.size.width
|
||||
r.origin.y = Appearance.padding.top
|
||||
return r
|
||||
}
|
||||
@ -93,4 +93,3 @@ class UnreadCountView : NSView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,11 +78,9 @@ private extension ArticlePasteboardWriter {
|
||||
}
|
||||
if let text = article.contentText {
|
||||
s += "\(text)\n\n"
|
||||
}
|
||||
else if let summary = article.summary {
|
||||
} else if let summary = article.summary {
|
||||
s += "\(summary)\n\n"
|
||||
}
|
||||
else if let html = article.contentHTML {
|
||||
} else if let html = article.contentHTML {
|
||||
let convertedHTML = html.convertingToPlainText()
|
||||
s += "\(convertedHTML)\n\n"
|
||||
}
|
||||
@ -187,4 +185,3 @@ private extension ArticlePasteboardWriter {
|
||||
return authors.map { authorDictionary($0) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,8 +227,7 @@ private extension MultilineTextFieldSizer {
|
||||
|
||||
if oneWidth < width && (oneWidth > smallNeighbor.width || smallNeighbor.width == 0) {
|
||||
smallNeighbor = (oneWidth, oneHeight)
|
||||
}
|
||||
else if oneWidth > width && (oneWidth < largeNeighbor.width || largeNeighbor.width == 0) {
|
||||
} else if oneWidth > width && (oneWidth < largeNeighbor.width || largeNeighbor.width == 0) {
|
||||
largeNeighbor = (oneWidth, oneHeight)
|
||||
}
|
||||
|
||||
|
@ -42,8 +42,7 @@ struct TimelineCellLayout {
|
||||
|
||||
if height > 0.1 {
|
||||
self.height = height
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
self.height = [feedNameRect, dateRect, titleRect, summaryRect, textRect, unreadIndicatorRect, iconImageRect].maxY() + paddingBottom
|
||||
}
|
||||
}
|
||||
@ -62,8 +61,7 @@ struct TimelineCellLayout {
|
||||
var lastTextRect = titleRect
|
||||
if numberOfLinesForTitle == 0 {
|
||||
lastTextRect = textRect
|
||||
}
|
||||
else if numberOfLinesForTitle < appearance.titleNumberOfLines {
|
||||
} else if numberOfLinesForTitle < appearance.titleNumberOfLines {
|
||||
if summaryRect.height > 0.1 {
|
||||
lastTextRect = summaryRect
|
||||
}
|
||||
@ -130,7 +128,7 @@ private extension TimelineCellLayout {
|
||||
}
|
||||
|
||||
var r = textBoxRect
|
||||
r.origin.y = NSMaxY(titleRect)
|
||||
r.origin.y = titleRect.maxY
|
||||
let summaryNumberOfLines = appearance.titleNumberOfLines - titleNumberOfLines
|
||||
|
||||
let sizeInfo = MultilineTextFieldSizer.size(for: cellData.text, font: appearance.textOnlyFont, numberOfLines: summaryNumberOfLines, width: Int(textBoxRect.width))
|
||||
@ -161,9 +159,9 @@ private extension TimelineCellLayout {
|
||||
static func rectForDate(_ textBoxRect: NSRect, _ rectAbove: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||
let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.dateString, font: appearance.dateFont)
|
||||
|
||||
var r = NSZeroRect
|
||||
var r = NSRect.zero
|
||||
r.size = textFieldSize
|
||||
r.origin.y = NSMaxY(rectAbove) + appearance.titleBottomMargin
|
||||
r.origin.y = rectAbove.maxY + appearance.titleBottomMargin
|
||||
r.size.width = textFieldSize.width
|
||||
|
||||
r.origin.x = textBoxRect.maxX - textFieldSize.width
|
||||
@ -173,11 +171,11 @@ private extension TimelineCellLayout {
|
||||
|
||||
static func rectForFeedName(_ textBoxRect: NSRect, _ dateRect: NSRect, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||
if cellData.showFeedName == .none {
|
||||
return NSZeroRect
|
||||
return NSRect.zero
|
||||
}
|
||||
|
||||
let textFieldSize = SingleLineTextFieldSizer.size(for: cellData.feedName, font: appearance.feedNameFont)
|
||||
var r = NSZeroRect
|
||||
var r = NSRect.zero
|
||||
r.size = textFieldSize
|
||||
r.origin.y = dateRect.minY
|
||||
r.origin.x = textBoxRect.origin.x
|
||||
@ -188,7 +186,7 @@ private extension TimelineCellLayout {
|
||||
|
||||
static func rectForUnreadIndicator(_ appearance: TimelineCellAppearance, _ titleRect: NSRect) -> NSRect {
|
||||
|
||||
var r = NSZeroRect
|
||||
var r = NSRect.zero
|
||||
r.size = NSSize(width: appearance.unreadCircleDimension, height: appearance.unreadCircleDimension)
|
||||
r.origin.x = appearance.cellPadding.left
|
||||
r.origin.y = titleRect.minY + 6
|
||||
@ -237,4 +235,3 @@ private extension Array where Element == NSRect {
|
||||
return y
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||
private let titleView = TimelineTableCellView.multiLineTextField()
|
||||
private let summaryView = TimelineTableCellView.multiLineTextField()
|
||||
private let textView = TimelineTableCellView.multiLineTextField()
|
||||
private let unreadIndicatorView = UnreadIndicatorView(frame: NSZeroRect)
|
||||
private let unreadIndicatorView = UnreadIndicatorView(frame: NSRect.zero)
|
||||
private let dateView = TimelineTableCellView.singleLineTextField()
|
||||
private let feedNameView = TimelineTableCellView.singleLineTextField()
|
||||
|
||||
@ -91,7 +91,7 @@ class TimelineTableCellView: NSTableCellView {
|
||||
|
||||
override func layout() {
|
||||
|
||||
resizeSubviews(withOldSize: NSZeroSize)
|
||||
resizeSubviews(withOldSize: NSSize.zero)
|
||||
}
|
||||
|
||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||
@ -149,8 +149,7 @@ private extension TimelineTableCellView {
|
||||
|
||||
if Int(floor(rect.height)) == 0 || Int(floor(rect.width)) == 0 {
|
||||
hideView(textField)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
showView(textField)
|
||||
textField.setFrame(ifNotEqualTo: rect)
|
||||
}
|
||||
|
@ -34,4 +34,3 @@ final class TimelineContainerView: NSView {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,8 +170,7 @@ private extension TimelineContainerViewController {
|
||||
func mode(for timelineViewController: TimelineViewController) -> TimelineSourceMode {
|
||||
if timelineViewController === regularTimelineViewController {
|
||||
return .regular
|
||||
}
|
||||
else if timelineViewController === searchTimelineViewController {
|
||||
} else if timelineViewController === searchTimelineViewController {
|
||||
return .search
|
||||
}
|
||||
assertionFailure("Expected timelineViewController to match either regular or search timelineViewController, but it doesn’t.")
|
||||
|
@ -106,7 +106,6 @@ extension TimelineViewController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private extension TimelineViewController {
|
||||
|
||||
func markArticles(_ articles: [Article], read: Bool) {
|
||||
@ -282,7 +281,6 @@ private extension TimelineViewController {
|
||||
return menuItem(NSLocalizedString("Copy External URL", comment: "Command"), #selector(copyURLFromContextualMenu(_:)), urlString)
|
||||
}
|
||||
|
||||
|
||||
func menuItem(_ title: String, _ action: Selector, _ representedObject: Any) -> NSMenuItem {
|
||||
|
||||
let item = NSMenuItem(title: title, action: action, keyEquivalent: "")
|
||||
|
@ -331,8 +331,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
|
||||
if markAsRead {
|
||||
markSelectedArticlesAsRead(sender)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
markSelectedArticlesAsUnread(sender)
|
||||
}
|
||||
}
|
||||
@ -485,12 +484,11 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
func markOlderArticlesRead(_ selectedArticles: [Article]) {
|
||||
// Mark articles older than the selectedArticles(s) as read.
|
||||
|
||||
var cutoffDate: Date? = nil
|
||||
var cutoffDate: Date?
|
||||
for article in selectedArticles {
|
||||
if cutoffDate == nil {
|
||||
cutoffDate = article.logicalDatePublished
|
||||
}
|
||||
else if cutoffDate! > article.logicalDatePublished {
|
||||
} else if cutoffDate! > article.logicalDatePublished {
|
||||
cutoffDate = article.logicalDatePublished
|
||||
}
|
||||
}
|
||||
@ -833,8 +831,7 @@ extension TimelineViewController: NSTableViewDelegate {
|
||||
cell.cellAppearance = showIcons ? cellAppearanceWithIcon : cellAppearance
|
||||
if let article = articles.articleAtRow(row) {
|
||||
configureTimelineCell(cell, article: article)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
makeTimelineCellEmpty(cell)
|
||||
}
|
||||
}
|
||||
@ -917,16 +914,16 @@ extension TimelineViewController: NSTableViewDelegate {
|
||||
|
||||
switch edge {
|
||||
case .leading:
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (action, row) in
|
||||
self.toggleArticleRead(article);
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (_, _) in
|
||||
self.toggleArticleRead(article)
|
||||
tableView.rowActionsVisible = false
|
||||
}
|
||||
action.image = article.status.read ? AppAssets.swipeMarkUnreadImage : AppAssets.swipeMarkReadImage
|
||||
return [action]
|
||||
|
||||
case .trailing:
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (action, row) in
|
||||
self.toggleArticleStarred(article);
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (_, _) in
|
||||
self.toggleArticleStarred(article)
|
||||
tableView.rowActionsVisible = false
|
||||
}
|
||||
action.backgroundColor = AppAssets.starColor
|
||||
@ -1236,8 +1233,7 @@ private extension TimelineViewController {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
else if let folder = representedObject as? Folder {
|
||||
} else if let folder = representedObject as? Folder {
|
||||
for oneFeed in feeds {
|
||||
if folder.hasFeed(with: oneFeed.feedID) || folder.hasFeed(withURL: oneFeed.url) {
|
||||
return true
|
||||
|
@ -53,7 +53,7 @@ class AccountsAddCloudKitWindowController: NSWindowController {
|
||||
return
|
||||
}
|
||||
|
||||
let _ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||
_ = AccountManager.shared.createAccount(type: .cloudKit)
|
||||
hostWindow!.endSheet(window!, returnCode: NSApplication.ModalResponse.OK)
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,6 @@ final class AccountsDetailViewController: NSViewController, NSTextFieldDelegate
|
||||
accountsReaderAPIWindowController.account = account
|
||||
accountsReaderAPIWindowController.runSheetOnWindow(self.view.window!)
|
||||
accountsWindowController = accountsReaderAPIWindowController
|
||||
break
|
||||
case .newsBlur:
|
||||
let accountsNewsBlurWindowController = AccountsNewsBlurWindowController()
|
||||
accountsNewsBlurWindowController.account = account
|
||||
|
@ -103,7 +103,7 @@ class AccountsFeedbinWindowController: NSWindowController {
|
||||
try self.account?.removeCredentials(type: .basic)
|
||||
try self.account?.storeCredentials(validatedCredentials)
|
||||
|
||||
self.account?.refreshAll() { result in
|
||||
self.account?.refreshAll { result in
|
||||
switch result {
|
||||
case .success:
|
||||
break
|
||||
|
@ -101,7 +101,7 @@ class AccountsNewsBlurWindowController: NSWindowController {
|
||||
try self.account?.storeCredentials(credentials)
|
||||
try self.account?.storeCredentials(validatedCredentials)
|
||||
|
||||
self.account?.refreshAll() { result in
|
||||
self.account?.refreshAll { result in
|
||||
switch result {
|
||||
case .success:
|
||||
break
|
||||
|
@ -40,7 +40,6 @@ final class AccountsPreferencesViewController: NSViewController {
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidAddAccount, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(accountsDidChange(_:)), name: .UserDidDeleteAccount, object: nil)
|
||||
|
||||
|
||||
// Fix tableView frame — for some reason IB wants it 1pt wider than the clip view. This leads to unwanted horizontal scrolling.
|
||||
var rTable = tableView.frame
|
||||
rTable.size.width = tableView.superview!.frame.size.width
|
||||
|
@ -158,7 +158,7 @@ class AccountsReaderAPIWindowController: NSWindowController {
|
||||
try self.account?.storeCredentials(credentials)
|
||||
try self.account?.storeCredentials(validatedCredentials)
|
||||
|
||||
self.account?.refreshAll() { result in
|
||||
self.account?.refreshAll { result in
|
||||
switch result {
|
||||
case .success:
|
||||
break
|
||||
|
@ -69,9 +69,6 @@ enum AddAccountSections: Int, CaseIterable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
struct AddAccountsView: View {
|
||||
@ -270,10 +267,8 @@ struct AddAccountsView: View {
|
||||
|
||||
}
|
||||
|
||||
|
||||
struct AddAccountsView_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AddAccountsView(delegate: nil)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,7 @@ private extension AdvancedPreferencesViewController {
|
||||
func updateUI() {
|
||||
if wantsTestBuilds {
|
||||
testBuildsButton.state = .on
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
releaseBuildsButton.state = .on
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ final class PreferencesControlsBackgroundView: NSView {
|
||||
|
||||
let fillColor = self.effectiveAppearance.isDarkMode ? darkModeFillColor : lightModeFillColor
|
||||
fillColor.setFill()
|
||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
||||
let r = dirtyRect.intersection(bounds)
|
||||
r.fill()
|
||||
|
||||
let borderColor = self.effectiveAppearance.isDarkMode ? darkModeBorderColor : lightModeBorderColor
|
||||
|
@ -17,7 +17,7 @@ final class PreferencesTableViewBackgroundView: NSView {
|
||||
let color = self.effectiveAppearance.isDarkMode ? darkBorderColor : lightBorderColor
|
||||
color.setFill()
|
||||
|
||||
let r = NSIntersectionRect(dirtyRect, bounds)
|
||||
let r = dirtyRect.intersection(bounds)
|
||||
r.fill()
|
||||
}
|
||||
}
|
||||
|
@ -140,8 +140,7 @@ private extension PreferencesWindowController {
|
||||
|
||||
if let currentView = currentView {
|
||||
window!.contentView?.replaceSubview(currentView, with: newViewController.view)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
window!.contentView?.addSubview(newViewController.view)
|
||||
}
|
||||
|
||||
@ -168,9 +167,9 @@ private extension PreferencesWindowController {
|
||||
let windowFrame = window!.frame
|
||||
let contentViewFrame = window!.contentView!.frame
|
||||
|
||||
let deltaHeight = NSHeight(contentViewFrame) - NSHeight(viewFrame)
|
||||
let heightForWindow = NSHeight(windowFrame) - deltaHeight
|
||||
let windowOriginY = NSMinY(windowFrame) + deltaHeight
|
||||
let deltaHeight = contentViewFrame.height - viewFrame.height
|
||||
let heightForWindow = windowFrame.height - deltaHeight
|
||||
let windowOriginY = windowFrame.minY + deltaHeight
|
||||
|
||||
var updatedWindowFrame = windowFrame
|
||||
updatedWindowFrame.size.height = heightForWindow
|
||||
@ -178,7 +177,7 @@ private extension PreferencesWindowController {
|
||||
updatedWindowFrame.size.width = windowWidth // NSWidth(viewFrame)
|
||||
|
||||
var updatedViewFrame = viewFrame
|
||||
updatedViewFrame.origin = NSZeroPoint
|
||||
updatedViewFrame.origin = NSPoint.zero
|
||||
updatedViewFrame.size.width = windowWidth
|
||||
if viewFrame != updatedViewFrame {
|
||||
view.frame = updatedViewFrame
|
||||
|
@ -29,7 +29,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
}
|
||||
|
||||
// Maps from UUID to a validation wrapper
|
||||
static var gPingPongMap = Dictionary<String, ValidationWrapper>()
|
||||
static var gPingPongMap = [String: ValidationWrapper]()
|
||||
static var validationQueue = DispatchQueue(label: "Toolbar Validation")
|
||||
|
||||
// Bottleneck for calling through to a validation handler we have saved, and removing it from the list.
|
||||
@ -41,7 +41,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
}
|
||||
|
||||
override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String: Any]?) {
|
||||
if (messageName == "subscribeToFeed") {
|
||||
if messageName == "subscribeToFeed" {
|
||||
if var feedURLString = userInfo?["url"] as? String {
|
||||
var openInDefaultBrowser = false
|
||||
|
||||
@ -61,8 +61,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
NSWorkspace.shared.open(feedURL)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (messageName == "pong") {
|
||||
} else if messageName == "pong" {
|
||||
if let validationIDString = userInfo?["validationID"] as? String {
|
||||
// Should we validate the button?
|
||||
let shouldValidate = userInfo?["shouldValidate"] as? Bool ?? false
|
||||
@ -97,7 +96,7 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
if thisValidationID != uniqueValidationID {
|
||||
// Default to valid ... we'll know soon enough whether the latest state
|
||||
// is actually still valid or not...
|
||||
SafariExtensionHandler.callValidationHandler(forHandlerID: thisValidationID, withShouldValidate: true);
|
||||
SafariExtensionHandler.callValidationHandler(forHandlerID: thisValidationID, withShouldValidate: true)
|
||||
|
||||
}
|
||||
}
|
||||
@ -108,13 +107,13 @@ class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
// a timeout period has elapsed
|
||||
window.getActiveTab { (activeTab) in
|
||||
guard let activeTab = activeTab else {
|
||||
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate:false);
|
||||
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate: false)
|
||||
return
|
||||
}
|
||||
|
||||
activeTab.getActivePage { (activePage) in
|
||||
guard let activePage = activePage else {
|
||||
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate:false);
|
||||
SafariExtensionHandler.callValidationHandler(forHandlerID: uniqueValidationID, withShouldValidate: false)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -70,18 +70,18 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
if let scriptableFolder = element as? ScriptableFolder {
|
||||
BatchUpdate.shared.perform {
|
||||
account.removeFolder(scriptableFolder.folder) { result in
|
||||
account.removeFolder(scriptableFolder.folder) { _ in
|
||||
}
|
||||
}
|
||||
} else if let scriptableFeed = element as? ScriptableFeed {
|
||||
BatchUpdate.shared.perform {
|
||||
var container: Container? = nil
|
||||
var container: Container?
|
||||
if let scriptableFolder = scriptableFeed.container as? ScriptableFolder {
|
||||
container = scriptableFolder.folder
|
||||
} else {
|
||||
container = account
|
||||
}
|
||||
account.removeFeed(scriptableFeed.feed, from: container!) { result in
|
||||
account.removeFeed(scriptableFeed.feed, from: container!) { _ in
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ class ScriptableAccount: NSObject, UniqueIdScriptingObject, ScriptingObjectConta
|
||||
|
||||
@objc(isLocationRequiredToCreateForKey:)
|
||||
func isLocationRequiredToCreate(forKey key: String) -> Bool {
|
||||
return false;
|
||||
return false
|
||||
}
|
||||
|
||||
// MARK: --- Scriptable elements ---
|
||||
|
@ -54,7 +54,7 @@ extension AppDelegate : AppDelegateAppleEvents {
|
||||
|
||||
if let themeURL = URL(string: themeURLString) {
|
||||
let request = URLRequest(url: themeURL)
|
||||
let task = URLSession.shared.downloadTask(with: request) { location, response, error in
|
||||
let task = URLSession.shared.downloadTask(with: request) { location, _, error in
|
||||
guard let location = location else {
|
||||
return
|
||||
}
|
||||
@ -71,7 +71,6 @@ extension AppDelegate : AppDelegateAppleEvents {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Special case URL with specific scheme handler x-netnewswire-feed: intended to ensure we open
|
||||
// it regardless of which news reader may be set as the default
|
||||
let nnwScheme = "x-netnewswire-feed:"
|
||||
@ -94,9 +93,9 @@ extension AppDelegate : AppDelegateAppleEvents {
|
||||
class NetNewsWireCreateElementCommand: NSCreateCommand {
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
let classDescription = self.createClassDescription
|
||||
if (classDescription.className == "feed") {
|
||||
if classDescription.className == "feed" {
|
||||
return ScriptableFeed.handleCreateElement(command: self)
|
||||
} else if (classDescription.className == "folder") {
|
||||
} else if classDescription.className == "folder" {
|
||||
return ScriptableFolder.handleCreateElement(command: self)
|
||||
}
|
||||
return nil
|
||||
@ -183,4 +182,3 @@ class NetNewsWireExistsCommand : NSExistsCommand {
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
if let scriptableFeed = element as? ScriptableFeed {
|
||||
BatchUpdate.shared.perform {
|
||||
folder.account?.removeFeed(scriptableFeed.feed, from: folder) { result in }
|
||||
folder.account?.removeFeed(scriptableFeed.feed, from: folder) { _ in }
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,7 +73,7 @@ class ScriptableFolder: NSObject, UniqueIdScriptingObject, ScriptingObjectContai
|
||||
// identifies where the new folder should be created
|
||||
let (account, folder) = command.accountAndFolderForNewChild()
|
||||
guard folder == nil else {
|
||||
print("support for folders within folders is NYI");
|
||||
print("support for folders within folders is NYI")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -13,4 +13,3 @@ protocol ScriptingMainWindowController {
|
||||
var scriptingCurrentArticle: Article? { get }
|
||||
var scriptingSelectedArticles: [Article] { get }
|
||||
}
|
||||
|
||||
|
@ -95,5 +95,3 @@ extension NSApplication : ScriptingObjectContainer {
|
||||
return ScriptableFeed(feed, container: self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,23 +22,23 @@ extension NSScriptCommand {
|
||||
func isCreateCommand(forClass whatClass: String) -> Bool {
|
||||
guard let arguments = self.arguments else {return false}
|
||||
guard let newObjectClass = arguments["ObjectClass"] as? Int else {return false}
|
||||
guard (newObjectClass.fourCharCode == whatClass.fourCharCode) else {return false}
|
||||
guard newObjectClass.fourCharCode == whatClass.fourCharCode else {return false}
|
||||
return true
|
||||
}
|
||||
|
||||
func accountAndFolderForNewChild() -> (Account, Folder?) {
|
||||
let appleEvent = self.appleEvent
|
||||
var account = AccountManager.shared.defaultAccount
|
||||
var folder:Folder? = nil
|
||||
var folder: Folder?
|
||||
if let appleEvent = appleEvent {
|
||||
var descriptorToConsider: NSAppleEventDescriptor?
|
||||
if let insertionLocationDescriptor = appleEvent.paramDescriptor(forKeyword: keyAEInsertHere) {
|
||||
print("insertionLocation : \(insertionLocationDescriptor)")
|
||||
// insertion location can be a typeObjectSpecifier, e.g. 'in account "Acct"'
|
||||
// or a typeInsertionLocation, e.g. 'at end of folder "
|
||||
if (insertionLocationDescriptor.descriptorType == "insl".fourCharCode) {
|
||||
if insertionLocationDescriptor.descriptorType == "insl".fourCharCode {
|
||||
descriptorToConsider = insertionLocationDescriptor.forKeyword("kobj".fourCharCode)
|
||||
} else if ( insertionLocationDescriptor.descriptorType == "obj ".fourCharCode) {
|
||||
} else if insertionLocationDescriptor.descriptorType == "obj ".fourCharCode {
|
||||
descriptorToConsider = insertionLocationDescriptor
|
||||
}
|
||||
} else if let subjectDescriptor = appleEvent.attributeDescriptor(forKeyword: "subj".fourCharCode) {
|
||||
|
@ -36,4 +36,3 @@ extension ScriptingObjectContainer {
|
||||
return specifier
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ class ShareViewController: NSViewController {
|
||||
extensionContainers = ExtensionContainersFile.read()
|
||||
buildFolderPopupMenu()
|
||||
|
||||
var provider: NSItemProvider? = nil
|
||||
var provider: NSItemProvider?
|
||||
|
||||
// Try to get any HTML that is maybe passed in
|
||||
for item in self.extensionContext!.inputItems as! [NSExtensionItem] {
|
||||
@ -117,7 +117,7 @@ private extension ShareViewController {
|
||||
}
|
||||
|
||||
let defaultContainer = ShareDefaultContainer.defaultContainer(containers: extensionContainers)
|
||||
var defaultMenuItem: NSMenuItem? = nil
|
||||
var defaultMenuItem: NSMenuItem?
|
||||
|
||||
for account in extensionContainers.accounts {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user