mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-01 09:50:16 +00:00
Fix various SwiftLint warnings.
This commit is contained in:
1 parent
d9216a3275
commit
9ff1bd9836
104 files changed
+365
-363
No files matched your search
@@ -68,7 +68,8 @@
|
||||
"Bash(echo:*)",
|
||||
"Bash(done)",
|
||||
"Bash(# Show files touched by state restoration related commits echo \"\"=== Files changed in state restoration commits ===\"\" for commit in 04e98a47d 89b31858c d788af388 1d49b9328 236943f82 38d6b11c5 3be027699 16c66513c 1ef2aa162 6ce3bdadc 1954f5b65 55b7da75d 20b3bda94 4bf57afc1 e0074d70b 616b9deeb f6bca9ee8 ea6eedb86 380617920 d68106ac0 d30c62757 813f0706b 2ea00619c; do git diff-tree --no-commit-id --name-only -r \"\"$commit\"\" done)",
|
||||
"Bash(swiftlint version:*)"
|
||||
"Bash(swiftlint version:*)",
|
||||
"Bash(swiftlint:*)"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -65,7 +65,7 @@ final class AppDefaults: Sendable {
|
||||
}()
|
||||
|
||||
let isFirstRun: Bool = {
|
||||
if UserDefaults.standard.object(forKey: Key.firstRunDate) as? Date != nil {
|
||||
if UserDefaults.standard.object(forKey: Key.firstRunDate) is Date {
|
||||
return false
|
||||
}
|
||||
firstRunDate = Date()
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ final class DetailWebViewController: NSViewController {
|
||||
|
||||
private var isShowingExtractedArticle: Bool {
|
||||
switch state {
|
||||
case .extracted(_, _, _):
|
||||
case .extracted:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
@@ -269,7 +269,7 @@ private extension DetailWebViewController {
|
||||
}
|
||||
|
||||
func reloadHTMLMaintainingScrollPosition() {
|
||||
fetchScrollInfo() { scrollInfo in
|
||||
fetchScrollInfo { scrollInfo in
|
||||
self.windowScrollY = scrollInfo?.offsetY
|
||||
self.reloadHTML()
|
||||
}
|
||||
@@ -319,7 +319,7 @@ private extension DetailWebViewController {
|
||||
private func fetchScrollInfo(_ completion: @escaping (ScrollInfo?) -> Void) {
|
||||
let javascriptString = "var x = {contentHeight: document.body.scrollHeight, offsetY: document.body.scrollTop}; x"
|
||||
|
||||
webView.evaluateJavaScript(javascriptString) { (info, error) in
|
||||
webView.evaluateJavaScript(javascriptString) { (info, _) in
|
||||
guard let info = info as? [String: Any] else {
|
||||
completion(nil)
|
||||
return
|
||||
|
||||
@@ -79,7 +79,7 @@ final class IconView: NSView {
|
||||
}
|
||||
|
||||
override func layout() {
|
||||
resizeSubviews(withOldSize: NSZeroSize)
|
||||
resizeSubviews(withOldSize: NSSize.zero)
|
||||
}
|
||||
|
||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||
@@ -106,7 +106,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 {
|
||||
@@ -118,21 +118,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)
|
||||
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)
|
||||
}
|
||||
}
|
||||
@@ -336,7 +336,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
|
||||
@IBAction func openArticleInBrowser(_ sender: Any?) {
|
||||
if let link = currentLink {
|
||||
Browser.open(link, invertPreference: NSApp.currentEvent?.modifierFlags.contains(.shift) ?? false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func openInBrowser(_ sender: Any?) {
|
||||
@@ -443,7 +443,7 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations
|
||||
}
|
||||
|
||||
@IBAction func markAllAsReadAndGoToNextUnread(_ sender: Any?) {
|
||||
currentTimelineViewController?.markAllAsRead() {
|
||||
currentTimelineViewController?.markAllAsRead {
|
||||
self.nextUnread(sender)
|
||||
}
|
||||
}
|
||||
@@ -980,7 +980,7 @@ private extension MainWindowController {
|
||||
|
||||
let splitViewWidths: [Int]
|
||||
if let splitView = splitViewController?.splitView {
|
||||
splitViewWidths = splitView.arrangedSubviews.map{ Int(floor($0.frame.width)) }
|
||||
splitViewWidths = splitView.arrangedSubviews.map { Int(floor($0.frame.width)) }
|
||||
} else {
|
||||
splitViewWidths = []
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ final 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 {
|
||||
@@ -100,7 +100,7 @@ final class SidebarCell: NSTableCellView {
|
||||
if let cellAppearance = cellAppearance {
|
||||
titleView.font = cellAppearance.textFieldFont
|
||||
}
|
||||
resizeSubviews(withOldSize: NSZeroSize)
|
||||
resizeSubviews(withOldSize: NSSize.zero)
|
||||
}
|
||||
|
||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||
|
||||
@@ -17,7 +17,6 @@ import RSCore
|
||||
let unreadCountRect: CGRect
|
||||
|
||||
init(appearance: SidebarCellAppearance, cellSize: NSSize, shouldShowImage: Bool, textField: NSTextField, unreadCountView: UnreadCountView) {
|
||||
|
||||
let bounds = NSRect(x: 0.0, y: 0.0, width: floor(cellSize.width), height: floor(cellSize.height))
|
||||
|
||||
var rFavicon = NSRect.zero
|
||||
@@ -31,7 +30,7 @@ import RSCore
|
||||
|
||||
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)
|
||||
|
||||
@@ -41,17 +40,17 @@ import RSCore
|
||||
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
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ import Account
|
||||
func outlineView(_ outlineView: NSOutlineView, validateDrop info: NSDraggingInfo, proposedItem item: Any?, proposedChildIndex index: Int) -> NSDragOperation {
|
||||
let draggedFolders = PasteboardFolder.pasteboardFolders(with: info.draggingPasteboard)
|
||||
let draggedFeeds = PasteboardFeed.pasteboardFeeds(with: info.draggingPasteboard)
|
||||
if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) {
|
||||
if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) {
|
||||
return SidebarOutlineDataSource.dragOperationNone
|
||||
}
|
||||
let parentNode = nodeForItem(item)
|
||||
@@ -100,7 +100,7 @@ import Account
|
||||
func outlineView(_ outlineView: NSOutlineView, acceptDrop info: NSDraggingInfo, item: Any?, childIndex index: Int) -> Bool {
|
||||
let draggedFolders = PasteboardFolder.pasteboardFolders(with: info.draggingPasteboard)
|
||||
let draggedFeeds = PasteboardFeed.pasteboardFeeds(with: info.draggingPasteboard)
|
||||
if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) {
|
||||
if (draggedFolders == nil && draggedFeeds == nil) || (draggedFolders != nil && draggedFeeds != nil) {
|
||||
return false
|
||||
}
|
||||
let parentNode = nodeForItem(item)
|
||||
@@ -236,7 +236,7 @@ private extension SidebarOutlineDataSource {
|
||||
return localDragOperation(parentNode: parentNode, draggedFeeds)
|
||||
}
|
||||
|
||||
func localDragOperation(parentNode: Node, _ draggedFeeds: Set<PasteboardFeed>)-> NSDragOperation {
|
||||
func localDragOperation(parentNode: Node, _ draggedFeeds: Set<PasteboardFeed>) -> NSDragOperation {
|
||||
guard let firstDraggedFeed = draggedFeeds.first else { return .move }
|
||||
if sameAccount(firstDraggedFeed, parentNode) {
|
||||
if NSApplication.shared.currentEvent?.modifierFlags.contains(.option) ?? false {
|
||||
|
||||
@@ -339,7 +339,7 @@ extension Notification.Name {
|
||||
// MARK: - Navigation
|
||||
|
||||
func canGoToNextUnread(wrappingToTop wrapping: Bool = false) -> Bool {
|
||||
if let _ = nextSelectableRowWithUnreadArticle(wrappingToTop: wrapping) {
|
||||
if nextSelectableRowWithUnreadArticle(wrappingToTop: wrapping) != nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@@ -857,7 +857,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
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@ final 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)
|
||||
@@ -74,7 +74,7 @@ final class UnreadCountView: NSView {
|
||||
|
||||
private func textSize() -> NSSize {
|
||||
if unreadCount < 1 {
|
||||
return NSZeroSize
|
||||
return NSSize.zero
|
||||
}
|
||||
|
||||
if let cachedSize = UnreadCountView.textSizeCache[unreadCount] {
|
||||
@@ -91,9 +91,9 @@ final 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
|
||||
}
|
||||
|
||||
@@ -122,13 +122,13 @@ import RSCore
|
||||
return (r, sizeInfo.numberOfLinesUsed)
|
||||
}
|
||||
|
||||
static func rectForSummary(_ textBoxRect: NSRect, _ titleRect: NSRect, _ titleNumberOfLines: Int, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||
static func rectForSummary(_ textBoxRect: NSRect, _ titleRect: NSRect, _ titleNumberOfLines: Int, _ appearance: TimelineCellAppearance, _ cellData: TimelineCellData) -> NSRect {
|
||||
if titleNumberOfLines >= appearance.titleNumberOfLines || cellData.text.isEmpty {
|
||||
return NSRect.zero
|
||||
}
|
||||
|
||||
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))
|
||||
@@ -159,9 +159,9 @@ import RSCore
|
||||
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
|
||||
@@ -171,11 +171,11 @@ import RSCore
|
||||
|
||||
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
|
||||
@@ -186,7 +186,7 @@ import RSCore
|
||||
|
||||
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
|
||||
|
||||
@@ -14,7 +14,7 @@ final 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 @@ final class TimelineTableCellView: NSTableCellView {
|
||||
|
||||
override func layout() {
|
||||
|
||||
resizeSubviews(withOldSize: NSZeroSize)
|
||||
resizeSubviews(withOldSize: NSSize.zero)
|
||||
}
|
||||
|
||||
override func resizeSubviews(withOldSize oldSize: NSSize) {
|
||||
@@ -299,7 +299,11 @@ private extension TimelineTableCellView {
|
||||
}
|
||||
|
||||
func showOrHideView(_ view: NSView, _ shouldHide: Bool) {
|
||||
shouldHide ? hideView(view) : showView(view)
|
||||
if shouldHide {
|
||||
hideView(view)
|
||||
} else {
|
||||
showView(view)
|
||||
}
|
||||
}
|
||||
|
||||
func updateSubviews() {
|
||||
|
||||
@@ -114,7 +114,7 @@ final class TimelineContainerViewController: NSViewController {
|
||||
return false
|
||||
}
|
||||
for object in representedObjects {
|
||||
guard let _ = currentObjects.firstIndex(where: { $0 === object } ) else {
|
||||
if currentObjects.firstIndex(where: { $0 === object }) == nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,11 +248,11 @@ private extension TimelineViewController {
|
||||
}
|
||||
|
||||
func markAboveReadMenuItem(_ articles: [Article]) -> NSMenuItem {
|
||||
return menuItem(NSLocalizedString("Mark Above as Read", comment: "Command"), #selector(markAboveArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markAboveAsRead)
|
||||
return menuItem(NSLocalizedString("Mark Above as Read", comment: "Command"), #selector(markAboveArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markAboveAsRead)
|
||||
}
|
||||
|
||||
func markBelowReadMenuItem(_ articles: [Article]) -> NSMenuItem {
|
||||
return menuItem(NSLocalizedString("Mark Below as Read", comment: "Command"), #selector(markBelowArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markBelowAsRead)
|
||||
return menuItem(NSLocalizedString("Mark Below as Read", comment: "Command"), #selector(markBelowArticlesReadFromContextualMenu(_:)), articles, image: Assets.Images.markBelowAsRead)
|
||||
}
|
||||
|
||||
func selectFeedInSidebarMenuItem(_ feed: Feed) -> NSMenuItem {
|
||||
|
||||
@@ -12,7 +12,7 @@ import Articles
|
||||
import Account
|
||||
import os.log
|
||||
|
||||
@MainActor protocol TimelineDelegate: AnyObject {
|
||||
@MainActor protocol TimelineDelegate: AnyObject {
|
||||
func timelineSelectionDidChange(_: TimelineViewController, selectedArticles: [Article]?)
|
||||
func timelineRequestedFeedSelection(_: TimelineViewController, feed: Feed)
|
||||
func timelineInvalidatedRestorationState(_: TimelineViewController)
|
||||
@@ -631,10 +631,7 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr
|
||||
}
|
||||
|
||||
func canGoToNextUnread(wrappingToTop wrapping: Bool = false) -> Bool {
|
||||
guard let _ = indexOfNextUnreadArticle(wrappingToTop: wrapping) else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
return indexOfNextUnreadArticle(wrappingToTop: wrapping) != nil
|
||||
}
|
||||
|
||||
func indexOfNextUnreadArticle(wrappingToTop wrapping: Bool = false) -> Int? {
|
||||
@@ -994,26 +991,26 @@ extension TimelineViewController: NSTableViewDelegate {
|
||||
|
||||
switch edge {
|
||||
case .leading:
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (action, row) in
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.read ? "Unread" : "Read") { (_, _) in
|
||||
self.toggleArticleRead(article)
|
||||
tableView.rowActionsVisible = false
|
||||
}
|
||||
action.image = article.status.read ? Assets.Images.swipeMarkUnread : Assets.Images.swipeMarkRead
|
||||
return [action]
|
||||
|
||||
|
||||
case .trailing:
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (action, row) in
|
||||
let action = NSTableViewRowAction(style: .regular, title: article.status.starred ? "Unstar" : "Star") { (_, _) in
|
||||
self.toggleArticleStarred(article)
|
||||
tableView.rowActionsVisible = false
|
||||
}
|
||||
action.backgroundColor = Assets.Colors.star
|
||||
action.image = article.status.starred ? Assets.Images.swipeMarkUnstarred : Assets.Images.swipeMarkStarred
|
||||
return [action]
|
||||
|
||||
|
||||
@unknown default:
|
||||
Self.logger.error("TimelineViewController: unknown edge \(edge.rawValue, privacy: .public)")
|
||||
}
|
||||
|
||||
|
||||
return []
|
||||
}
|
||||
}
|
||||
@@ -1218,7 +1215,7 @@ private extension TimelineViewController {
|
||||
|
||||
func fetchUnsortedArticlesSync(for representedObjects: [Any]) -> Set<Article> {
|
||||
cancelPendingAsyncFetches()
|
||||
let fetchers = representedObjects.compactMap{ $0 as? ArticleFetcher }
|
||||
let fetchers = representedObjects.compactMap { $0 as? ArticleFetcher }
|
||||
if fetchers.isEmpty {
|
||||
return Set<Article>()
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -167,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
|
||||
@@ -177,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 @@ final class SafariExtensionHandler: SFSafariExtensionHandler {
|
||||
}
|
||||
|
||||
// Maps from UUID to a validation wrapper
|
||||
nonisolated(unsafe) static var gPingPongMap = Dictionary<String, ValidationWrapper>()
|
||||
nonisolated(unsafe) static var gPingPongMap = [String: ValidationWrapper]()
|
||||
static let validationQueue = DispatchQueue(label: "Toolbar Validation")
|
||||
|
||||
// Bottleneck for calling through to a validation handler we have saved, and removing it from the list.
|
||||
|
||||
@@ -93,7 +93,7 @@ import RSCore
|
||||
// MARK: --- Scriptable elements ---
|
||||
|
||||
@objc(feeds)
|
||||
var feeds: NSArray {
|
||||
var feeds: NSArray {
|
||||
account.topLevelFeeds.map { ScriptableFeed($0, container: self) } as NSArray
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ import RSCore
|
||||
}
|
||||
|
||||
@objc(folders)
|
||||
var folders: NSArray {
|
||||
var folders: NSArray {
|
||||
let foldersSet = account.folders ?? Set<Folder>()
|
||||
let folders = Array(foldersSet)
|
||||
return folders.map { ScriptableFolder($0, container: self) } as NSArray
|
||||
@@ -164,7 +164,7 @@ import RSCore
|
||||
// MARK: --- Scriptable properties ---
|
||||
|
||||
@objc(allFeeds)
|
||||
var allFeeds: NSArray {
|
||||
var allFeeds: NSArray {
|
||||
let allFeeds = account.flattenedFeeds()
|
||||
let scriptableFeeds = allFeeds.map { feed in
|
||||
ScriptableFeed(feed, container: self)
|
||||
@@ -204,7 +204,7 @@ import RSCore
|
||||
}
|
||||
|
||||
@objc(opmlRepresentation)
|
||||
var opmlRepresentation: String {
|
||||
var opmlRepresentation: String {
|
||||
self.account.OPMLString(indentLevel: 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -25,8 +25,8 @@ import Articles
|
||||
}
|
||||
|
||||
@MainActor protocol ScriptingAppDelegate {
|
||||
var scriptingCurrentArticle: Article? {get}
|
||||
var scriptingSelectedArticles: [Article] {get}
|
||||
var scriptingCurrentArticle: Article? {get}
|
||||
var scriptingSelectedArticles: [Article] {get}
|
||||
var scriptingMainWindowController: ScriptingMainWindowController? {get}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,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
|
||||
}
|
||||
@@ -105,9 +105,9 @@ final class NetNewsWireCreateElementCommand: NSCreateCommand {
|
||||
let instance = unsafeSelf.value
|
||||
let classDescription: NSScriptClassDescription = instance.createClassDescription
|
||||
let command: NSCreateCommand = instance
|
||||
if (classDescription.className == "feed") {
|
||||
if classDescription.className == "feed" {
|
||||
return UnsafeSendable(value: ScriptableFeed.handleCreateElement(command: command))
|
||||
} else if (classDescription.className == "folder") {
|
||||
} else if classDescription.className == "folder" {
|
||||
return UnsafeSendable(value: ScriptableFolder.handleCreateElement(command: command))
|
||||
}
|
||||
return UnsafeSendable(value: nil)
|
||||
@@ -197,7 +197,7 @@ final class NetNewsWireExistsCommand: NSExistsCommand {
|
||||
|
||||
override func performDefaultImplementation() -> Any? {
|
||||
guard let result = super.performDefaultImplementation() else {
|
||||
return NSNumber(booleanLiteral: false)
|
||||
return false as NSNumber
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -49,63 +49,63 @@ import Articles
|
||||
}
|
||||
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
print ("delete event not handled")
|
||||
print("delete event not handled")
|
||||
}
|
||||
|
||||
// MARK: - Scriptable properties
|
||||
|
||||
@objc(url)
|
||||
var url: String? {
|
||||
var url: String? {
|
||||
article.preferredLink
|
||||
}
|
||||
|
||||
@objc(permalink)
|
||||
var permalink: String? {
|
||||
var permalink: String? {
|
||||
article.link
|
||||
}
|
||||
|
||||
@objc(externalUrl)
|
||||
var externalUrl: String? {
|
||||
var externalUrl: String? {
|
||||
article.externalLink
|
||||
}
|
||||
|
||||
@objc(title)
|
||||
var title: String {
|
||||
var title: String {
|
||||
article.title ?? ""
|
||||
}
|
||||
|
||||
@objc(contents)
|
||||
var contents: String {
|
||||
var contents: String {
|
||||
article.contentText ?? ""
|
||||
}
|
||||
|
||||
@objc(html)
|
||||
var html: String {
|
||||
var html: String {
|
||||
article.contentHTML ?? ""
|
||||
}
|
||||
|
||||
@objc(summary)
|
||||
var summary: String {
|
||||
var summary: String {
|
||||
article.summary ?? ""
|
||||
}
|
||||
|
||||
@objc(datePublished)
|
||||
var datePublished: Date? {
|
||||
var datePublished: Date? {
|
||||
article.datePublished
|
||||
}
|
||||
|
||||
@objc(dateModified)
|
||||
var dateModified: Date? {
|
||||
var dateModified: Date? {
|
||||
article.dateModified
|
||||
}
|
||||
|
||||
@objc(dateArrived)
|
||||
var dateArrived: Date {
|
||||
var dateArrived: Date {
|
||||
article.status.dateArrived
|
||||
}
|
||||
|
||||
@objc(read)
|
||||
var read: Bool {
|
||||
var read: Bool {
|
||||
get {
|
||||
article.status.boolStatus(forKey: .read)
|
||||
}
|
||||
@@ -115,7 +115,7 @@ import Articles
|
||||
}
|
||||
|
||||
@objc(starred)
|
||||
var starred: Bool {
|
||||
var starred: Bool {
|
||||
get {
|
||||
article.status.boolStatus(forKey: .starred)
|
||||
}
|
||||
@@ -125,12 +125,12 @@ import Articles
|
||||
}
|
||||
|
||||
@objc(deleted)
|
||||
var deleted: Bool {
|
||||
var deleted: Bool {
|
||||
false
|
||||
}
|
||||
|
||||
@objc(imageURL)
|
||||
var imageURL: String {
|
||||
var imageURL: String {
|
||||
article.imageLink ?? ""
|
||||
}
|
||||
|
||||
|
||||
@@ -47,22 +47,22 @@ import Articles
|
||||
// MARK: - Scriptable properties
|
||||
|
||||
@objc(url)
|
||||
var url: String {
|
||||
var url: String {
|
||||
author.url ?? ""
|
||||
}
|
||||
|
||||
@objc(name)
|
||||
var name: String {
|
||||
var name: String {
|
||||
author.name ?? ""
|
||||
}
|
||||
|
||||
@objc(avatarURL)
|
||||
var avatarURL: String {
|
||||
var avatarURL: String {
|
||||
author.avatarURL ?? ""
|
||||
}
|
||||
|
||||
@objc(emailAddress)
|
||||
var emailAddress: String {
|
||||
var emailAddress: String {
|
||||
author.emailAddress ?? ""
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ import RSCore
|
||||
or
|
||||
tell account X to make new folder at end with properties {name:"new folder name"}
|
||||
*/
|
||||
static func handleCreateElement(command: NSCreateCommand) -> Any? {
|
||||
static func handleCreateElement(command: NSCreateCommand) -> Any? {
|
||||
guard command.isCreateCommand(forClass: "fold") else {
|
||||
return nil
|
||||
}
|
||||
@@ -97,7 +97,7 @@ import RSCore
|
||||
// MARK: - Scriptable elements
|
||||
|
||||
@objc(feeds)
|
||||
var feeds: NSArray {
|
||||
var feeds: NSArray {
|
||||
let feeds = Array(folder.topLevelFeeds)
|
||||
return feeds.map { ScriptableFeed($0, container: self) } as NSArray
|
||||
}
|
||||
@@ -142,7 +142,7 @@ import RSCore
|
||||
// MARK: - Scriptable properties
|
||||
|
||||
@objc(name)
|
||||
var name: String {
|
||||
var name: String {
|
||||
folder.name ?? ""
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ extension NSApplication: @preconcurrency ScriptingObjectContainer {
|
||||
}
|
||||
|
||||
func deleteElement(_ element: ScriptingObject) {
|
||||
print ("delete event not handled")
|
||||
print("delete event not handled")
|
||||
}
|
||||
|
||||
nonisolated var scriptingKey: String {
|
||||
@@ -136,7 +136,7 @@ extension NSApplication: @preconcurrency ScriptingObjectContainer {
|
||||
@objc(valueInFeedsWithUniqueID:)
|
||||
func valueInFeeds(withUniqueID id: String) -> ScriptableFeed? {
|
||||
let feeds = allFeeds()
|
||||
guard let feed = feeds.first(where: { $0.feedID == id} ) else {
|
||||
guard let feed = feeds.first(where: { $0.feedID == id}) else {
|
||||
return nil
|
||||
}
|
||||
return ScriptableFeed(feed, container: self)
|
||||
|
||||
@@ -11,9 +11,9 @@ import Account
|
||||
|
||||
@MainActor extension NSScriptCommand {
|
||||
func property(forKey key: String) -> Any? {
|
||||
if let evaluatedArguments = self.evaluatedArguments {
|
||||
if let evaluatedArguments = self.evaluatedArguments {
|
||||
if let props = evaluatedArguments["KeyDictionary"] as? [String: Any] {
|
||||
return props[key]
|
||||
return props[key]
|
||||
}
|
||||
}
|
||||
return nil
|
||||
@@ -26,7 +26,7 @@ import Account
|
||||
guard let newObjectClass = arguments["ObjectClass"] as? Int else {
|
||||
return false
|
||||
}
|
||||
guard (newObjectClass.fourCharCode == whatClass.fourCharCode) else {
|
||||
guard newObjectClass.fourCharCode == whatClass.fourCharCode else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
@@ -42,9 +42,9 @@ import Account
|
||||
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) {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
|
||||
protocol ScriptingObject {
|
||||
var objectSpecifier: NSScriptObjectSpecifier? { get }
|
||||
var objectSpecifier: NSScriptObjectSpecifier? { get }
|
||||
var scriptingKey: String { get }
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ let package = Package(
|
||||
.library(
|
||||
name: "Account",
|
||||
type: .dynamic,
|
||||
targets: ["Account"]),
|
||||
targets: ["Account"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../Articles"),
|
||||
@@ -41,16 +41,16 @@ let package = Package(
|
||||
],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "AccountTests",
|
||||
dependencies: ["Account"],
|
||||
resources: [
|
||||
.copy("JSON"),
|
||||
.copy("JSON")
|
||||
],
|
||||
swiftSettings: [.swiftLanguageMode(.v6)]
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -378,10 +378,10 @@ public enum FetchType {
|
||||
}
|
||||
|
||||
public static func requestOAuthAccessToken(with response: OAuthAuthorizationResponse,
|
||||
client: OAuthAuthorizationClient,
|
||||
accountType: AccountType,
|
||||
transport: Transport = URLSession.webserviceTransport(),
|
||||
completion: @escaping @MainActor (Result<OAuthAuthorizationGrant, Error>) -> Void) {
|
||||
client: OAuthAuthorizationClient,
|
||||
accountType: AccountType,
|
||||
transport: Transport = URLSession.webserviceTransport(),
|
||||
completion: @escaping @MainActor (Result<OAuthAuthorizationGrant, Error>) -> Void) {
|
||||
let grantingType: OAuthAuthorizationGranting.Type
|
||||
|
||||
switch accountType {
|
||||
|
||||
@@ -77,7 +77,7 @@ private extension CloudKitArticlesZoneDelegate {
|
||||
// Parse items on background thread
|
||||
let feedIDsAndItems = await Task.detached(priority: .userInitiated) {
|
||||
let parsedItems = records.compactMap { makeParsedItem($0) }
|
||||
return Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) }
|
||||
return Dictionary(grouping: parsedItems, by: { item in item.feedURL }).mapValues { Set($0) }
|
||||
}.value
|
||||
|
||||
nonisolated(unsafe) var updateError: Error?
|
||||
|
||||
@@ -644,11 +644,11 @@ private extension FeedbinAccountDelegate {
|
||||
for articleIDGroup in articleIDGroups {
|
||||
do {
|
||||
try await apiCall(articleIDGroup)
|
||||
try? await self.syncDatabase.deleteSelectedForProcessing(Set(articleIDGroup.map { String($0) } ))
|
||||
try? await self.syncDatabase.deleteSelectedForProcessing(Set(articleIDGroup.map { String($0) }))
|
||||
} catch {
|
||||
savedError = error
|
||||
Self.logger.error("Feedbin: Article status sync call failed: \(error.localizedDescription)")
|
||||
try? await self.syncDatabase.resetSelectedForProcessing(Set(articleIDGroup.map { String($0) } ))
|
||||
try? await self.syncDatabase.resetSelectedForProcessing(Set(articleIDGroup.map { String($0) }))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -799,7 +799,7 @@ private extension FeedbinAccountDelegate {
|
||||
|
||||
func processEntries(account: Account, entries: [FeedbinEntry]?) async throws {
|
||||
let parsedItems = mapEntriesToParsedItems(entries: entries)
|
||||
let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) }
|
||||
let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL }).mapValues { Set($0) }
|
||||
try await account.updateAsync(feedIDsAndItems: feedIDsAndItems, defaultRead: true)
|
||||
}
|
||||
|
||||
@@ -827,7 +827,7 @@ private extension FeedbinAccountDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
let feedbinUnreadArticleIDs = Set(articleIDs.map { String($0) } )
|
||||
let feedbinUnreadArticleIDs = Set(articleIDs.map { String($0) })
|
||||
let updatableFeedbinUnreadArticleIDs = feedbinUnreadArticleIDs.subtracting(pendingArticleIDs)
|
||||
|
||||
let currentUnreadArticleIDs = try await account.fetchUnreadArticleIDsAsync()
|
||||
@@ -854,7 +854,7 @@ private extension FeedbinAccountDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
let feedbinStarredArticleIDs = Set(articleIDs.map { String($0) } )
|
||||
let feedbinStarredArticleIDs = Set(articleIDs.map { String($0) })
|
||||
let updatableFeedbinStarredArticleIDs = feedbinStarredArticleIDs.subtracting(pendingArticleIDs)
|
||||
|
||||
let currentStarredArticleIDs = try await account.fetchStarredArticleIDsAsync()
|
||||
|
||||
@@ -213,7 +213,7 @@ extension Folder: OPMLRepresentable {
|
||||
|
||||
@MainActor extension Set where Element == Folder {
|
||||
|
||||
func sorted() -> Array<Folder> {
|
||||
func sorted() -> [Folder] {
|
||||
return sorted(by: { (folder1, folder2) -> Bool in
|
||||
return folder1.nameForDisplay.localizedStandardCompare(folder2.nameForDisplay) == .orderedAscending
|
||||
})
|
||||
|
||||
+2
-2
@@ -293,7 +293,7 @@ import os.log
|
||||
return
|
||||
}
|
||||
|
||||
let newsBlurUnreadStoryHashes = Set(hashes.map { $0.hash } )
|
||||
let newsBlurUnreadStoryHashes = Set(hashes.map { $0.hash })
|
||||
let updatableNewsBlurUnreadStoryHashes = newsBlurUnreadStoryHashes.subtracting(pendingStoryHashes)
|
||||
|
||||
let currentUnreadArticleIDs = try await account.fetchUnreadArticleIDsAsync()
|
||||
@@ -320,7 +320,7 @@ import os.log
|
||||
return
|
||||
}
|
||||
|
||||
let newsBlurStarredStoryHashes = Set(hashes.map { $0.hash } )
|
||||
let newsBlurStarredStoryHashes = Set(hashes.map { $0.hash })
|
||||
let updatableNewsBlurUnreadStoryHashes = newsBlurStarredStoryHashes.subtracting(pendingStoryHashes)
|
||||
|
||||
let currentStarredArticleIDs = try await account.fetchStarredArticleIDsAsync()
|
||||
|
||||
@@ -774,7 +774,7 @@ private extension ReaderAPIAccountDelegate {
|
||||
func processEntries(account: Account, entries: [ReaderAPIEntry]?) async {
|
||||
|
||||
let parsedItems = mapEntriesToParsedItems(account: account, entries: entries)
|
||||
let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL } ).mapValues { Set($0) }
|
||||
let feedIDsAndItems = Dictionary(grouping: parsedItems, by: { item in item.feedURL }).mapValues { Set($0) }
|
||||
|
||||
try? await account.updateAsync(feedIDsAndItems: feedIDsAndItems, defaultRead: true)
|
||||
}
|
||||
|
||||
@@ -55,14 +55,12 @@ public extension URLRequest {
|
||||
setValue(auth, forHTTPHeaderField: "Authorization")
|
||||
case .oauthAccessTokenSecret:
|
||||
assertionFailure("Token secrets are used by OAuth1. Did you mean to use `OAuthSwift` instead of a URLRequest?")
|
||||
break
|
||||
case .oauthRefreshToken:
|
||||
// While both access and refresh tokens are credentials, it seems the `Credentials` cases
|
||||
// enumerates how the identity of the user can be proved rather than
|
||||
// credentials-in-general, such as in this refresh token case,
|
||||
// the authority to prove an identity.
|
||||
assertionFailure("Refresh tokens are used to replace expired access tokens. Did you mean to use `accessToken` instead?")
|
||||
break
|
||||
}
|
||||
|
||||
guard let conditionalGet = conditionalGet else {
|
||||
|
||||
@@ -8,10 +8,10 @@ let package = Package(
|
||||
.library(
|
||||
name: "Articles",
|
||||
type: .dynamic,
|
||||
targets: ["Articles"]),
|
||||
targets: ["Articles"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../RSCore"),
|
||||
.package(path: "../RSCore")
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
@@ -21,7 +21,7 @@ let package = Package(
|
||||
],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
]),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
])
|
||||
]
|
||||
)
|
||||
@@ -110,13 +110,21 @@ public extension Article {
|
||||
result.append(text)
|
||||
}
|
||||
|
||||
if let _ = scanner.scanString("<") {
|
||||
if scanner.scanString("<") != nil {
|
||||
// All the allowed tags currently don't allow attributes
|
||||
if let tag = scanner.scanUpToString(">") {
|
||||
if Self.allowedTags.contains(tag.replacingOccurrences(of: "/", with: "")) {
|
||||
forHTML ? result.append("<\(tag)>") : result.append("")
|
||||
if forHTML {
|
||||
result.append("<\(tag)>")
|
||||
} else {
|
||||
result.append("")
|
||||
}
|
||||
} else {
|
||||
forHTML ? result.append("<\(tag)>") : result.append("<\(tag)>")
|
||||
if forHTML {
|
||||
result.append("<\(tag)>")
|
||||
} else {
|
||||
result.append("<\(tag)>")
|
||||
}
|
||||
}
|
||||
|
||||
_ = scanner.scanString(">")
|
||||
|
||||
@@ -93,7 +93,7 @@ public extension Set where Element == ArticleStatus {
|
||||
|
||||
public extension Array where Element == ArticleStatus {
|
||||
|
||||
func articleIDs() -> [String] {
|
||||
func articleIDs() -> [String] {
|
||||
return map { $0.articleID }
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,13 @@ let package = Package(
|
||||
.library(
|
||||
name: "ArticlesDatabase",
|
||||
type: .dynamic,
|
||||
targets: ["ArticlesDatabase"]),
|
||||
targets: ["ArticlesDatabase"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../Articles"),
|
||||
.package(path: "../RSCore"),
|
||||
.package(path: "../RSParser"),
|
||||
.package(path: "../RSDatabase"),
|
||||
.package(path: "../RSDatabase")
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
@@ -23,12 +23,12 @@ let package = Package(
|
||||
"RSCore",
|
||||
"RSDatabase",
|
||||
"RSParser",
|
||||
"Articles",
|
||||
"Articles"
|
||||
],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -36,7 +36,7 @@ public struct ArticleChanges: Sendable {
|
||||
}
|
||||
}
|
||||
|
||||
@MainActor public final class ArticlesDatabase: Sendable {
|
||||
@MainActor public final class ArticlesDatabase {
|
||||
public enum RetentionStyle: Sendable {
|
||||
case feedBased // Local and iCloud: article retention is defined by contents of feed
|
||||
case syncSystem // Feedbin, Feedly, etc.: article retention is defined by external system
|
||||
|
||||
@@ -48,7 +48,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
// MARK: - Fetching Articles for Feed
|
||||
|
||||
func fetchArticles(_ feedID: String) throws -> Set<Article> {
|
||||
return try fetchArticles{ self.fetchArticlesForFeedID(feedID, $0) }
|
||||
return try fetchArticles { self.fetchArticlesForFeedID(feedID, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ feedID: String, _ completion: @escaping ArticleSetResultBlock) {
|
||||
@@ -56,7 +56,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
}
|
||||
|
||||
func fetchArticles(_ feedIDs: Set<String>) throws -> Set<Article> {
|
||||
return try fetchArticles{ self.fetchArticles(feedIDs, $0) }
|
||||
return try fetchArticles { self.fetchArticles(feedIDs, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(_ feedIDs: Set<String>, _ completion: @escaping ArticleSetResultBlock) {
|
||||
@@ -66,7 +66,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
// MARK: - Fetching Articles by articleID
|
||||
|
||||
func fetchArticles(articleIDs: Set<String>) throws -> Set<Article> {
|
||||
return try fetchArticles{ self.fetchArticles(articleIDs: articleIDs, $0) }
|
||||
return try fetchArticles { self.fetchArticles(articleIDs: articleIDs, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesAsync(articleIDs: Set<String>, _ completion: @escaping ArticleSetResultBlock) {
|
||||
@@ -76,7 +76,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
// MARK: - Fetching Unread Articles
|
||||
|
||||
func fetchUnreadArticles(_ feedIDs: Set<String>, _ limit: Int?) throws -> Set<Article> {
|
||||
return try fetchArticles{ self.fetchUnreadArticles(feedIDs, limit, $0) }
|
||||
return try fetchArticles { self.fetchUnreadArticles(feedIDs, limit, $0) }
|
||||
}
|
||||
|
||||
func fetchUnreadArticlesAsync(_ feedIDs: Set<String>, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) {
|
||||
@@ -86,7 +86,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
// MARK: - Fetching Today Articles
|
||||
|
||||
func fetchArticlesSince(_ feedIDs: Set<String>, _ cutoffDate: Date, _ limit: Int?) throws -> Set<Article> {
|
||||
return try fetchArticles{ self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) }
|
||||
return try fetchArticles { self.fetchArticlesSince(feedIDs, cutoffDate, limit, $0) }
|
||||
}
|
||||
|
||||
func fetchArticlesSinceAsync(_ feedIDs: Set<String>, _ cutoffDate: Date, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) {
|
||||
@@ -96,7 +96,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
// MARK: - Fetching Starred Articles
|
||||
|
||||
func fetchStarredArticles(_ feedIDs: Set<String>, _ limit: Int?) throws -> Set<Article> {
|
||||
return try fetchArticles{ self.fetchStarredArticles(feedIDs, limit, $0) }
|
||||
return try fetchArticles { self.fetchStarredArticles(feedIDs, limit, $0) }
|
||||
}
|
||||
|
||||
func fetchStarredArticlesAsync(_ feedIDs: Set<String>, _ limit: Int?, _ completion: @escaping ArticleSetResultBlock) {
|
||||
@@ -104,7 +104,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
}
|
||||
|
||||
func fetchStarredArticlesCount(_ feedIDs: Set<String>) throws -> Int {
|
||||
return try fetchArticlesCount{ self.fetchStarredArticlesCount(feedIDs, $0) }
|
||||
return try fetchArticlesCount { self.fetchStarredArticlesCount(feedIDs, $0) }
|
||||
}
|
||||
|
||||
// MARK: - Fetching Search Articles
|
||||
@@ -130,13 +130,13 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
|
||||
func fetchArticlesMatching(_ searchString: String, _ feedIDs: Set<String>) throws -> Set<Article> {
|
||||
var articles = try fetchArticlesMatching(searchString)
|
||||
articles = articles.filter{ feedIDs.contains($0.feedID) }
|
||||
articles = articles.filter { feedIDs.contains($0.feedID) }
|
||||
return articles
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingWithArticleIDs(_ searchString: String, _ articleIDs: Set<String>) throws -> Set<Article> {
|
||||
var articles = try fetchArticlesMatching(searchString)
|
||||
articles = articles.filter{ articleIDs.contains($0.articleID) }
|
||||
articles = articles.filter { articleIDs.contains($0.articleID) }
|
||||
return articles
|
||||
}
|
||||
|
||||
@@ -543,7 +543,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
queue.runInTransaction { databaseResult in
|
||||
switch databaseResult {
|
||||
case .success(let database):
|
||||
@@ -569,7 +569,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
guard let resultSet = database.executeQuery(sql, withArgumentsIn: nil) else {
|
||||
return
|
||||
}
|
||||
let articleIDs = resultSet.mapToSet{ $0.string(forColumn: DatabaseKey.articleID) }
|
||||
let articleIDs = resultSet.mapToSet { $0.string(forColumn: DatabaseKey.articleID) }
|
||||
if articleIDs.isEmpty {
|
||||
return
|
||||
}
|
||||
@@ -677,7 +677,7 @@ final class ArticlesTable: DatabaseTable, Sendable {
|
||||
guard let resultSet = database.executeQuery(sql, withArgumentsIn: parameters) else {
|
||||
return
|
||||
}
|
||||
let articleIDs = resultSet.mapToSet{ $0.string(forColumn: DatabaseKey.articleID) }
|
||||
let articleIDs = resultSet.mapToSet { $0.string(forColumn: DatabaseKey.articleID) }
|
||||
if articleIDs.isEmpty {
|
||||
return
|
||||
}
|
||||
@@ -734,7 +734,7 @@ nonisolated private extension ArticlesTable {
|
||||
|
||||
private func fetchArticlesCount(_ fetchMethod: @escaping ArticlesCountFetchMethod) throws -> Int {
|
||||
nonisolated(unsafe) var articlesCount = 0
|
||||
nonisolated(unsafe) var error: DatabaseError? = nil
|
||||
nonisolated(unsafe) var error: DatabaseError?
|
||||
|
||||
queue.runInDatabaseSync { databaseResult in
|
||||
switch databaseResult {
|
||||
@@ -859,7 +859,7 @@ nonisolated private extension ArticlesTable {
|
||||
|
||||
func sqliteSearchString(with searchString: String) -> String {
|
||||
var s = ""
|
||||
searchString.enumerateSubstrings(in: searchString.startIndex..<searchString.endIndex, options: .byWords) { (word, _, _, stop) in
|
||||
searchString.enumerateSubstrings(in: searchString.startIndex..<searchString.endIndex, options: .byWords) { (word, _, _, _) in
|
||||
guard let word else {
|
||||
return
|
||||
}
|
||||
@@ -962,13 +962,13 @@ nonisolated private extension ArticlesTable {
|
||||
func fetchArticlesMatching(_ searchString: String, _ feedIDs: Set<String>, _ database: FMDatabase) -> Set<Article> {
|
||||
let articles = fetchArticlesMatching(searchString, database)
|
||||
// TODO: include the feedIDs in the SQL rather than filtering here.
|
||||
return articles.filter{ feedIDs.contains($0.feedID) }
|
||||
return articles.filter { feedIDs.contains($0.feedID) }
|
||||
}
|
||||
|
||||
func fetchArticlesMatchingWithArticleIDs(_ searchString: String, _ articleIDs: Set<String>, _ database: FMDatabase) -> Set<Article> {
|
||||
let articles = fetchArticlesMatching(searchString, database)
|
||||
// TODO: include the articleIDs in the SQL rather than filtering here.
|
||||
return articles.filter{ articleIDs.contains($0.articleID) }
|
||||
return articles.filter { articleIDs.contains($0.articleID) }
|
||||
}
|
||||
|
||||
// MARK: - Saving Parsed Items
|
||||
@@ -1011,7 +1011,7 @@ nonisolated private extension ArticlesTable {
|
||||
// MARK: - Updating Existing Articles
|
||||
|
||||
func articlesWithRelatedObjectChanges<T>(_ comparisonKeyPath: KeyPath<Article, Set<T>?>, _ updatedArticles: Set<Article>, _ fetchedArticles: [String: Article]) -> Set<Article> {
|
||||
return updatedArticles.filter{ (updatedArticle) -> Bool in
|
||||
return updatedArticles.filter { (updatedArticle) -> Bool in
|
||||
if let fetchedArticle = fetchedArticles[updatedArticle.articleID] {
|
||||
return updatedArticle[keyPath: comparisonKeyPath] != fetchedArticle[keyPath: comparisonKeyPath]
|
||||
}
|
||||
@@ -1032,7 +1032,7 @@ nonisolated private extension ArticlesTable {
|
||||
}
|
||||
|
||||
func findUpdatedArticles(_ incomingArticles: Set<Article>, _ fetchedArticlesDictionary: [String: Article]) -> Set<Article>? {
|
||||
let updatedArticles = incomingArticles.filter{ (incomingArticle) -> Bool in // 6
|
||||
let updatedArticles = incomingArticles.filter { (incomingArticle) -> Bool in // 6
|
||||
if let existingArticle = fetchedArticlesDictionary[incomingArticle.articleID] {
|
||||
if existingArticle != incomingArticle {
|
||||
return true
|
||||
@@ -1106,7 +1106,7 @@ nonisolated private extension ArticlesTable {
|
||||
func filterIncomingArticles(_ articles: Set<Article>) -> Set<Article> {
|
||||
// Drop Articles that we can ignore.
|
||||
precondition(retentionStyle == .syncSystem)
|
||||
return Set(articles.filter{ !articleIsIgnorable($0) })
|
||||
return Set(articles.filter { !articleIsIgnorable($0) })
|
||||
}
|
||||
|
||||
func removeArticles(_ articleIDs: Set<String>, _ database: FMDatabase) {
|
||||
|
||||
@@ -62,7 +62,7 @@ extension Article {
|
||||
self.init(accountID: accountID, articleID: parsedItem.syncServiceID, feedID: feedID, uniqueID: parsedItem.uniqueID, title: parsedItem.title, contentHTML: parsedItem.contentHTML, contentText: parsedItem.contentText, markdown: parsedItem.markdown, url: parsedItem.url, externalURL: parsedItem.externalURL, summary: parsedItem.summary, imageURL: parsedItem.imageURL, datePublished: datePublished, dateModified: dateModified, authors: authors, status: status)
|
||||
}
|
||||
|
||||
private func addPossibleStringChangeWithKeyPath(_ comparisonKeyPath: KeyPath<Article,String?>, _ otherArticle: Article, _ key: String, _ dictionary: inout DatabaseDictionary) {
|
||||
private func addPossibleStringChangeWithKeyPath(_ comparisonKeyPath: KeyPath<Article, String?>, _ otherArticle: Article, _ key: String, _ dictionary: inout DatabaseDictionary) {
|
||||
if self[keyPath: comparisonKeyPath] != otherArticle[keyPath: comparisonKeyPath] {
|
||||
dictionary[key] = self[keyPath: comparisonKeyPath] ?? ""
|
||||
}
|
||||
@@ -133,7 +133,7 @@ extension Article {
|
||||
|
||||
static func articlesWithParsedItems(_ parsedItems: Set<ParsedItem>, _ feedID: String, _ accountID: String, _ statusesDictionary: [String: ArticleStatus]) -> Set<Article> {
|
||||
let maximumDateAllowed = _maximumDateAllowed()
|
||||
return Set(parsedItems.map{ Article(parsedItem: $0, maximumDateAllowed: maximumDateAllowed, accountID: accountID, feedID: feedID, status: statusesDictionary[$0.articleID]!) })
|
||||
return Set(parsedItems.map { Article(parsedItem: $0, maximumDateAllowed: maximumDateAllowed, accountID: accountID, feedID: feedID, status: statusesDictionary[$0.articleID]!) })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ extension Set where Element == Article {
|
||||
}
|
||||
|
||||
func databaseObjects() -> [DatabaseObject] {
|
||||
return self.map{ $0 as DatabaseObject }
|
||||
return self.map { $0 as DatabaseObject }
|
||||
}
|
||||
|
||||
func databaseDictionaries() -> [DatabaseDictionary]? {
|
||||
|
||||
@@ -116,7 +116,7 @@ final class SearchTable: DatabaseTable, @unchecked Sendable {
|
||||
|
||||
/// Index new articles.
|
||||
func indexNewArticles(_ articles: Set<Article>, _ database: FMDatabase) {
|
||||
let articleSearchInfos = Set(articles.map{ ArticleSearchInfo(article: $0) })
|
||||
let articleSearchInfos = Set(articles.map { ArticleSearchInfo(article: $0) })
|
||||
performInitialIndexForArticles(articleSearchInfos, database)
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ final class StatusesTable: DatabaseTable, Sendable {
|
||||
return statusWithRow(row, articleID: articleID)
|
||||
}
|
||||
|
||||
func statusWithRow(_ row: FMResultSet, articleID: String) ->ArticleStatus? {
|
||||
func statusWithRow(_ row: FMResultSet, articleID: String) -> ArticleStatus? {
|
||||
if let cachedStatus = cache[articleID] {
|
||||
return cachedStatus
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ let package = Package(
|
||||
.library(
|
||||
name: "CloudKitSync",
|
||||
targets: ["CloudKitSync"]
|
||||
),
|
||||
)
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../RSCore")
|
||||
@@ -21,12 +21,12 @@ let package = Package(
|
||||
],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
name: "CloudKitSyncTests",
|
||||
dependencies: ["CloudKitSync"]
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -29,7 +29,7 @@ public enum CloudKitZoneError: LocalizedError, Sendable {
|
||||
|
||||
// Wrapper to safely transfer non-Sendable values in @Sendable closures
|
||||
// Generic over the Success type of the Result
|
||||
fileprivate struct CloudKitZoneCaptures<Success>: @unchecked Sendable {
|
||||
private struct CloudKitZoneCaptures<Success>: @unchecked Sendable {
|
||||
weak var zone: (any CloudKitZone)?
|
||||
let completion: (Result<Success, Error>) -> Void
|
||||
}
|
||||
@@ -119,7 +119,7 @@ public extension CloudKitZone {
|
||||
return CKRecord.ID(recordName: UUID().uuidString, zoneID: zoneID)
|
||||
}
|
||||
|
||||
func retryIfPossible(after: Double, block: @escaping @MainActor () -> ()) {
|
||||
func retryIfPossible(after: Double, block: @escaping @MainActor () -> Void) {
|
||||
let delayTime = DispatchTime.now() + after
|
||||
DispatchQueue.main.asyncAfter(deadline: delayTime, execute: {
|
||||
block()
|
||||
@@ -148,7 +148,7 @@ public extension CloudKitZone {
|
||||
return
|
||||
}
|
||||
|
||||
database.save(CKRecordZone(zoneID: zoneID)) { (recordZone, error) in
|
||||
database.save(CKRecordZone(zoneID: zoneID)) { (_, error) in
|
||||
Task { @MainActor in
|
||||
if let error {
|
||||
completion(.failure(CloudKitError(error)))
|
||||
@@ -185,7 +185,7 @@ public extension CloudKitZone {
|
||||
op.desiredKeys = desiredKeys
|
||||
}
|
||||
|
||||
op.recordMatchedBlock = { recordID, result in
|
||||
op.recordMatchedBlock = { _, result in
|
||||
if let record = try? result.get() {
|
||||
records.append(record)
|
||||
}
|
||||
@@ -213,7 +213,7 @@ public extension CloudKitZone {
|
||||
completion(.success(records))
|
||||
}
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
self.createZoneRecord { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.query(ckQuery, desiredKeys: desiredKeys, completion: completion)
|
||||
@@ -254,7 +254,7 @@ public extension CloudKitZone {
|
||||
op.desiredKeys = desiredKeys
|
||||
}
|
||||
|
||||
op.recordMatchedBlock = { recordID, result in
|
||||
op.recordMatchedBlock = { _, result in
|
||||
if let record = try? result.get() {
|
||||
records.append(record)
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public extension CloudKitZone {
|
||||
completion(.success(records))
|
||||
}
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
self.createZoneRecord { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.query(cursor: cursor, desiredKeys: desiredKeys, carriedRecords: records, completion: completion)
|
||||
@@ -341,7 +341,7 @@ public extension CloudKitZone {
|
||||
}
|
||||
}
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
self.createZoneRecord { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.fetch(externalID: externalID, completion: captures.completion)
|
||||
@@ -403,7 +403,7 @@ public extension CloudKitZone {
|
||||
}
|
||||
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
self.createZoneRecord { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.saveIfNew(records, completion: completion)
|
||||
@@ -475,7 +475,7 @@ public extension CloudKitZone {
|
||||
captures.completion(.success((savedSubscription!)))
|
||||
}
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
self.createZoneRecord { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.save(subscription, completion: captures.completion)
|
||||
@@ -506,7 +506,7 @@ public extension CloudKitZone {
|
||||
|
||||
let op = CKQueryOperation(query: ckQuery)
|
||||
op.qualityOfService = Self.qualityOfService
|
||||
op.recordMatchedBlock = { recordID, result in
|
||||
op.recordMatchedBlock = { _, result in
|
||||
if let record = try? result.get() {
|
||||
records.append(record)
|
||||
}
|
||||
@@ -550,7 +550,7 @@ public extension CloudKitZone {
|
||||
|
||||
let op = CKQueryOperation(cursor: cursor)
|
||||
op.qualityOfService = Self.qualityOfService
|
||||
op.recordMatchedBlock = { recordID, result in
|
||||
op.recordMatchedBlock = { _, result in
|
||||
if let record = try? result.get() {
|
||||
records.append(record)
|
||||
}
|
||||
@@ -667,7 +667,7 @@ public extension CloudKitZone {
|
||||
completion(.success(()))
|
||||
}
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
self.createZoneRecord { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.modify(recordsToSave: recordsToSave, recordIDsToDelete: recordIDsToDelete, completion: completion)
|
||||
@@ -728,7 +728,7 @@ public extension CloudKitZone {
|
||||
}
|
||||
}
|
||||
|
||||
saveChunks() { result in
|
||||
saveChunks { result in
|
||||
switch result {
|
||||
case .success:
|
||||
deleteChunks()
|
||||
@@ -764,11 +764,11 @@ public extension CloudKitZone {
|
||||
op.fetchAllChanges = true
|
||||
op.qualityOfService = Self.qualityOfService
|
||||
|
||||
op.recordZoneChangeTokensUpdatedBlock = { zoneID, token, _ in
|
||||
op.recordZoneChangeTokensUpdatedBlock = { _, token, _ in
|
||||
savedChangeToken = token
|
||||
}
|
||||
|
||||
op.recordWasChangedBlock = { recordID, result in
|
||||
op.recordWasChangedBlock = { _, result in
|
||||
if let record = try? result.get() {
|
||||
changedRecords.append(record)
|
||||
}
|
||||
@@ -779,7 +779,7 @@ public extension CloudKitZone {
|
||||
deletedRecordKeys.append(recordKey)
|
||||
}
|
||||
|
||||
op.recordZoneFetchResultBlock = { zoneID, result in
|
||||
op.recordZoneFetchResultBlock = { _, result in
|
||||
if case .success(let (serverChangeToken, _, _)) = result {
|
||||
savedChangeToken = serverChangeToken
|
||||
}
|
||||
@@ -815,7 +815,7 @@ public extension CloudKitZone {
|
||||
}
|
||||
}
|
||||
case .zoneNotFound:
|
||||
self.createZoneRecord() { result in
|
||||
self.createZoneRecord { result in
|
||||
switch result {
|
||||
case .success:
|
||||
self.fetchChangesInZone(completion: completion)
|
||||
|
||||
@@ -63,13 +63,13 @@ public enum CloudKitZoneResult {
|
||||
private extension CloudKitZoneResult {
|
||||
|
||||
static func anyRequestErrors(_ errors: [AnyHashable: CKError]) -> CloudKitZoneResult? {
|
||||
if errors.values.contains(where: { $0.code == .changeTokenExpired } ) {
|
||||
if errors.values.contains(where: { $0.code == .changeTokenExpired }) {
|
||||
return .changeTokenExpired
|
||||
}
|
||||
if errors.values.contains(where: { $0.code == .zoneNotFound } ) {
|
||||
if errors.values.contains(where: { $0.code == .zoneNotFound }) {
|
||||
return .zoneNotFound
|
||||
}
|
||||
if errors.values.contains(where: { $0.code == .userDeletedZone } ) {
|
||||
if errors.values.contains(where: { $0.code == .userDeletedZone }) {
|
||||
return .userDeletedZone
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -15,7 +15,7 @@ let package = Package(
|
||||
dependencies: ["RSCoreObjC"],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
.target(
|
||||
@@ -33,7 +33,7 @@ let package = Package(
|
||||
],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
@@ -41,6 +41,6 @@ let package = Package(
|
||||
dependencies: ["RSCore"],
|
||||
resources: [.copy("Resources")],
|
||||
swiftSettings: [.swiftLanguageMode(.v5)]
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -102,7 +102,7 @@ public struct KeyboardKey: Hashable, Sendable {
|
||||
|
||||
var integerValue = 0
|
||||
|
||||
switch(s) {
|
||||
switch s {
|
||||
case "[space]":
|
||||
integerValue = " ".keyboardIntegerValue!
|
||||
case "[uparrow]":
|
||||
|
||||
@@ -64,7 +64,7 @@ public extension NSOutlineView {
|
||||
|
||||
while true {
|
||||
row += 1
|
||||
if let _ = item(atRow: row) {
|
||||
if item(atRow: row) != nil {
|
||||
if canSelect(row) {
|
||||
selectRowAndScrollToVisible(row)
|
||||
return
|
||||
|
||||
@@ -13,12 +13,12 @@ public extension NSResponder {
|
||||
|
||||
func hasAncestor(_ ancestor: NSResponder) -> Bool {
|
||||
var nomad: NSResponder = self
|
||||
while(true) {
|
||||
while true {
|
||||
if nomad === ancestor {
|
||||
return true
|
||||
}
|
||||
if let _ = nomad.nextResponder {
|
||||
nomad = nomad.nextResponder!
|
||||
if let next = nomad.nextResponder {
|
||||
nomad = next
|
||||
} else {
|
||||
break
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ public extension NSTableView {
|
||||
let documentVisibleRect = scrollView.documentVisibleRect
|
||||
|
||||
let r = rect(ofRow: row)
|
||||
if NSContainsRect(documentVisibleRect, r) {
|
||||
if documentVisibleRect.contains(r) {
|
||||
return
|
||||
}
|
||||
|
||||
let rMidY = NSMidY(r)
|
||||
let rMidY = r.midY
|
||||
var scrollPoint = NSPoint.zero
|
||||
scrollPoint.y = floor(rMidY - (documentVisibleRect.size.height / 2.0)) + CGFloat(extraHeight)
|
||||
scrollPoint.y = max(scrollPoint.y, 0)
|
||||
@@ -54,7 +54,7 @@ public extension NSTableView {
|
||||
|
||||
let clipView = scrollView.contentView
|
||||
|
||||
let rClipView = NSRect(x: scrollPoint.x, y: scrollPoint.y, width: NSWidth(clipView.bounds), height: NSHeight(clipView.bounds))
|
||||
let rClipView = NSRect(x: scrollPoint.x, y: scrollPoint.y, width: clipView.bounds.width, height: clipView.bounds.height)
|
||||
|
||||
clipView.animator().bounds = rClipView
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ import Cocoa
|
||||
// every time the app becomes active. This catches a good number of edge-case
|
||||
// changes to the app bundle's path, such as when a containing folder or the
|
||||
// volume name changes.
|
||||
NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: nil) { notification in
|
||||
NotificationCenter.default.addObserver(forName: NSApplication.didBecomeActiveNotification, object: nil, queue: nil) { _ in
|
||||
Task { @MainActor in
|
||||
// Removing observer in invalidate doesn't seem to prevent this getting called? Maybe
|
||||
// because it's on the same invocation of the runloop?
|
||||
|
||||
@@ -12,7 +12,7 @@ import AppKit
|
||||
public class RSToolbarItem: NSToolbarItem {
|
||||
|
||||
override public func validate() {
|
||||
guard let view = view, let _ = view.window else {
|
||||
guard let view = view, view.window != nil else {
|
||||
isEnabled = false
|
||||
return
|
||||
}
|
||||
@@ -34,7 +34,7 @@ private extension RSToolbarItem {
|
||||
return false
|
||||
}
|
||||
|
||||
while(true) {
|
||||
while true {
|
||||
if let validated = validateWithResponder(responder!) {
|
||||
return validated
|
||||
}
|
||||
|
||||
@@ -18,11 +18,11 @@ import AppKit
|
||||
self.urlString = urlString
|
||||
}
|
||||
|
||||
public class func write(urlString: String, to pasteboard: NSPasteboard) {
|
||||
public static func write(urlString: String, to pasteboard: NSPasteboard) {
|
||||
write(urlStrings: [urlString], to: pasteboard)
|
||||
}
|
||||
|
||||
public class func write(urlStrings: [String], to pasteboard: NSPasteboard) {
|
||||
public static func write(urlStrings: [String], to pasteboard: NSPasteboard) {
|
||||
assert(!urlStrings.isEmpty)
|
||||
guard !urlStrings.isEmpty else {
|
||||
return
|
||||
@@ -36,7 +36,7 @@ import AppKit
|
||||
// MARK: - NSPasteboardWriting
|
||||
|
||||
public func writableTypes(for pasteboard: NSPasteboard) -> [NSPasteboard.PasteboardType] {
|
||||
if let _ = URL(string: urlString) {
|
||||
if URL(string: urlString) != nil {
|
||||
return [.URL, .string]
|
||||
}
|
||||
return [.string]
|
||||
|
||||
@@ -49,7 +49,7 @@ public extension Notification.Name {
|
||||
public func end() {
|
||||
precondition(Thread.isMainThread)
|
||||
decrementCount()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private extension BatchUpdate {
|
||||
|
||||
@@ -112,7 +112,7 @@ import Foundation
|
||||
|
||||
operation.callCompletionBlock()
|
||||
operation.noteDidComplete()
|
||||
|
||||
|
||||
pendingOperations.removeAll { $0 == operation }
|
||||
if currentOperation == operation {
|
||||
currentOperation = nil
|
||||
@@ -155,7 +155,7 @@ private extension MainThreadOperationQueue {
|
||||
return
|
||||
}
|
||||
hasPendingRunScheduled = true
|
||||
|
||||
|
||||
Task {
|
||||
hasPendingRunScheduled = false
|
||||
guard !isSuspended && currentOperation == nil else {
|
||||
@@ -173,7 +173,7 @@ private extension MainThreadOperationQueue {
|
||||
guard let index = pendingOperations.firstIndex(where: { operationIsAvailable($0) }) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
let operation = pendingOperations[index]
|
||||
pendingOperations.remove(at: index)
|
||||
assert(!pendingOperations.contains(where: { $0 == operation }))
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class InteractiveLabel: UILabel, @preconcurrency UIEditMenuInteract
|
||||
|
||||
public func editMenuInteraction(_ interaction: UIEditMenuInteraction, menuFor configuration: UIEditMenuConfiguration, suggestedActions: [UIMenuElement]) -> UIMenu? {
|
||||
|
||||
let copyAction = UIAction(title: "Copy", image: nil) { [weak self] action in
|
||||
let copyAction = UIAction(title: "Copy", image: nil) { [weak self] _ in
|
||||
self?.copy(nil)
|
||||
}
|
||||
return UIMenu(title: "", children: [copyAction])
|
||||
|
||||
@@ -12,7 +12,7 @@ import Foundation
|
||||
import UIKit
|
||||
|
||||
extension UICollectionView {
|
||||
|
||||
|
||||
/// Selects an item and scrolls it to the middle if it is not visible
|
||||
public func selectItemAndScrollIfNotVisible(at indexPath: IndexPath, animations: Animations) {
|
||||
guard let dataSource = dataSource,
|
||||
|
||||
@@ -27,7 +27,7 @@ public final class WebViewWindowController: NSWindowController {
|
||||
public func displayContents(of path: String) {
|
||||
// We assume there might be images, style sheets, etc. contained by the folder that the file appears in, so we get read access to the parent folder.
|
||||
|
||||
let _ = self.window
|
||||
_ = self.window
|
||||
|
||||
let fileURL = URL(fileURLWithPath: path)
|
||||
let folderURL = fileURL.deletingLastPathComponent()
|
||||
|
||||
@@ -12,7 +12,7 @@ let package = Package(
|
||||
.library(
|
||||
name: "RSDatabaseObjC",
|
||||
type: .dynamic,
|
||||
targets: ["RSDatabaseObjC"]),
|
||||
targets: ["RSDatabaseObjC"])
|
||||
],
|
||||
dependencies: [
|
||||
],
|
||||
@@ -22,7 +22,7 @@ let package = Package(
|
||||
dependencies: ["RSDatabaseObjC"],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
.target(
|
||||
@@ -31,6 +31,6 @@ let package = Package(
|
||||
),
|
||||
.testTarget(
|
||||
name: "RSDatabaseTests",
|
||||
dependencies: ["RSDatabase"]),
|
||||
dependencies: ["RSDatabase"])
|
||||
]
|
||||
)
|
||||
@@ -55,7 +55,7 @@ extension Array where Element == DatabaseObject {
|
||||
|
||||
func databaseDictionaries() -> [DatabaseDictionary]? {
|
||||
|
||||
let dictionaries = self.compactMap{ $0.databaseDictionary() }
|
||||
let dictionaries = self.compactMap { $0.databaseDictionary() }
|
||||
return dictionaries.isEmpty ? nil : dictionaries
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public extension DatabaseTable {
|
||||
|
||||
func insertRows(_ dictionaries: [DatabaseDictionary], insertType: RSDatabaseInsertType, in database: FMDatabase) {
|
||||
dictionaries.forEach { (oneDictionary) in
|
||||
let _ = database.rs_insertRow(with: oneDictionary, insertType: insertType, tableName: self.name)
|
||||
_ = database.rs_insertRow(with: oneDictionary, insertType: insertType, tableName: self.name)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ public extension DatabaseTable {
|
||||
func containsColumn(_ columnName: String, in database: FMDatabase) -> Bool {
|
||||
if let resultSet = database.executeQuery("select * from \(name) limit 1;", withArgumentsIn: nil) {
|
||||
if let columnMap = resultSet.columnNameToIndexMap {
|
||||
if let _ = columnMap[columnName.lowercased()] {
|
||||
if columnMap[columnName.lowercased()] != nil {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ public extension FMDatabase {
|
||||
guard let resultSet = executeQuery(sql, withArgumentsIn: parameters) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
let count = resultSet.intWithCountResult()
|
||||
return count
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public extension FMResultSet {
|
||||
|
||||
let count = Int(long(forColumnIndex: 0))
|
||||
close()
|
||||
|
||||
|
||||
return count
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public extension DatabaseRelatedObjectsTable {
|
||||
|
||||
// Objects in cache must already exist in database. Filter them out.
|
||||
let objectsToSave = objects.filter { (object) -> Bool in
|
||||
if let _ = cache[object.databaseID] {
|
||||
if cache[object.databaseID] != nil {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
@@ -22,7 +22,7 @@ public struct RelatedObjectsMap: Sendable {
|
||||
for objectID in relatedObjectIDsMap.objectIDs() {
|
||||
|
||||
if let relatedObjectIDs = relatedObjectIDsMap[objectID] {
|
||||
let relatedObjects = relatedObjectIDs.compactMap{ relatedObjectsDictionary[$0] }
|
||||
let relatedObjects = relatedObjectIDs.compactMap { relatedObjectsDictionary[$0] }
|
||||
if !relatedObjects.isEmpty {
|
||||
d[objectID] = relatedObjects
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ let package = Package(
|
||||
.library(
|
||||
name: "RSParserObjC",
|
||||
type: .dynamic,
|
||||
targets: ["RSParserObjC"]),
|
||||
targets: ["RSParserObjC"])
|
||||
],
|
||||
dependencies: [
|
||||
.package(path: "../RSMarkdown")
|
||||
@@ -24,7 +24,7 @@ let package = Package(
|
||||
path: "Sources/Swift",
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]),
|
||||
.target(
|
||||
name: "RSParserObjC",
|
||||
@@ -41,8 +41,8 @@ let package = Package(
|
||||
resources: [.copy("Resources")],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
)
|
||||
]
|
||||
)
|
||||
@@ -58,7 +58,7 @@ public struct JSONFeedParser {
|
||||
throw FeedParserError.invalidJSON
|
||||
}
|
||||
|
||||
guard let version = d[Key.version] as? String, let _ = version.range(of: JSONFeedParser.jsonFeedVersionMarker) else {
|
||||
guard let version = d[Key.version] as? String, version.range(of: JSONFeedParser.jsonFeedVersionMarker) != nil else {
|
||||
throw FeedParserError.jsonFeedVersionNotFound
|
||||
}
|
||||
guard let itemsArray = d[Key.items] as? JSONArray else {
|
||||
|
||||
@@ -116,11 +116,11 @@ private extension RSSInJSONParser {
|
||||
}
|
||||
if s.isEmpty {
|
||||
// Sheesh. Tough case.
|
||||
if let _ = contentHTML {
|
||||
s = contentHTML!
|
||||
if let html = contentHTML {
|
||||
s = html
|
||||
}
|
||||
if let _ = contentText {
|
||||
s = contentText!
|
||||
if let text = contentText {
|
||||
s = text
|
||||
}
|
||||
}
|
||||
uniqueID = (s as NSString).rsparser_md5Hash()
|
||||
@@ -149,7 +149,7 @@ private extension RSSInJSONParser {
|
||||
}
|
||||
return nil
|
||||
} else if let categoryArray = itemDictionary["category"] as? JSONArray {
|
||||
return Set(categoryArray.compactMap{ $0["#value"] as? String })
|
||||
return Set(categoryArray.compactMap { $0["#value"] as? String })
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -30,23 +30,23 @@ public struct ParsedItem: Hashable, Sendable {
|
||||
public let attachments: Set<ParsedAttachment>?
|
||||
|
||||
public init(syncServiceID: String?,
|
||||
uniqueID: String,
|
||||
feedURL: String,
|
||||
url: String?,
|
||||
externalURL: String?,
|
||||
title: String?,
|
||||
language: String?,
|
||||
contentHTML: String?,
|
||||
contentText: String?,
|
||||
markdown: String?,
|
||||
summary: String?,
|
||||
imageURL: String?,
|
||||
bannerImageURL: String?,
|
||||
datePublished: Date?,
|
||||
dateModified: Date?,
|
||||
authors: Set<ParsedAuthor>?,
|
||||
tags: Set<String>?,
|
||||
attachments: Set<ParsedAttachment>?) {
|
||||
uniqueID: String,
|
||||
feedURL: String,
|
||||
url: String?,
|
||||
externalURL: String?,
|
||||
title: String?,
|
||||
language: String?,
|
||||
contentHTML: String?,
|
||||
contentText: String?,
|
||||
markdown: String?,
|
||||
summary: String?,
|
||||
imageURL: String?,
|
||||
bannerImageURL: String?,
|
||||
datePublished: Date?,
|
||||
dateModified: Date?,
|
||||
authors: Set<ParsedAuthor>?,
|
||||
tags: Set<String>?,
|
||||
attachments: Set<ParsedAttachment>?) {
|
||||
self.syncServiceID = syncServiceID
|
||||
self.uniqueID = uniqueID
|
||||
self.feedURL = feedURL
|
||||
|
||||
@@ -118,7 +118,7 @@ final class HTMLMetadataTests: XCTestCase {
|
||||
// 0.002 sec on my 2012 iMac
|
||||
let d = parserData("sixcolors", "html", "http://sixcolors.com/")
|
||||
self.measure {
|
||||
let _ = RSHTMLMetadataParser.htmlMetadata(with: d)
|
||||
_ = RSHTMLMetadataParser.htmlMetadata(with: d)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ let package = Package(
|
||||
.library(
|
||||
name: "RSTree",
|
||||
type: .dynamic,
|
||||
targets: ["RSTree"]),
|
||||
targets: ["RSTree"])
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
@@ -16,7 +16,7 @@ let package = Package(
|
||||
dependencies: [],
|
||||
swiftSettings: [
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
]),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
])
|
||||
]
|
||||
)
|
||||
@@ -80,7 +80,7 @@ private extension TreeController {
|
||||
|
||||
func visitNode(_ node: Node, _ visitBlock: NodeVisitBlock) {
|
||||
visitBlock(node)
|
||||
node.childNodes.forEach{ (oneChildNode) in
|
||||
node.childNodes.forEach { (oneChildNode) in
|
||||
visitNode(oneChildNode, visitBlock)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ let package = Package(
|
||||
swiftSettings: [
|
||||
.unsafeFlags(["-warnings-as-errors"]),
|
||||
.enableUpcomingFeature("NonisolatedNonsendingByDefault"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances"),
|
||||
.enableUpcomingFeature("InferIsolatedConformances")
|
||||
]
|
||||
),
|
||||
.testTarget(
|
||||
|
||||
@@ -199,7 +199,7 @@ extension DownloadSession: @preconcurrency URLSessionDataDelegate {
|
||||
return
|
||||
}
|
||||
info.addData(data)
|
||||
|
||||
|
||||
if !delegate.downloadSession(self, shouldContinueAfterReceivingData: info.data as Data, url: info.url) {
|
||||
dataTask.cancel()
|
||||
removeTask(dataTask)
|
||||
|
||||
@@ -75,7 +75,7 @@ private extension String {
|
||||
let lowerPrefix = prefix.lowercased()
|
||||
let lowerSelf = self.lowercased()
|
||||
|
||||
if (lowerSelf == lowerPrefix) {
|
||||
if lowerSelf == lowerPrefix {
|
||||
return ""
|
||||
}
|
||||
if !lowerSelf.hasPrefix(lowerPrefix) {
|
||||
|
||||
@@ -193,7 +193,7 @@ nonisolated extension URLSession: Transport {
|
||||
var sendRequest = request
|
||||
sendRequest.httpMethod = method
|
||||
|
||||
let task = self.dataTask(with: sendRequest) { (data, response, error) in
|
||||
let task = self.dataTask(with: sendRequest) { (_, response, error) in
|
||||
DispatchQueue.main.async {
|
||||
if let error = error {
|
||||
return completion(.failure(error))
|
||||
|
||||
@@ -254,9 +254,9 @@ private struct DeleteActionName {
|
||||
var numberOfFolders = 0
|
||||
|
||||
for node in nodes {
|
||||
if node.representedObject as? Feed != nil {
|
||||
if node.representedObject is Feed {
|
||||
numberOfFeeds += 1
|
||||
} else if node.representedObject as? Folder != nil {
|
||||
} else if node.representedObject is Folder {
|
||||
numberOfFolders += 1
|
||||
} else {
|
||||
return nil // Delete only Feeds and Folders.
|
||||
|
||||
@@ -161,7 +161,7 @@ final class FeedbinAccountViewController: UITableViewController {
|
||||
actionButton.isEnabled = value
|
||||
}
|
||||
|
||||
private func toggleActivityIndicatorAnimation(visible value: Bool){
|
||||
private func toggleActivityIndicatorAnimation(visible value: Bool) {
|
||||
activityIndicator.isHidden = !value
|
||||
if value {
|
||||
activityIndicator.startAnimating()
|
||||
|
||||
@@ -230,7 +230,7 @@ final class ReaderAPIAccountViewController: UITableViewController {
|
||||
showError(NSLocalizedString("Username, password, and API URL are required.", comment: "Credentials Error"))
|
||||
return false
|
||||
}
|
||||
guard let _ = URL(string: apiURLTextField.text!) else {
|
||||
guard URL(string: apiURLTextField.text!) != nil else {
|
||||
showError(NSLocalizedString("Invalid API URL.", comment: "Invalid API URL"))
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ final class AppDefaults: Sendable {
|
||||
}()
|
||||
|
||||
let isFirstRun: Bool = {
|
||||
if AppDefaults.store.object(forKey: Key.firstRunDate) as? Date != nil {
|
||||
if AppDefaults.store.object(forKey: Key.firstRunDate) is Date {
|
||||
return false
|
||||
}
|
||||
firstRunDate = Date()
|
||||
|
||||
@@ -82,7 +82,7 @@ import Secrets
|
||||
self.updateBadge()
|
||||
}
|
||||
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, error) in
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .sound, .alert]) { (granted, _) in
|
||||
if granted {
|
||||
DispatchQueue.main.async {
|
||||
UIApplication.shared.registerForRemoteNotifications()
|
||||
@@ -143,8 +143,8 @@ import Secrets
|
||||
|
||||
// MARK: - API
|
||||
|
||||
func manualRefresh(errorHandler: @escaping @Sendable (Error) -> ()) {
|
||||
UIApplication.shared.connectedScenes.compactMap( { $0.delegate as? SceneDelegate } ).forEach {
|
||||
func manualRefresh(errorHandler: @escaping @Sendable (Error) -> Void) {
|
||||
UIApplication.shared.connectedScenes.compactMap( { $0.delegate as? SceneDelegate }).forEach {
|
||||
$0.cleanUp(conditional: true)
|
||||
}
|
||||
AccountManager.shared.refreshAllWithoutWaiting(errorHandler: errorHandler)
|
||||
@@ -264,7 +264,7 @@ private extension AppDelegate {
|
||||
}
|
||||
|
||||
DispatchQueue.main.async { [weak self] in
|
||||
self?.waitToComplete() { [weak self] suspend in
|
||||
self?.waitToComplete { [weak self] suspend in
|
||||
self?.completeProcessing(suspend)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -364,8 +364,7 @@ public extension Notification.Name {
|
||||
extension ArticleViewController: SearchBarDelegate {
|
||||
|
||||
func searchBar(_ searchBar: ArticleSearchBar, textDidChange searchText: String) {
|
||||
currentWebViewController?.searchText(searchText) {
|
||||
found in
|
||||
currentWebViewController?.searchText(searchText) { found in
|
||||
searchBar.resultsCount = found.count
|
||||
|
||||
if let index = found.index {
|
||||
|
||||
@@ -21,7 +21,7 @@ final class FindInArticleActivity: UIActivity {
|
||||
UIImage(systemName: "magnifyingglass", withConfiguration: UIImage.SymbolConfiguration(pointSize: 20, weight: .regular))
|
||||
}
|
||||
|
||||
override class var activityCategory: UIActivity.Category {
|
||||
override static var activityCategory: UIActivity.Category {
|
||||
.action
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ final class ImageTransition: NSObject, UIViewControllerAnimatedTransitioning {
|
||||
imageView.frame = self.originFrame
|
||||
}, completion: { _ in
|
||||
if let controller = self.webViewController {
|
||||
controller.showClickedImage() {
|
||||
controller.showClickedImage {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
imageView.removeFromSuperview()
|
||||
transitionContext.completeTransition(true)
|
||||
|
||||
@@ -58,7 +58,7 @@ final class ImageViewController: UIViewController {
|
||||
|
||||
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
|
||||
super.viewWillTransition(to: size, with: coordinator)
|
||||
coordinator.animate(alongsideTransition: { [weak self] context in
|
||||
coordinator.animate(alongsideTransition: { [weak self] _ in
|
||||
self?.imageScrollView.resize()
|
||||
})
|
||||
}
|
||||
@@ -75,7 +75,7 @@ final class ImageViewController: UIViewController {
|
||||
dismiss(animated: true)
|
||||
}
|
||||
|
||||
private func layoutTitleLabel(){
|
||||
private func layoutTitleLabel() {
|
||||
let width = view.frame.width
|
||||
let multiplier = traitCollection.userInterfaceIdiom == .pad ? CGFloat(0.1) : CGFloat(0.04)
|
||||
titleLeading.constant += width * multiplier
|
||||
|
||||
@@ -24,7 +24,7 @@ final class OpenInBrowserActivity: UIActivity {
|
||||
return UIActivity.ActivityType(rawValue: "com.rancharo.NetNewsWire-Evergreen.safari")
|
||||
}
|
||||
|
||||
override class var activityCategory: UIActivity.Category {
|
||||
override static var activityCategory: UIActivity.Category {
|
||||
return .action
|
||||
}
|
||||
|
||||
|
||||
@@ -321,7 +321,7 @@ extension WebViewController: ArticleExtractorDelegate {
|
||||
extension WebViewController: UIContextMenuInteractionDelegate {
|
||||
func contextMenuInteraction(_ interaction: UIContextMenuInteraction, configurationForMenuAtLocation location: CGPoint) -> UIContextMenuConfiguration? {
|
||||
|
||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: contextMenuPreviewProvider) { [weak self] suggestedActions in
|
||||
return UIContextMenuConfiguration(identifier: nil, previewProvider: contextMenuPreviewProvider) { [weak self] _ in
|
||||
guard let self = self else { return nil }
|
||||
|
||||
var menus = [UIMenu]()
|
||||
@@ -530,7 +530,7 @@ private extension WebViewController {
|
||||
return
|
||||
}
|
||||
|
||||
coordinator.webViewProvider.dequeueWebView() { webView in
|
||||
coordinator.webViewProvider.dequeueWebView { webView in
|
||||
|
||||
webView.ready {
|
||||
|
||||
@@ -658,7 +658,7 @@ private extension WebViewController {
|
||||
|
||||
guard let imageURL = URL(string: clickMessage.imageURL) else { return }
|
||||
|
||||
Downloader.shared.download(imageURL) { [weak self] data, response, error in
|
||||
Downloader.shared.download(imageURL) { [weak self] data, _, error in
|
||||
guard let self, let data, error == nil, !data.isEmpty,
|
||||
let image = UIImage(data: data) else {
|
||||
return
|
||||
@@ -751,7 +751,7 @@ private extension WebViewController {
|
||||
func prevArticleAction() -> UIAction? {
|
||||
guard coordinator.isPrevArticleAvailable else { return nil }
|
||||
let title = NSLocalizedString("Previous Article", comment: "Previous Article")
|
||||
return UIAction(title: title, image: Assets.Images.prevArticle) { [weak self] action in
|
||||
return UIAction(title: title, image: Assets.Images.prevArticle) { [weak self] _ in
|
||||
self?.coordinator.selectPrevArticle()
|
||||
}
|
||||
}
|
||||
@@ -759,7 +759,7 @@ private extension WebViewController {
|
||||
func nextArticleAction() -> UIAction? {
|
||||
guard coordinator.isNextArticleAvailable else { return nil }
|
||||
let title = NSLocalizedString("Next Article", comment: "Next Article")
|
||||
return UIAction(title: title, image: Assets.Images.nextArticle) { [weak self] action in
|
||||
return UIAction(title: title, image: Assets.Images.nextArticle) { [weak self] _ in
|
||||
self?.coordinator.selectNextArticle()
|
||||
}
|
||||
}
|
||||
@@ -769,7 +769,7 @@ private extension WebViewController {
|
||||
|
||||
let title = article.status.read ? NSLocalizedString("Mark as Unread", comment: "Mark as Unread") : NSLocalizedString("Mark as Read", comment: "Mark as Read")
|
||||
let readImage = article.status.read ? Assets.Images.circleClosed : Assets.Images.circleOpen
|
||||
return UIAction(title: title, image: readImage) { [weak self] action in
|
||||
return UIAction(title: title, image: readImage) { [weak self] _ in
|
||||
self?.coordinator.toggleReadForCurrentArticle()
|
||||
}
|
||||
}
|
||||
@@ -778,7 +778,7 @@ private extension WebViewController {
|
||||
let starred = article?.status.starred ?? false
|
||||
let title = starred ? NSLocalizedString("Mark as Unstarred", comment: "Mark as Unstarred") : NSLocalizedString("Mark as Starred", comment: "Mark as Starred")
|
||||
let starredImage = starred ? Assets.Images.starOpen : Assets.Images.starClosed
|
||||
return UIAction(title: title, image: starredImage) { [weak self] action in
|
||||
return UIAction(title: title, image: starredImage) { [weak self] _ in
|
||||
self?.coordinator.toggleStarredForCurrentArticle()
|
||||
}
|
||||
}
|
||||
@@ -786,7 +786,7 @@ private extension WebViewController {
|
||||
func nextUnreadArticleAction() -> UIAction? {
|
||||
guard coordinator.isAnyUnreadAvailable else { return nil }
|
||||
let title = NSLocalizedString("Next Unread Article", comment: "Next Unread Article")
|
||||
return UIAction(title: title, image: Assets.Images.nextUnread) { [weak self] action in
|
||||
return UIAction(title: title, image: Assets.Images.nextUnread) { [weak self] _ in
|
||||
self?.coordinator.selectNextUnread()
|
||||
}
|
||||
}
|
||||
@@ -795,14 +795,14 @@ private extension WebViewController {
|
||||
let extracted = articleExtractorButtonState == .on
|
||||
let title = extracted ? NSLocalizedString("Show Feed Article", comment: "Show Feed Article") : NSLocalizedString("Show Reader View", comment: "Show Reader View")
|
||||
let extractorImage = extracted ? Assets.Images.articleExtractorOffSF : Assets.Images.articleExtractorOnSF
|
||||
return UIAction(title: title, image: extractorImage) { [weak self] action in
|
||||
return UIAction(title: title, image: extractorImage) { [weak self] _ in
|
||||
self?.toggleArticleExtractor()
|
||||
}
|
||||
}
|
||||
|
||||
func shareAction() -> UIAction {
|
||||
let title = NSLocalizedString("Share", comment: "Share")
|
||||
return UIAction(title: title, image: Assets.Images.share) { [weak self] action in
|
||||
return UIAction(title: title, image: Assets.Images.share) { [weak self] _ in
|
||||
self?.showActivityDialog()
|
||||
}
|
||||
}
|
||||
@@ -862,8 +862,7 @@ extension WebViewController {
|
||||
}
|
||||
let encoded = json.base64EncodedString()
|
||||
|
||||
webView?.evaluateJavaScript("updateFind(\"\(encoded)\")") {
|
||||
(result, error) in
|
||||
webView?.evaluateJavaScript("updateFind(\"\(encoded)\")") { (result, error) in
|
||||
guard error == nil,
|
||||
let b64 = result as? String,
|
||||
let rawData = Data(base64Encoded: b64),
|
||||
|
||||
@@ -27,7 +27,7 @@ import WebKit
|
||||
operationQueue.add(WebViewProviderReplenishQueueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler))
|
||||
}
|
||||
|
||||
func dequeueWebView(completion: @escaping (PreloadedWebView) -> ()) {
|
||||
func dequeueWebView(completion: @escaping (PreloadedWebView) -> Void) {
|
||||
operationQueue.add(WebViewProviderDequeueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler, completion: completion))
|
||||
operationQueue.add(WebViewProviderReplenishQueueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler))
|
||||
}
|
||||
@@ -58,9 +58,9 @@ final class WebViewProviderReplenishQueueOperation: MainThreadOperation, @unchec
|
||||
final class WebViewProviderDequeueOperation: MainThreadOperation, @unchecked Sendable {
|
||||
private var queue: NSMutableArray
|
||||
private var articleIconSchemeHandler: ArticleIconSchemeHandler
|
||||
private var completion: (PreloadedWebView) -> ()
|
||||
private var completion: (PreloadedWebView) -> Void
|
||||
|
||||
init(queue: NSMutableArray, articleIconSchemeHandler: ArticleIconSchemeHandler, completion: @escaping (PreloadedWebView) -> ()) {
|
||||
init(queue: NSMutableArray, articleIconSchemeHandler: ArticleIconSchemeHandler, completion: @escaping (PreloadedWebView) -> Void) {
|
||||
self.queue = queue
|
||||
self.articleIconSchemeHandler = articleIconSchemeHandler
|
||||
self.completion = completion
|
||||
|
||||
@@ -28,7 +28,7 @@ import Account
|
||||
|
||||
func toggleHidingReadArticles(for sidebarItemID: SidebarItemIdentifier) {
|
||||
assert(canToggleHidingReadArticles(for: sidebarItemID))
|
||||
if (!canToggleHidingReadArticles(for: sidebarItemID)) {
|
||||
if !canToggleHidingReadArticles(for: sidebarItemID) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -74,9 +74,11 @@ private extension KeyboardManager {
|
||||
}
|
||||
|
||||
static func createKeyCommandInput(keyEntry: [String: Any]) -> String? {
|
||||
guard let key = keyEntry["key"] as? String else { return nil }
|
||||
guard let key = keyEntry["key"] as? String else {
|
||||
return nil
|
||||
}
|
||||
|
||||
switch(key) {
|
||||
switch key {
|
||||
case "[space]":
|
||||
return "\u{0020}"
|
||||
case "[uparrow]":
|
||||
|
||||
@@ -22,7 +22,6 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView {
|
||||
private var unreadLabelWidthConstraint: NSLayoutConstraint?
|
||||
|
||||
override var accessibilityLabel: String? {
|
||||
set {}
|
||||
get {
|
||||
if unreadCount > 0 {
|
||||
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
|
||||
@@ -31,16 +30,14 @@ final class MainFeedCollectionHeaderReusableView: UICollectionReusableView {
|
||||
return "\(headerTitle.text ?? "") \(expandedStateMessage) "
|
||||
}
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
private var expandedStateMessage: String {
|
||||
set {}
|
||||
get {
|
||||
if disclosureExpanded {
|
||||
return NSLocalizedString("Expanded", comment: "Disclosure button expanded state for accessibility")
|
||||
}
|
||||
return NSLocalizedString("Collapsed", comment: "Disclosure button collapsed state for accessibility")
|
||||
if disclosureExpanded {
|
||||
return NSLocalizedString("Expanded", comment: "Disclosure button expanded state for accessibility")
|
||||
}
|
||||
return NSLocalizedString("Collapsed", comment: "Disclosure button collapsed state for accessibility")
|
||||
}
|
||||
|
||||
private var _unreadCount: Int = 0
|
||||
|
||||
@@ -61,7 +61,6 @@ final class MainFeedCollectionViewCell: UICollectionViewCell {
|
||||
}
|
||||
|
||||
override var accessibilityLabel: String? {
|
||||
set {}
|
||||
get {
|
||||
if unreadCount > 0 {
|
||||
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
|
||||
@@ -70,6 +69,7 @@ final class MainFeedCollectionViewCell: UICollectionViewCell {
|
||||
return (String(describing: feedTitle.text))
|
||||
}
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
override func awakeFromNib() {
|
||||
|
||||
@@ -98,7 +98,6 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell {
|
||||
}
|
||||
|
||||
override var accessibilityLabel: String? {
|
||||
set {}
|
||||
get {
|
||||
if unreadCount > 0 {
|
||||
let unreadLabel = NSLocalizedString("unread", comment: "Unread label for accessibility")
|
||||
@@ -107,6 +106,7 @@ class MainFeedCollectionViewFolderCell: UICollectionViewCell {
|
||||
return (String(describing: folderTitle.text))
|
||||
}
|
||||
}
|
||||
set {}
|
||||
}
|
||||
|
||||
override func updateConfiguration(using state: UICellConfigurationState) {
|
||||
|
||||
@@ -71,7 +71,7 @@ extension MainFeedCollectionViewController: UICollectionViewDropDelegate {
|
||||
|
||||
func collectionView(_ collectionView: UICollectionView, dropSessionDidUpdate session: any UIDropSession, withDestinationIndexPath destinationIndexPath: IndexPath?) -> UICollectionViewDropProposal {
|
||||
|
||||
guard let destIndexPath = destinationIndexPath, destIndexPath.section > 0, collectionView.hasActiveDrag else {
|
||||
guard let destIndexPath = destinationIndexPath, destIndexPath.section > 0, collectionView.hasActiveDrag else {
|
||||
return UICollectionViewDropProposal(operation: .forbidden)
|
||||
}
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
///
|
||||
/// `shouldSelectItemAt()` will not allow selection when `isAnimating`
|
||||
/// is `true.`
|
||||
if let _ = collectionView.indexPathsForSelectedItems {
|
||||
if collectionView.indexPathsForSelectedItems != nil {
|
||||
isAnimating = true
|
||||
}
|
||||
}
|
||||
@@ -95,7 +95,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
/// On iPhone, once the deselection animation has completed, set `isAnimating`
|
||||
/// to false and this will allow selection.
|
||||
if traitCollection.userInterfaceIdiom == .phone {
|
||||
if let _ = collectionView.indexPathsForSelectedItems {
|
||||
if collectionView.indexPathsForSelectedItems != nil {
|
||||
coordinator.selectFeed(indexPath: nil, animations: [.select])
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
|
||||
self.isAnimating = false
|
||||
@@ -130,7 +130,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
|
||||
// Set up the delete action
|
||||
let deleteTitle = NSLocalizedString("Delete", comment: "Delete")
|
||||
let deleteAction = UIContextualAction(style: .destructive, title: nil) { [weak self] (action, view, completion) in
|
||||
let deleteAction = UIContextualAction(style: .destructive, title: nil) { [weak self] _, _, completion in
|
||||
self?.delete(indexPath: indexPath)
|
||||
completion(true)
|
||||
}
|
||||
@@ -141,7 +141,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
|
||||
// Set up the rename action
|
||||
let renameTitle = NSLocalizedString("Rename", comment: "Rename")
|
||||
let renameAction = UIContextualAction(style: .normal, title: nil) { [weak self] (action, view, completion) in
|
||||
let renameAction = UIContextualAction(style: .normal, title: nil) { [weak self] _, _, completion in
|
||||
self?.rename(indexPath: indexPath)
|
||||
completion(true)
|
||||
}
|
||||
@@ -233,7 +233,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
}
|
||||
|
||||
override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
|
||||
guard let node = coordinator.nodeFor(indexPath), let _ = node.representedObject as? Folder else {
|
||||
guard let node = coordinator.nodeFor(indexPath), node.representedObject is Folder else {
|
||||
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: reuseIdentifier, for: indexPath) as? MainFeedCollectionViewCell
|
||||
configure(cell!, indexPath: indexPath)
|
||||
return cell!
|
||||
@@ -324,7 +324,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
return makeFeedContextMenu(indexPath: indexPath, includeDeleteRename: true)
|
||||
} else if sidebarItem is Folder {
|
||||
return makeFolderContextMenu(indexPath: indexPath)
|
||||
} else if sidebarItem is PseudoFeed {
|
||||
} else if sidebarItem is PseudoFeed {
|
||||
return makePseudoFeedContextMenu(indexPath: indexPath)
|
||||
} else {
|
||||
return nil
|
||||
@@ -546,7 +546,7 @@ final class MainFeedCollectionViewController: UICollectionViewController, Undoab
|
||||
func configure(_ cell: MainFeedCollectionViewCell, indexPath: IndexPath) {
|
||||
guard let node = coordinator.nodeFor(indexPath) else { return }
|
||||
var indentationLevel = 0
|
||||
if let _ = node.parent?.representedObject as? Folder {
|
||||
if node.parent?.representedObject is Folder {
|
||||
indentationLevel = 1
|
||||
}
|
||||
|
||||
@@ -779,7 +779,7 @@ extension MainFeedCollectionViewController: UIContextMenuInteractionDelegate {
|
||||
return nil
|
||||
}
|
||||
|
||||
return UIContextMenuConfiguration(identifier: sectionIndex as NSCopying, previewProvider: nil) { suggestedActions in
|
||||
return UIContextMenuConfiguration(identifier: sectionIndex as NSCopying, previewProvider: nil) { _ in
|
||||
|
||||
var menuElements = [UIMenuElement]()
|
||||
menuElements.append(UIMenu(title: "", options: .displayInline, children: [self.getAccountInfoAction(account: account)]))
|
||||
@@ -806,7 +806,7 @@ extension MainFeedCollectionViewController: UIContextMenuInteractionDelegate {
|
||||
|
||||
extension MainFeedCollectionViewController {
|
||||
func makeFeedContextMenu(indexPath: IndexPath, includeDeleteRename: Bool) -> UIContextMenuConfiguration {
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [ weak self] suggestedActions in
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [ weak self] _ in
|
||||
|
||||
guard let self = self else { return nil }
|
||||
|
||||
@@ -849,7 +849,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
func makeFolderContextMenu(indexPath: IndexPath) -> UIContextMenuConfiguration {
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [weak self] suggestedActions in
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { [weak self] _ in
|
||||
|
||||
guard let self = self else { return nil }
|
||||
|
||||
@@ -876,7 +876,7 @@ extension MainFeedCollectionViewController {
|
||||
return nil
|
||||
}
|
||||
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { suggestedActions in
|
||||
return UIContextMenuConfiguration(identifier: MainFeedRowIdentifier(indexPath: indexPath), previewProvider: nil, actionProvider: { _ in
|
||||
return UIMenu(title: "", children: [markAllAction])
|
||||
})
|
||||
}
|
||||
@@ -887,7 +887,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Open Home Page", comment: "Open Home Page")
|
||||
let action = UIAction(title: title, image: Assets.Images.safari) { [weak self] action in
|
||||
let action = UIAction(title: title, image: Assets.Images.safari) { [weak self] _ in
|
||||
self?.coordinator.showBrowserForFeed(indexPath)
|
||||
}
|
||||
return action
|
||||
@@ -899,7 +899,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Open Home Page", comment: "Open Home Page")
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
|
||||
self?.coordinator.showBrowserForFeed(indexPath)
|
||||
completion(true)
|
||||
}
|
||||
@@ -913,7 +913,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Copy Feed URL", comment: "Copy Feed URL")
|
||||
let action = UIAction(title: title, image: Assets.Images.copy) { action in
|
||||
let action = UIAction(title: title, image: Assets.Images.copy) { _ in
|
||||
UIPasteboard.general.url = url
|
||||
}
|
||||
return action
|
||||
@@ -926,7 +926,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Copy Feed URL", comment: "Copy Feed URL")
|
||||
let action = UIAlertAction(title: title, style: .default) { action in
|
||||
let action = UIAlertAction(title: title, style: .default) { _ in
|
||||
UIPasteboard.general.url = url
|
||||
completion(true)
|
||||
}
|
||||
@@ -941,7 +941,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Copy Home Page URL", comment: "Copy Home Page URL")
|
||||
let action = UIAction(title: title, image: Assets.Images.copy) { action in
|
||||
let action = UIAction(title: title, image: Assets.Images.copy) { _ in
|
||||
UIPasteboard.general.url = url
|
||||
}
|
||||
return action
|
||||
@@ -955,7 +955,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Copy Home Page URL", comment: "Copy Home Page URL")
|
||||
let action = UIAlertAction(title: title, style: .default) { action in
|
||||
let action = UIAlertAction(title: title, style: .default) { _ in
|
||||
UIPasteboard.general.url = url
|
||||
completion(true)
|
||||
}
|
||||
@@ -975,7 +975,7 @@ extension MainFeedCollectionViewController {
|
||||
completion(true)
|
||||
}
|
||||
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView, cancelCompletion: cancel) { [weak self] in
|
||||
self?.coordinator.markAllAsRead(Array(articles))
|
||||
completion(true)
|
||||
@@ -987,7 +987,7 @@ extension MainFeedCollectionViewController {
|
||||
func deleteAction(indexPath: IndexPath) -> UIAction {
|
||||
let title = NSLocalizedString("Delete", comment: "Delete")
|
||||
|
||||
let action = UIAction(title: title, image: Assets.Images.trash, attributes: .destructive) { [weak self] action in
|
||||
let action = UIAction(title: title, image: Assets.Images.trash, attributes: .destructive) { [weak self] _ in
|
||||
self?.delete(indexPath: indexPath)
|
||||
}
|
||||
return action
|
||||
@@ -995,7 +995,7 @@ extension MainFeedCollectionViewController {
|
||||
|
||||
func renameAction(indexPath: IndexPath) -> UIAction {
|
||||
let title = NSLocalizedString("Rename", comment: "Rename")
|
||||
let action = UIAction(title: title, image: Assets.Images.edit) { [weak self] action in
|
||||
let action = UIAction(title: title, image: Assets.Images.edit) { [weak self] _ in
|
||||
self?.rename(indexPath: indexPath)
|
||||
}
|
||||
return action
|
||||
@@ -1007,7 +1007,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Get Info", comment: "Get Info")
|
||||
let action = UIAction(title: title, image: Assets.Images.info) { [weak self] action in
|
||||
let action = UIAction(title: title, image: Assets.Images.info) { [weak self] _ in
|
||||
self?.coordinator.showFeedInspector(for: feed)
|
||||
}
|
||||
return action
|
||||
@@ -1015,7 +1015,7 @@ extension MainFeedCollectionViewController {
|
||||
|
||||
func getAccountInfoAction(account: Account) -> UIAction {
|
||||
let title = NSLocalizedString("Get Info", comment: "Get Info")
|
||||
let action = UIAction(title: title, image: Assets.Images.info) { [weak self] action in
|
||||
let action = UIAction(title: title, image: Assets.Images.info) { [weak self] _ in
|
||||
self?.coordinator.showAccountInspector(for: account)
|
||||
}
|
||||
return action
|
||||
@@ -1023,7 +1023,7 @@ extension MainFeedCollectionViewController {
|
||||
|
||||
func deactivateAccountAction(account: Account) -> UIAction {
|
||||
let title = NSLocalizedString("Deactivate", comment: "Deactivate")
|
||||
let action = UIAction(title: title, image: Assets.Images.deactivate) { action in
|
||||
let action = UIAction(title: title, image: Assets.Images.deactivate) { _ in
|
||||
account.isActive = false
|
||||
}
|
||||
return action
|
||||
@@ -1035,7 +1035,7 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
let title = NSLocalizedString("Get Info", comment: "Get Info")
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] action in
|
||||
let action = UIAlertAction(title: title, style: .default) { [weak self] _ in
|
||||
self?.coordinator.showFeedInspector(for: feed)
|
||||
completion(true)
|
||||
}
|
||||
@@ -1051,7 +1051,7 @@ extension MainFeedCollectionViewController {
|
||||
|
||||
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
|
||||
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, sidebarItem.nameForDisplay) as String
|
||||
let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] action in
|
||||
let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
if let articles = try? sidebarItem.fetchUnreadArticles() {
|
||||
self?.coordinator.markAllAsRead(Array(articles))
|
||||
@@ -1063,13 +1063,13 @@ extension MainFeedCollectionViewController {
|
||||
}
|
||||
|
||||
func markAllAsReadAction(account: Account, contentView: UIView?) -> UIAction? {
|
||||
guard account.unreadCount > 0, let contentView = contentView else {
|
||||
guard account.unreadCount > 0, let contentView else {
|
||||
return nil
|
||||
}
|
||||
|
||||
let localizedMenuText = NSLocalizedString("Mark All as Read in “%@”", comment: "Command")
|
||||
let title = NSString.localizedStringWithFormat(localizedMenuText as NSString, account.nameForDisplay) as String
|
||||
let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] action in
|
||||
let action = UIAction(title: title, image: Assets.Images.markAllAsRead) { [weak self] _ in
|
||||
MarkAsReadAlertController.confirm(self, coordinator: self?.coordinator, confirmTitle: title, sourceType: contentView) { [weak self] in
|
||||
// If you don't have this delay the screen flashes when it executes this code
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
||||
@@ -1095,7 +1095,7 @@ extension MainFeedCollectionViewController {
|
||||
alertController.addAction(UIAlertAction(title: cancelTitle, style: .cancel))
|
||||
|
||||
let renameTitle = NSLocalizedString("Rename", comment: "Rename")
|
||||
let renameAction = UIAlertAction(title: renameTitle, style: .default) { [weak self] action in
|
||||
let renameAction = UIAlertAction(title: renameTitle, style: .default) { [weak self] _ in
|
||||
|
||||
guard let name = alertController.textFields?[0].text, !name.isEmpty else {
|
||||
return
|
||||
@@ -1126,7 +1126,7 @@ extension MainFeedCollectionViewController {
|
||||
alertController.addAction(renameAction)
|
||||
alertController.preferredAction = renameAction
|
||||
|
||||
alertController.addTextField() { textField in
|
||||
alertController.addTextField { textField in
|
||||
textField.text = sidebarItem.nameForDisplay
|
||||
textField.placeholder = NSLocalizedString("Name", comment: "Name")
|
||||
textField.clearButtonMode = .always
|
||||
@@ -1147,7 +1147,7 @@ extension MainFeedCollectionViewController {
|
||||
title = NSLocalizedString("Delete Folder", comment: "Delete folder")
|
||||
let localizedInformativeText = NSLocalizedString("Are you sure you want to delete the “%@” folder?", comment: "Folder delete text")
|
||||
message = NSString.localizedStringWithFormat(localizedInformativeText as NSString, sidebarItem.nameForDisplay) as String
|
||||
} else {
|
||||
} else {
|
||||
title = NSLocalizedString("Delete Feed", comment: "Delete feed")
|
||||
let localizedInformativeText = NSLocalizedString("Are you sure you want to delete the “%@” feed?", comment: "Feed delete text")
|
||||
message = NSString.localizedStringWithFormat(localizedInformativeText as NSString, sidebarItem.nameForDisplay) as String
|
||||
@@ -1159,7 +1159,7 @@ extension MainFeedCollectionViewController {
|
||||
alertController.addAction(UIAlertAction(title: cancelTitle, style: .cancel))
|
||||
|
||||
let deleteTitle = NSLocalizedString("Delete", comment: "Delete")
|
||||
let deleteAction = UIAlertAction(title: deleteTitle, style: .destructive) { [weak self] action in
|
||||
let deleteAction = UIAlertAction(title: deleteTitle, style: .destructive) { [weak self] _ in
|
||||
self?.performDelete(indexPath: indexPath)
|
||||
}
|
||||
alertController.addAction(deleteAction)
|
||||
|
||||
@@ -24,7 +24,7 @@ final class RefreshProgressView: UIView {
|
||||
accessibilityTraits = [.updatesFrequently, .notEnabled]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func update() {
|
||||
if !AccountManager.shared.combinedRefreshProgress.isComplete {
|
||||
progressChanged(animated: false)
|
||||
|
||||
@@ -66,10 +66,4 @@ struct ShadowTableChanges {
|
||||
var moves: Set<Move>?
|
||||
var rowChanges: [RowChanges]?
|
||||
|
||||
init(deletes: Set<Int>?, inserts: Set<Int>?, moves: Set<Move>?, rowChanges: [RowChanges]?) {
|
||||
self.deletes = deletes
|
||||
self.inserts = inserts
|
||||
self.moves = moves
|
||||
self.rowChanges = rowChanges
|
||||
}
|
||||
}
|
||||
Loaded 100 of 104 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user