diff --git a/Mac/AppDefaults+Mac.swift b/Mac/AppDefaults+Mac.swift index 2e245569d..37db25e4f 100644 --- a/Mac/AppDefaults+Mac.swift +++ b/Mac/AppDefaults+Mac.swift @@ -33,7 +33,6 @@ enum StatusBarCountMode: Int { } extension AppDefaults.Key { - static let legacyWindowState = "windowState" static let secureWindowState = "secureWindowState" static let useColumnLayout = "useColumnLayout" static let timelineShowSeparators = "timelineShowSeparators" @@ -60,18 +59,6 @@ extension AppDefaults.Key { extension AppDefaults { - /// 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. - static var legacyWindowState: [AnyHashable: Any]? { - UserDefaults.standard.object(forKey: Key.legacyWindowState) as? [AnyHashable: Any] - } - - static func deleteLegacyWindowState() { - UserDefaults.standard.removeObject(forKey: Key.legacyWindowState) - } - static var secureWindowState: Data? { get { UserDefaults.standard.object(forKey: Key.secureWindowState) as? Data diff --git a/Mac/MainWindow/MainWindowController.swift b/Mac/MainWindow/MainWindowController.swift index aa63ae522..655afdefa 100644 --- a/Mac/MainWindow/MainWindowController.swift +++ b/Mac/MainWindow/MainWindowController.swift @@ -27,7 +27,6 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations private var sharingServicePickerDelegate: SharingServicePickerDelegate? private let windowAutosaveName = NSWindow.FrameAutosaveName("MainWindow") - private static let mainWindowWidthsStateKey = "mainWindowWidthsStateKey" private var currentFeedOrFolder: AnyObject? { // Nil for none or multiple selection. @@ -181,11 +180,6 @@ final class MainWindowController: NSWindowController, NSUserInterfaceValidations Self.logger.debug("MainWindowController: restoring state from UserDefaults: \(state)") window?.setFrameUsingName(windowAutosaveName, force: true) restoreState(from: state) - } else if let state = AppDefaults.legacyWindowState { - // Migrate from previous window state data. Delete data when finished. - window?.setFrameUsingName(windowAutosaveName, force: true) - restoreLegacyState(from: state) - AppDefaults.deleteLegacyWindowState() } } @@ -1435,32 +1429,6 @@ private extension MainWindowController { } } - /// 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?.restoreLegacyState(from: state) - - let isShowingExtractedArticle = state[UserInfoKey.isShowingExtractedArticle] as? Bool ?? false - if isShowingExtractedArticle { - restoreArticleWindowScrollY = articleWindowScrollY - startArticleExtractorForCurrentLink() - } - } - // MARK: - Command Validation func canCopyArticleURL() -> Bool { @@ -1783,37 +1751,6 @@ private extension MainWindowController { sidebarSplitViewItem?.isCollapsed = state.isSidebarHidden } - /// 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 windowWidth = Int(floor(window.frame.width)) - let dividerThickness: Int = Int(splitView.dividerThickness) - let sidebarWidth: Int = widths[0] - let timelineWidth: Int = widths[1] - - // Make sure the detail view has its minimum thickness, at least. - if windowWidth < sidebarWidth + dividerThickness + timelineWidth + dividerThickness + Self.detailViewMinimumWidth { - return - } - - rememberedStandardLayoutWidths = widths - applyRememberedGeometry() - - let isSidebarHidden = state[UserInfoKey.isSidebarHidden] as? Bool ?? false - - if !(sidebarSplitViewItem?.isCollapsed ?? false) && isSidebarHidden { - sidebarSplitViewItem?.isCollapsed = true - } - } - func buildToolbarButton(_ itemIdentifier: NSToolbarItem.Identifier, _ title: String, _ image: NSImage, _ selector: String) -> NSToolbarItem { let toolbarItem = RSToolbarItem(itemIdentifier: itemIdentifier) toolbarItem.autovalidates = true diff --git a/Mac/MainWindow/Sidebar/SidebarViewController.swift b/Mac/MainWindow/Sidebar/SidebarViewController.swift index 2668d41cd..b01390cfa 100644 --- a/Mac/MainWindow/Sidebar/SidebarViewController.swift +++ b/Mac/MainWindow/Sidebar/SidebarViewController.swift @@ -172,49 +172,6 @@ extension Notification.Name { 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) - } - - guard let selectedFeedsState = state[UserInfoKey.selectedFeedsState] as? [[String: String]] else { - return - } - - let selectedFeedIdentifiers = Set(selectedFeedsState.compactMap( { SidebarItemIdentifier(userInfo: $0) })) - for identifier in selectedFeedIdentifiers { - treeControllerDelegate.addFilterException(identifier) - } - - rebuildTreeAndReloadDataIfNeeded() - - var selectIndexes = IndexSet() - - func selectFeedsVisitor(node: Node) { - if let sidebarItemID = (node.representedObject as? SidebarItemIdentifiable)?.sidebarItemID { - if selectedFeedIdentifiers.contains(sidebarItemID) { - let row = outlineView.row(forItem: node) - if row >= 0 { - selectIndexes.insert(row) - } - } - } - } - - 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/Timeline/TimelineContainerViewController.swift b/Mac/MainWindow/Timeline/TimelineContainerViewController.swift index 0fd082318..44de1b688 100644 --- a/Mac/MainWindow/Timeline/TimelineContainerViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineContainerViewController.swift @@ -188,14 +188,6 @@ final class TimelineContainerViewController: NSViewController { 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 ef5f714de..6571a144c 100644 --- a/Mac/MainWindow/Timeline/TimelineViewController.swift +++ b/Mac/MainWindow/Timeline/TimelineViewController.swift @@ -455,46 +455,6 @@ final class TimelineViewController: NSViewController, UndoableCommandRunner, Unr } } - /// Restore state using legacy state restoration data. - /// - /// TODO: Delete for NetNewsWire 7. - func restoreLegacyState(from state: [AnyHashable: Any]) { - guard let readArticlesFilterStateKeys = state[UserInfoKey.readArticlesFilterStateKeys] as? [[String: String]], - let readArticlesFilterStateValues = state[UserInfoKey.readArticlesFilterStateValues] as? [Bool] else { - return - } - - for i in 0..