diff --git a/Appcasts/netnewswire-beta.xml b/Appcasts/netnewswire-beta.xml index 44d7cc899..b3e022216 100755 --- a/Appcasts/netnewswire-beta.xml +++ b/Appcasts/netnewswire-beta.xml @@ -7,146 +7,28 @@ en - NetNewsWire 6.1.10b2 + NetNewsWire 6.1.10b4 -
  • Fixed bug, introduced in previous test build, that prevented adding a Feedly account
  • +
  • Adopt secure state restoration; fix bug with state restoration not working in previous betas.
  • ]]>
    - Tue, 13 May 2025 09:00:00 -0700 - + Sat, 16 Aug 2025 10:10:00 -0700 + 13.0
    - NetNewsWire 6.1.10b1 - NetNewsWire 6.1.10b3 + -
  • Added caching to the downloader (the one that downloads feed icons, favicons, etc.) — make fewer network requests
  • -
  • Worked around The Verge’s bug with character encoding
  • -
  • Fixed bug where links in footnotes — in light mode, using the default theme — would be invisible
  • -
  • Fixed double-underlines on 404 Media links. (Fixed bug where using <u> tag inside an <a> would cause two underlines.)
  • -
  • Added &smallcircle; to the entities decoder
  • -
  • Synced the Mac default theme with the iOS version
  • +
  • Fixed bug, introduced in previous test build, that prevented choosing an OPML file to import
  • ]]>
    - Wed, 07 May 2025 22:00:00 -0700 - - 13.0 -
    - - - NetNewsWire 6.1b2 - Article themes. Several themes ship with the app, and you can create your own. You can change the theme in Preferences or by adding the theme switcher to the toolbar.

    -

    Copy URLs using repaired, rather than raw, feed links.

    -

    Restore article scroll position on relaunching app.

    -

    Added Copy Article URL and Copy External URL commands to the Edit menu.

    -

    Fixed a bug where using cmd-Q wouldn’t always quit the app as quickly as one might prefer.

    -

    Disallow creation of iCloud account in the app if iCloud and iCloud Drive aren’t both enabled.

    -

    Fixed bug showing quote tweets that only included an image.

    -

    Added a hidden pref to suppress downloading/syncing on start: `defaults write com.ranchero.NetNewsWire-Evergreen DevroeSuppressSyncOnLaunch -bool true`

    -

    Video autoplay is now disallowed.

    -

    Article view now supports RTL layout.

    - ]]>
    - Mon, 17 Jan 2022 17:45:00 -0800 - - 10.15.0 -
    - - - - NetNewsWire 6.0.3 - Same as 6.0.3b2 except for the version number.

    - ]]>
    - Sun, 05 Sep 2021 12:20:00 -0700 - - 10.15.0 -
    - - - - NetNewsWire 6.0.3b2 - Feedly: preserve custom feed names with Feedly when moving them between folders

    -

    Preferences: use full-width row style in accounts and extensions panes

    -

    Fixed a crashing bug triggered by running some UI code outside of main thread

    -

    Fixed a crashing bug that could happen when the app tries to find a feed for a website

    -

    Fixed a crashing bug that could happen when rendering tweets

    -

    Changed how images are placed in Twitter articles so that you can better see who Tweeted the image

    -

    Fixed bug where iCloud syncing could stop prematurely when the sync database has records not in the local database

    -

    Fixed bug where favicons wouldn’t be found when a home page URL has non-ASCII characters

    -

    Fixed bug where external URLs in Feedbin feeds might be lost

    -

    Fixed bug where words prepended with $ wouldn’t appear in Twitter feeds

    -

    Fixed bug where newlines would be just a space in Twitter feeds

    -

    Fixed bug where BazQux-synced feeds might stop updating

    - ]]>
    - Sun, 29 Aug 2021 15:25:00 -0700 - - 10.15.0 -
    - - - NetNewsWire 6.0.3b1 - Feedly: handle API change with deleting and don’t show a spurious error

    -

    NewsBlur: don’t fetch articles marked hidden by NewsBlur

    -

    FreshRSS: add API endpoint URL example in setup form

    -

    iCloud: fixed bug not retaining feeds in a folder where the folder hasn’t been synced yet

    -

    Feeds list: smart feeds remain visible despite Hide Read Feeds setting

    -

    Keyboard shortcuts: fixed regression where L key wouldn’t go to next unread when feed is all read

    -

    Twitter extension: fixed weird bug where an extra https:/ could appear in tweet text

    - ]]>
    - Thu, 20 May 2021 20:00:00 -0700 - - 10.15.0 -
    - - - NetNewsWire 6.0.2 - Same as 6.0.2b1 — no changes other than version

    - ]]>
    - Tue, 20 Apr 2021 17:40:00 -0700 - - 10.15.0 -
    - - - NetNewsWire 6.0.2b1 - Inoreader sync: fixed (hopefully) cause of rate limit errors — now doing background sync of statuses much less often - note that this fix needs to be rolled out across all NetNewsWire users in order for it to have full effect

    -

    Fixed regression with the L key — now works properly again

    - ]]>
    - Thu, 15 Apr 2021 19:15:00 -0700 - - 10.15.0 -
    - - - NetNewsWire 6.0.1 - Adjusted layout of the add account sheet so that it fits on smaller monitors

    -

    Sidebar: properly scale the smart feed icons when sidebar is set to large size in System Preferences

    - ]]>
    - Thu, 01 Apr 2021 20:22:00 -0700 - - 10.15.0 -
    - - - NetNewsWire 6.0.1b2 - Twitter: fixed a date parsing bug that could affect people in some locales, which would prevent Twitter feeds from working for them

    -

    Feeds list: fixed bug where newly added feed would be called Untitled past the time when the app actually knows its name

    -

    Fixed bug where next-unread command wouldn’t wrap around when you got to the bottom of the Feeds list

    - ]]>
    - Mon, 29 Mar 2021 20:55:00 -0700 - - 10.15.0 -
    - + Tue, 12 Aug 2025 10:10:00 -0700 + + 13.0 + diff --git a/Mac/AppDefaults.swift b/Mac/AppDefaults.swift index d4b2ee784..1084a2c6f 100644 --- a/Mac/AppDefaults.swift +++ b/Mac/AppDefaults.swift @@ -23,7 +23,8 @@ final class AppDefaults { struct Key { static let firstRunDate = "firstRunDate" - static let windowState = "windowState" + static let legacyWindowState = "windowState" + static let secureWindowState = "secureWindowState" static let lastImageCacheFlushDate = "lastImageCacheFlushDate" static let sidebarFontSize = "sidebarFontSize" static let timelineFontSize = "timelineFontSize" @@ -73,16 +74,28 @@ final class AppDefaults { firstRunDate = Date() return true }() - - var windowState: [AnyHashable : Any]? { + + /// Stores window state prior to switching to secure state restoration. + /// + /// This is referenced temporarily, only to be able to provide migration from legacy to secure window state. + /// TODO: delete for NetNewsWire 7. + var legacyWindowState: [AnyHashable: Any]? { + UserDefaults.standard.object(forKey: Key.legacyWindowState) as? [AnyHashable: Any] + } + + func deleteLegacyWindowState() { + UserDefaults.standard.removeObject(forKey: Key.legacyWindowState) + } + + var secureWindowState: Data? { get { - return UserDefaults.standard.object(forKey: Key.windowState) as? [AnyHashable : Any] + UserDefaults.standard.object(forKey: Key.secureWindowState) as? Data } set { - UserDefaults.standard.set(newValue, forKey: Key.windowState) + UserDefaults.standard.set(newValue, forKey: Key.secureWindowState) } } - + var lastImageCacheFlushDate: Date? { get { return AppDefaults.date(for: Key.lastImageCacheFlushDate) diff --git a/Mac/AppDelegate.swift b/Mac/AppDelegate.swift index e8f3dd76b..c9fa513c4 100644 --- a/Mac/AppDelegate.swift +++ b/Mac/AppDelegate.swift @@ -302,6 +302,10 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidations, return false } + func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } + func applicationDidBecomeActive(_ notification: Notification) { fireOldTimers() } diff --git a/Mac/MainWindow/Detail/DetailViewController.swift b/Mac/MainWindow/Detail/DetailViewController.swift index f096d0f5c..236047f03 100644 --- a/Mac/MainWindow/Detail/DetailViewController.swift +++ b/Mac/MainWindow/Detail/DetailViewController.swift @@ -28,6 +28,10 @@ final class DetailViewController: NSViewController, WKUIDelegate { private lazy var regularWebViewController = createWebViewController() private var searchWebViewController: DetailWebViewController? + var windowState: DetailWindowState { + currentWebViewController.windowState + } + private var currentWebViewController: DetailWebViewController! { didSet { let webview = currentWebViewController.view @@ -107,13 +111,6 @@ final class DetailViewController: NSViewController, WKUIDelegate { } window.makeFirstResponderUnlessDescendantIsFirstResponder(currentWebViewController.webView) } - - // MARK: State Restoration - - func saveState(to state: inout [AnyHashable : Any]) { - currentWebViewController.saveState(to: &state) - } - } // MARK: - DetailWebViewControllerDelegate diff --git a/Mac/MainWindow/Detail/DetailWebViewController.swift b/Mac/MainWindow/Detail/DetailWebViewController.swift index 2f82fed78..1655da8a3 100644 --- a/Mac/MainWindow/Detail/DetailWebViewController.swift +++ b/Mac/MainWindow/Detail/DetailWebViewController.swift @@ -35,6 +35,10 @@ final class DetailWebViewController: NSViewController { } } + var windowState: DetailWindowState { + DetailWindowState(isShowingExtractedArticle: isShowingExtractedArticle, windowScrollY: windowScrollY ?? 0) + } + var article: Article? { switch state { case .article(let article, _): @@ -204,14 +208,6 @@ final class DetailWebViewController: NSViewController { override func scrollPageUp(_ sender: Any?) { webView.scrollPageUp(sender) } - - // MARK: State Restoration - - func saveState(to state: inout [AnyHashable : Any]) { - state[UserInfoKey.isShowingExtractedArticle] = isShowingExtractedArticle - state[UserInfoKey.articleWindowScrollY] = windowScrollY - } - } // MARK: - WKScriptMessageHandler diff --git a/Mac/MainWindow/Detail/DetailWindowState.swift b/Mac/MainWindow/Detail/DetailWindowState.swift new file mode 100644 index 000000000..f277c2c33 --- /dev/null +++ b/Mac/MainWindow/Detail/DetailWindowState.swift @@ -0,0 +1,37 @@ +// +// DetailWindowState.swift +// NetNewsWire +// +// Created by Maurice Parker on 12/16/23. +// Copyright © 2023 Ranchero Software. All rights reserved. +// + +import Foundation + +final class DetailWindowState: NSObject, NSSecureCoding { + + static let supportsSecureCoding = true + + let isShowingExtractedArticle: Bool + let windowScrollY: CGFloat + + init(isShowingExtractedArticle: Bool, windowScrollY: CGFloat) { + self.isShowingExtractedArticle = isShowingExtractedArticle + self.windowScrollY = windowScrollY + } + + private struct Key { + static let isShowingExtractedArticle = "isShowingExtractedArticle" + static let windowScrollY = "windowScrollY" + } + + required init?(coder: NSCoder) { + isShowingExtractedArticle = coder.decodeBool(forKey: Key.isShowingExtractedArticle) + windowScrollY = CGFloat(coder.decodeDouble(forKey: Key.windowScrollY)) + } + + func encode(with coder: NSCoder) { + coder.encode(isShowingExtractedArticle, forKey: Key.isShowingExtractedArticle) + coder.encode(Double(windowScrollY), forKey: Key.windowScrollY) + } +} diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index a0b9932c5..f42b8a15e 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -130,17 +130,24 @@ class MainWindowController : NSWindowController, NSUserInterfaceValidations { } func saveStateToUserDefaults() { - AppDefaults.shared.windowState = savableState() + let data = try? NSKeyedArchiver.archivedData(withRootObject: savableState(), requiringSecureCoding: true) + AppDefaults.shared.secureWindowState = data window?.saveFrame(usingName: windowAutosaveName) } func restoreStateFromUserDefaults() { - if let state = AppDefaults.shared.windowState { + if let data = AppDefaults.shared.secureWindowState, + let state = try? NSKeyedUnarchiver.unarchivedObject(ofClass: MainWindowState.self, from: data) { restoreState(from: state) window?.setFrameUsingName(windowAutosaveName, force: true) + } else if let state = AppDefaults.shared.legacyWindowState { + // Migrate from previous window state data. Delete data when finished. + restoreLegacyState(from: state) + window?.setFrameUsingName(windowAutosaveName, force: true) + AppDefaults.shared.deleteLegacyWindowState() } } - + // MARK: - Notifications @objc func refreshProgressDidChange(_ note: Notification) { @@ -530,7 +537,7 @@ extension MainWindowController: NSWindowDelegate { } func window(_ window: NSWindow, didDecodeRestorableState coder: NSCoder) { - guard let state = try? coder.decodeTopLevelObject(forKey: UserInfoKey.windowState) as? [AnyHashable : Any] else { return } + guard let state = coder.decodeObject(of: MainWindowState.self, forKey: UserInfoKey.windowState) else { return } restoreState(from: state) } @@ -949,34 +956,67 @@ private extension MainWindowController { // MARK: - State Restoration - func savableState() -> [AnyHashable : Any] { - var state = [AnyHashable : Any]() - state[UserInfoKey.windowFullScreenState] = window?.styleMask.contains(.fullScreen) ?? false - saveSplitViewState(to: &state) - sidebarViewController?.saveState(to: &state) - timelineContainerViewController?.saveState(to: &state) - detailViewController?.saveState(to: &state) - return state + func savableState() -> MainWindowState { + let isFullScreen = window?.styleMask.contains(.fullScreen) ?? false + + let splitViewWidths: [Int] + if let splitView = splitViewController?.splitView { + splitViewWidths = splitView.arrangedSubviews.map{ Int(floor($0.frame.width)) } + } else { + splitViewWidths = [] + } + + let isSidebarHidden = sidebarSplitViewItem?.isCollapsed ?? false + + return MainWindowState(isFullScreen: isFullScreen, + splitViewWidths: splitViewWidths, + isSidebarHidden: isSidebarHidden, + sidebarWindowState: sidebarViewController?.windowState, + timelineWindowState: timelineContainerViewController?.windowState, + detailWindowState: detailViewController?.windowState) } - func restoreState(from state: [AnyHashable : Any]) { - if let fullScreen = state[UserInfoKey.windowFullScreenState] as? Bool, fullScreen { + func restoreState(from state: MainWindowState) { + if state.isFullScreen { window?.toggleFullScreen(self) } restoreSplitViewState(from: state) - sidebarViewController?.restoreState(from: state) + sidebarViewController?.restoreState(from: state.sidebarWindowState) + timelineContainerViewController?.restoreState(from: state.timelineWindowState) + restoreArticleWindowScrollY = state.detailWindowState?.windowScrollY + + let isShowingExtractedArticle = state.detailWindowState?.isShowingExtractedArticle ?? false + if isShowingExtractedArticle { + startArticleExtractorForCurrentLink() + } + } + + /// Restore state using pre-secure-state-restoration data. + /// + /// It’s up to the caller to call this only when: + /// 1. Legacy state exists, and + /// 2. Secure state data does not exist. + /// + /// TODO: delete this for NetNewsWire 7. + func restoreLegacyState(from state: [AnyHashable: Any]) { + if let fullScreen = state[UserInfoKey.windowFullScreenState] as? Bool, fullScreen { + window?.toggleFullScreen(self) + } + restoreLegacySplitViewState(from: state) + + sidebarViewController?.restoreLegacyState(from: state) + let articleWindowScrollY = state[UserInfoKey.articleWindowScrollY] as? CGFloat restoreArticleWindowScrollY = articleWindowScrollY - timelineContainerViewController?.restoreState(from: state) - + timelineContainerViewController?.restoreLegacyState(from: state) + let isShowingExtractedArticle = state[UserInfoKey.isShowingExtractedArticle] as? Bool ?? false if isShowingExtractedArticle { restoreArticleWindowScrollY = articleWindowScrollY startArticleExtractorForCurrentLink() } - } // MARK: - Command Validation @@ -1237,23 +1277,40 @@ private extension MainWindowController { } } - func saveSplitViewState(to state: inout [AnyHashable : Any]) { - guard let splitView = splitViewController?.splitView else { + func restoreSplitViewState(from state: MainWindowState) { + guard let splitView = splitViewController?.splitView, + state.splitViewWidths.count == 3, + let window = window else { return } - let widths = splitView.arrangedSubviews.map{ Int(floor($0.frame.width)) } - state[MainWindowController.mainWindowWidthsStateKey] = widths - - state[UserInfoKey.isSidebarHidden] = sidebarSplitViewItem?.isCollapsed + let windowWidth = Int(floor(window.frame.width)) + let dividerThickness: Int = Int(splitView.dividerThickness) + let sidebarWidth: Int = state.splitViewWidths[0] + let timelineWidth: Int = state.splitViewWidths[1] + + // Make sure the detail view has its minimum thickness, at least. + if windowWidth < sidebarWidth + dividerThickness + timelineWidth + dividerThickness + MainWindowController.detailViewMinimumThickness { + return + } + + splitView.setPosition(CGFloat(sidebarWidth), ofDividerAt: 0) + splitView.setPosition(CGFloat(sidebarWidth + dividerThickness + timelineWidth), ofDividerAt: 1) + + Task { @MainActor in + sidebarSplitViewItem?.isCollapsed = state.isSidebarHidden + } } - func restoreSplitViewState(from state: [AnyHashable : Any]) { + /// Restore main window split view using legacy state restoration data. + /// + /// TODO: Delete this for NetNewsWire 7. + func restoreLegacySplitViewState(from state: [AnyHashable: Any]) { guard let splitView = splitViewController?.splitView, - let widths = state[MainWindowController.mainWindowWidthsStateKey] as? [Int], - widths.count == 3, - let window = window else { - return + let widths = state[MainWindowController.mainWindowWidthsStateKey] as? [Int], + widths.count == 3, + let window = window else { + return } let windowWidth = Int(floor(window.frame.width)) @@ -1268,9 +1325,9 @@ private extension MainWindowController { splitView.setPosition(CGFloat(sidebarWidth), ofDividerAt: 0) splitView.setPosition(CGFloat(sidebarWidth + dividerThickness + timelineWidth), ofDividerAt: 1) - + let isSidebarHidden = state[UserInfoKey.isSidebarHidden] as? Bool ?? false - + if !(sidebarSplitViewItem?.isCollapsed ?? false) && isSidebarHidden { sidebarSplitViewItem?.isCollapsed = true } diff --git a/Mac/MainWindow/MainWindowState.swift b/Mac/MainWindow/MainWindowState.swift new file mode 100644 index 000000000..a92168938 --- /dev/null +++ b/Mac/MainWindow/MainWindowState.swift @@ -0,0 +1,57 @@ +// +// MainWindowState.swift +// NetNewsWire +// +// Created by Maurice Parker on 12/16/23. +// Copyright © 2023 Ranchero Software. All rights reserved. +// + +import Foundation + +final class MainWindowState: NSObject, NSSecureCoding { + + static let supportsSecureCoding = true + + let isFullScreen: Bool + let splitViewWidths: [Int] + let isSidebarHidden: Bool + let sidebarWindowState: SidebarWindowState? + let timelineWindowState: TimelineWindowState? + let detailWindowState: DetailWindowState? + + init(isFullScreen: Bool, splitViewWidths: [Int], isSidebarHidden: Bool, sidebarWindowState: SidebarWindowState? = nil, timelineWindowState: TimelineWindowState? = nil, detailWindowState: DetailWindowState? = nil) { + self.isFullScreen = isFullScreen + self.splitViewWidths = splitViewWidths + self.isSidebarHidden = isSidebarHidden + self.sidebarWindowState = sidebarWindowState + self.timelineWindowState = timelineWindowState + self.detailWindowState = detailWindowState + } + + private struct Key { + static let isFullScreen = "isFullScreen" + static let splitViewWidths = "splitViewWidths" + static let isSidebarHidden = "isSidebarHidden" + static let sidebarWindowState = "sidebarWindowState" + static let timelineWindowState = "timelineWindowState" + static let detailWindowState = "detailWindowState" + } + + required init?(coder: NSCoder) { + isFullScreen = coder.decodeBool(forKey: Key.isFullScreen) + splitViewWidths = coder.decodeObject(of: [NSArray.self, NSNumber.self], forKey: Key.splitViewWidths) as? [Int] ?? [] + isSidebarHidden = coder.decodeBool(forKey: Key.isSidebarHidden) + sidebarWindowState = coder.decodeObject(of: SidebarWindowState.self, forKey: Key.sidebarWindowState) + timelineWindowState = coder.decodeObject(of: TimelineWindowState.self, forKey: Key.timelineWindowState) + detailWindowState = coder.decodeObject(of: DetailWindowState.self, forKey: Key.detailWindowState) + } + + func encode(with coder: NSCoder) { + coder.encode(isFullScreen, forKey: Key.isFullScreen) + coder.encode(splitViewWidths, forKey: Key.splitViewWidths) + coder.encode(isSidebarHidden, forKey: Key.isSidebarHidden) + coder.encode(sidebarWindowState, forKey: Key.sidebarWindowState) + coder.encode(timelineWindowState, forKey: Key.timelineWindowState) + coder.encode(detailWindowState, forKey: Key.detailWindowState) + } +} diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index 43c625f10..2456878fa 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -30,6 +30,12 @@ protocol SidebarDelegate: AnyObject { weak var splitViewItem: NSSplitViewItem? + var windowState: SidebarWindowState { + let expandedContainers = expandedTable.compactMap { $0.userInfo as? [String: String] } + let selectedFeeds = selectedFeeds.compactMap { $0.feedID?.userInfo as? [String: String] } + return SidebarWindowState(isReadFiltered: isReadFiltered, expandedContainers: expandedContainers, selectedFeeds: selectedFeeds) + } + private let rebuildTreeAndRestoreSelectionQueue = CoalescingQueue(name: "Rebuild Tree Queue", interval: 1.0) let treeControllerDelegate = WebFeedTreeControllerDelegate() lazy var treeController: TreeController = { @@ -96,14 +102,39 @@ protocol SidebarDelegate: AnyObject { // MARK: State Restoration - func saveState(to state: inout [AnyHashable : Any]) { - state[UserInfoKey.readFeedsFilterState] = isReadFiltered - state[UserInfoKey.containerExpandedWindowState] = expandedTable.map { $0.userInfo } - state[UserInfoKey.selectedFeedsState] = selectedFeeds.compactMap { $0.feedID?.userInfo } - } - - func restoreState(from state: [AnyHashable : Any]) { + func restoreState(from state: SidebarWindowState?) { + guard let state else { return } + let containerIdentifers = state.expandedContainers.compactMap( { ContainerIdentifier(userInfo: $0) }) + expandedTable = Set(containerIdentifers) + + let selectedFeedIdentifers = Set(state.selectedFeeds.compactMap( { FeedIdentifier(userInfo: $0) })) + selectedFeedIdentifers.forEach { treeControllerDelegate.addFilterException($0) } + + rebuildTreeAndReloadDataIfNeeded() + + var selectIndexes = IndexSet() + + func selectFeedsVisitor(node: Node) { + if let feedID = (node.representedObject as? FeedIdentifiable)?.feedID { + if selectedFeedIdentifers.contains(feedID) { + selectIndexes.insert(outlineView.row(forItem: node) ) + } + } + } + + treeController.visitNodes(selectFeedsVisitor(node:)) + outlineView.selectRowIndexes(selectIndexes, byExtendingSelection: false) + focus() + + isReadFiltered = state.isReadFiltered + } + + /// Restore state using legacy state restoration data. + /// + /// TODO: Delete for NetNewsWire 7. + func restoreLegacyState(from state: [AnyHashable : Any]) { + if let containerExpandedWindowState = state[UserInfoKey.containerExpandedWindowState] as? [[AnyHashable: AnyHashable]] { let containerIdentifiers = containerExpandedWindowState.compactMap( { ContainerIdentifier(userInfo: $0) }) expandedTable = Set(containerIdentifiers) @@ -115,9 +146,9 @@ protocol SidebarDelegate: AnyObject { let selectedFeedIdentifiers = Set(selectedFeedsState.compactMap( { FeedIdentifier(userInfo: $0) })) selectedFeedIdentifiers.forEach { treeControllerDelegate.addFilterException($0) } - + rebuildTreeAndReloadDataIfNeeded() - + var selectIndexes = IndexSet() func selectFeedsVisitor(node: Node) { @@ -131,12 +162,12 @@ protocol SidebarDelegate: AnyObject { treeController.visitNodes(selectFeedsVisitor(node:)) outlineView.selectRowIndexes(selectIndexes, byExtendingSelection: false) focus() - + if let readFeedsFilterState = state[UserInfoKey.readFeedsFilterState] as? Bool { isReadFiltered = readFeedsFilterState } } - + // MARK: - Notifications @objc func unreadCountDidInitialize(_ notification: Notification) { diff --git a/Mac/MainWindow/Sidebar/SidebarWindowState.swift b/Mac/MainWindow/Sidebar/SidebarWindowState.swift new file mode 100644 index 000000000..1674a1437 --- /dev/null +++ b/Mac/MainWindow/Sidebar/SidebarWindowState.swift @@ -0,0 +1,42 @@ +// +// SidebarWindowState.swift +// NetNewsWire +// +// Created by Maurice Parker on 12/16/23. +// Copyright © 2023 Ranchero Software. All rights reserved. +// + +import Foundation + +final class SidebarWindowState: NSObject, NSSecureCoding { + + static let supportsSecureCoding = true + + let isReadFiltered: Bool + let expandedContainers: [[String: String]] + let selectedFeeds: [[String: String]] + + init(isReadFiltered: Bool, expandedContainers: [[String : String]], selectedFeeds: [[String : String]]) { + self.isReadFiltered = isReadFiltered + self.expandedContainers = expandedContainers + self.selectedFeeds = selectedFeeds + } + + private struct Key { + static let isReadFiltered = "isReadFiltered" + static let expandedContainers = "expandedContainers" + static let selectedFeeds = "selectedFeeds" + } + + required init?(coder: NSCoder) { + isReadFiltered = coder.decodeBool(forKey: Key.isReadFiltered) + expandedContainers = coder.decodeObject(of: [NSArray.self, NSDictionary.self, NSString.self], forKey: Key.expandedContainers) as? [[String: String]] ?? [] + selectedFeeds = coder.decodeObject(of: [NSArray.self, NSDictionary.self, NSString.self], forKey: Key.selectedFeeds) as? [[String: String]] ?? [] + } + + func encode(with coder: NSCoder) { + coder.encode(isReadFiltered, forKey: Key.isReadFiltered) + coder.encode(expandedContainers, forKey: Key.expandedContainers) + coder.encode(selectedFeeds, forKey: Key.selectedFeeds) + } +} diff --git a/Mac/MainWindow/Timeline/TimelineContainerViewController.swift b/Mac/MainWindow/Timeline/TimelineContainerViewController.swift index 5fdf0ab12..9a173b8a3 100644 --- a/Mac/MainWindow/Timeline/TimelineContainerViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineContainerViewController.swift @@ -37,6 +37,10 @@ final class TimelineContainerViewController: NSViewController { view?.window?.recalculateKeyViewLoop() } } + + var windowState: TimelineWindowState? { + return currentTimelineViewController?.windowState + } weak var delegate: TimelineContainerViewControllerDelegate? @@ -127,14 +131,20 @@ final class TimelineContainerViewController: NSViewController { // MARK: State Restoration - func saveState(to state: inout [AnyHashable : Any]) { - regularTimelineViewController.saveState(to: &state) - } - - func restoreState(from state: [AnyHashable : Any]) { + func restoreState(from state: TimelineWindowState?) { + guard let state else { return } + regularTimelineViewController.restoreState(from: state) updateReadFilterButton() } + + /// Restore state using legacy state restoration data. + /// + /// TODO: Delete for NetNewsWire 7. + func restoreLegacyState(from state: [AnyHashable: Any]) { + regularTimelineViewController.restoreLegacyState(from: state) + updateReadFilterButton() + } } extension TimelineContainerViewController: TimelineDelegate { diff --git a/Mac/MainWindow/Timeline/TimelineViewController.swift b/Mac/MainWindow/Timeline/TimelineViewController.swift index f19276b9f..21f9b5206 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -80,6 +80,24 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } } + var windowState: TimelineWindowState { + let readArticlesFilterStateKeys = readFilterEnabledTable.keys.compactMap { $0.userInfo as? [String: String] } + let readArticlesFilterStateValues = readFilterEnabledTable.values.compactMap( { $0 }) + + if selectedArticles.count == 1 { + let path = selectedArticles.first!.pathUserInfo + return TimelineWindowState(readArticlesFilterStateKeys: readArticlesFilterStateKeys, + readArticlesFilterStateValues: readArticlesFilterStateValues, + selectedAccountID: path[ArticlePathKey.accountID] as? String, + selectedArticleID: path[ArticlePathKey.articleID] as? String) + } else { + return TimelineWindowState(readArticlesFilterStateKeys: readArticlesFilterStateKeys, + readArticlesFilterStateValues: readArticlesFilterStateValues, + selectedAccountID: nil, + selectedArticleID: nil) + } + + } weak var delegate: TimelineDelegate? var sharingServiceDelegate: NSSharingServiceDelegate? @@ -271,16 +289,36 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr // MARK: State Restoration - func saveState(to state: inout [AnyHashable : Any]) { - state[UserInfoKey.readArticlesFilterStateKeys] = readFilterEnabledTable.keys.compactMap { $0.userInfo } - state[UserInfoKey.readArticlesFilterStateValues] = readFilterEnabledTable.values.compactMap( { $0 }) + func restoreState(from state: TimelineWindowState) { + for i in 0..` matches the literal `>` character. /// - `[\\s\\S]*?` /// - `[\\s\\S]` matches _any_ character, including new lines. - /// - `*` will match zero or more of the preceeding character, in this case _any_ + /// - `*` will match zero or more of the preceding character, in this case _any_ /// character. /// - `?` switches the matching mode to [lazy](https://javascript.info/regexp-greedy-and-lazy) /// so it will match as few as characters as possible before satisfying the rest of the pattern. diff --git a/Modules/RSCore/Tests/RSCoreTests/MainThreadOperationTests.swift b/Modules/RSCore/Tests/RSCoreTests/MainThreadOperationTests.swift index 1ab9eae94..976376201 100644 --- a/Modules/RSCore/Tests/RSCoreTests/MainThreadOperationTests.swift +++ b/Modules/RSCore/Tests/RSCoreTests/MainThreadOperationTests.swift @@ -240,7 +240,7 @@ class MainThreadOperationTests: XCTestCase { func run() { guard let block = didStartRunBlock else { - XCTFail("Unable to test cancelation of running operation.") + XCTFail("Unable to test cancellation of running operation.") return } block() diff --git a/Shared/UserInfoKey.swift b/Shared/UserInfoKey.swift index 07d850895..e9aaa21fc 100644 --- a/Shared/UserInfoKey.swift +++ b/Shared/UserInfoKey.swift @@ -24,7 +24,7 @@ struct UserInfoKey { static let readArticlesFilterStateValues = "readArticlesFilterStateValue" static let selectedFeedsState = "selectedFeedsState" static let isShowingExtractedArticle = "isShowingExtractedArticle" + static let articleWindowScrollY = "articleWindowScrollY" static let isSidebarHidden = "isSidebarHidden" - } diff --git a/Technotes/Bugs/MacStateRestoration.md b/Technotes/Bugs/MacStateRestoration.md deleted file mode 100644 index fd5c337ae..000000000 --- a/Technotes/Bugs/MacStateRestoration.md +++ /dev/null @@ -1,59 +0,0 @@ -# Mac State Restoration - -https://github.com/Ranchero-Software/NetNewsWire/issues/4589 - -https://github.com/Ranchero-Software/NetNewsWire/issues/4631 - -## State to restore - -Hide Read Articles -Hide Read Feeds -Windows positions, including split view positions - -## Warnings - - WARNING: Secure coding is automatically enabled for restorable state! However, not on all supported macOS versions of this application. Opt-in to secure coding explicitly by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState:. - -## How state restoration works according to Apple - -Info.plist: NSApplicationSupportsRestorableState - true - -NSUserInterfaceItemIdentification - -NSWindowRestoration Protocol -window.restorationClass = … - -encodeRestorableStateWithCoder: -restoreStateWithCoder: - -self.restorationIdentifier = "MainWindowController" - -AppDelegate — application:shouldRestoreApplicationState: and application:shouldSaveApplicationState: for complex cases - -Can be turned on and off via system pref - -## Tests - -Window 1 -Restore position — yes -Restore split view position — sometimes -Restore timeline position — no -Restore Hide Read Feeds — yes -Restore Hide Read Articles for inessential — yes - -Window 2 -Restore position -Restore split view position -Restore Hide Read Feeds -Restore Hide Read Articles for The Verge - -Restores second window but not first - -With state restoration enabled, all three windows appear, but with not everything restored - ---- - -Close windows tests - -1 window -detail scroll not restored diff --git a/Technotes/HowToDoMacSparkleRelease.markdown b/Technotes/HowToDoMacSparkleRelease.markdown new file mode 100644 index 000000000..32b325f25 --- /dev/null +++ b/Technotes/HowToDoMacSparkleRelease.markdown @@ -0,0 +1,57 @@ +# How To Do Mac Sparkle Release + +NetNewsWire_mac_target_common.xcconfig + update MARKETING_VERSION and CURRENT_PROJECT_VERSION + +ReleaseNotes-Mac.markdown +main branch +Write change notes in notes +Include branch and tag + +Run buildscripts/quiet_build_and_test.sh + +Make sure there are no outstanding changes + +Archive build +Developer ID distribution - notarize +Wait while processing + +Export +Smoke test + +On main: update Technotes/Status.md +commit + +Tag the app: +git tag mac-6.1.5b4 + +Push: +git push origin mac-6.1.5b4 + +Find tag in GitHub - https://github.com/Ranchero-Software/NetNewsWire/tags +Turn into release — NetNewsWire 6.1.5b4 for Mac +Add change notes +Zip app - NetNewsWire6.1.5b4.zip +Upload binary to release +Publish release +Copy file to releases archive — iCloud Drive/Archive/Releases/ + +Update Appcast on main branch + Add changes + Update title + Update pubDate + Update enclosure URL + Update version + Update file size - length + +Run xmllint on appcast + xmllint --noout netnewswire-beta.xml + +Upload appcast +Commit and push git change + +Test updating via appcast + +Optionally: +Announce on Slack +Announce on blog diff --git a/Technotes/HowToDoiOSAppStoreRelease.markdown b/Technotes/HowToDoiOSAppStoreRelease.markdown new file mode 100644 index 000000000..7134e6a2a --- /dev/null +++ b/Technotes/HowToDoiOSAppStoreRelease.markdown @@ -0,0 +1,20 @@ +# How To Do App Store Release + +Update release notes in ReleaseNotes-iOS.markdown on main to say that the TestFlight build has been submitted to App Store +Commit release notes + +Click + near iOS App +Type in new version name (example: 6.1.10) +Scroll halfway down to Build section, click + button, and choose the build (latest TestFlight build, presumably) +Fill in What’s New text +Click Save at top of screen +Click Add for Review next to Save + +On next screen, click Submit to App Review + +Once it appears on App Store… + +Optionally… +Announce on Slack +Announce on NetNewsWire blog +Announce on inessential diff --git a/Technotes/HowToDoiOSTestFlightRelease.markdown b/Technotes/HowToDoiOSTestFlightRelease.markdown new file mode 100644 index 000000000..e73d03c94 --- /dev/null +++ b/Technotes/HowToDoiOSTestFlightRelease.markdown @@ -0,0 +1,74 @@ +# How To Do iOS TestFlight Release + +Be sure to have updated code and be *on correct branch* + +## Edit Build Version + +NetNewsWire_ios_target_common.xcconfig + +Possibly bump MARKETING_VERSION +Increment CURRENT_PROJECT_VERSION by 1 (usually) + +Commit change. + +## Test + +Run buildscripts/quiet_build_and_test.sh to be sure all platforms build and tests pass. + +Build and run app on device + +Smoke test +If it fails, bail. +Check in and push changes. + +## Create Release Notes + +On main: + +ReleaseNotes-iOS.markdown + +Go to milestone and find closed bugs since last release notes +Add to iOS Release Notes note + +Write release notes + +Commit change. + +## Archive and Upload + +Archive +Distribute to TestFlight + +## Status + +Update NetNewsWire Status doc in Technotes +Commit + +## Tag + +On branch (or on main, if working on main): + +Use SemVer with tags +Tag the app: git tag iOS-6.1.5-6124 +Push: git push origin iOS-6.1.5-6124 + +## Release the app + +In AppStoreConnect add groups and release the app +Paste in the release notes +Announce in Slack +Optionally blog about it + +## GitHub release + +Make new release from tag + +https://github.com/Ranchero-Software/NetNewsWire/tags + +Example title: +NetNewsWire 6.1.6 (6140) for iOS - TestFlight + +## Notes + +Public TestFlight link: +https://testflight.apple.com/join/wpedPMRR diff --git a/Technotes/ReleaseNotes-Mac.markdown b/Technotes/ReleaseNotes-Mac.markdown index 2c34a2b17..1c86b395b 100644 --- a/Technotes/ReleaseNotes-Mac.markdown +++ b/Technotes/ReleaseNotes-Mac.markdown @@ -1,5 +1,13 @@ # Mac Release Notes +### 6.1.10b4 build 6139 16 Aug 2025 - branch main tag: mac-6.1.10b4 + +Adopt secure state restoration; fix bug with state restoration not working in previous betas. + +### 6.1.10b3 build 6138 11 Aug 2025 - branch main tag: mac-6.1.10b3 + +Fixed bug, introduced in previous test build, that prevented choosing an OPML file to import + ### 6.1.10b2 build 6137 13 May 2025 - branch main tag: mac-6.1.10b2 Fixed bug, introduced in previous test build, that prevented adding a Feedly account diff --git a/Technotes/ReleaseNotes-iOS.markdown b/Technotes/ReleaseNotes-iOS.markdown index 1b4864c21..4074d9b2f 100644 --- a/Technotes/ReleaseNotes-iOS.markdown +++ b/Technotes/ReleaseNotes-iOS.markdown @@ -1,6 +1,6 @@ # iOS Release Notes -### 6.1.10 TestFlight build 6198 11 Aug 2025 - branch: main tag iOS-6.1.10-6198 +### 6.1.10 TestFlight build 6198 11 Aug 2025 - branch: main tag iOS-6.1.10-6198 — submitted as App Store release build 18 Aug 2025 Replaced BBC in default feeds (for new users) because its feeds have gone wonky. Replaced with Scripting News. diff --git a/Technotes/Status.md b/Technotes/Status.md new file mode 100644 index 000000000..21a0c4458 --- /dev/null +++ b/Technotes/Status.md @@ -0,0 +1,22 @@ +# NetNewsWire Status + +Current milestone: NetNewsWire 6.1.10 + https://github.com/Ranchero-Software/NetNewsWire/milestone/60 + +Current bug: TBD + +Stuart working on Liquid Glass UI for NetNewsWire 7 + +## iOS + +iOS shipping: 6.1.9 (6197) + +TestFlight: 6.1.10 (6198) + https://github.com/Ranchero-Software/NetNewsWire/releases/tag/iOS-6.1.10-6198 + +## Mac + +Mac shipping: 6.1.9 + +Beta: 6.1.10b4 + https://github.com/Ranchero-Software/NetNewsWire/releases/tag/mac-6.1.10b4 diff --git a/xcconfig/common/NetNewsWire_mac_target_common.xcconfig b/xcconfig/common/NetNewsWire_mac_target_common.xcconfig index 541b6d663..5c232366d 100644 --- a/xcconfig/common/NetNewsWire_mac_target_common.xcconfig +++ b/xcconfig/common/NetNewsWire_mac_target_common.xcconfig @@ -1,6 +1,6 @@ // High Level Settings common to both the Mac application and any extensions we bundle with it -MARKETING_VERSION = 6.1.10b2 -CURRENT_PROJECT_VERSION = 6137 +MARKETING_VERSION = 6.1.10b4 +CURRENT_PROJECT_VERSION = 6139 ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon