mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-12-04 03:08:43 +00:00
Remove obsolete Mac state migration.
This commit is contained in:
1 parent
102ffbdc4b
commit
0df7ee6a73
6 files changed
-177
No files matched your search
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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..<readArticlesFilterStateKeys.count {
|
||||
if let sidebarItemID = SidebarItemIdentifier(userInfo: readArticlesFilterStateKeys[i]) {
|
||||
let hidesReadArticles = readArticlesFilterStateValues[i]
|
||||
if hidesReadArticles {
|
||||
noteSidebarItemHidesReadArticles(sidebarItemID)
|
||||
} else {
|
||||
noteSidebarItemShowsReadArticles(sidebarItemID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let articlePathUserInfo = state[UserInfoKey.articlePath] as? [AnyHashable: Any],
|
||||
let accountID = articlePathUserInfo[ArticlePathKey.accountID] as? String,
|
||||
let account = AccountManager.shared.existingAccount(accountID: accountID),
|
||||
let articleID = articlePathUserInfo[ArticlePathKey.articleID] as? String {
|
||||
|
||||
exceptionArticleFetcher = SingleArticleFetcher(account: account, articleID: articleID)
|
||||
fetchAndReplaceArticlesSync()
|
||||
|
||||
if let selectedIndex = articles.firstIndex(where: { $0.articleID == articleID }) {
|
||||
tableView.selectRow(selectedIndex)
|
||||
DispatchQueue.main.async {
|
||||
self.tableView.scrollTo(row: selectedIndex)
|
||||
}
|
||||
focus()
|
||||
}
|
||||
} else {
|
||||
fetchAndReplaceArticlesSync()
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Actions
|
||||
|
||||
@objc func openArticleInBrowser(_ sender: Any?) {
|
||||
|
||||
@@ -17,14 +17,4 @@ struct UserInfoKey {
|
||||
static let feedIdentifier = "feedIdentifier" // legacy
|
||||
|
||||
static let windowState = "windowState"
|
||||
static let windowFullScreenState = "windowFullScreenState"
|
||||
static let containerExpandedWindowState = "containerExpandedWindowState"
|
||||
static let readFeedsFilterState = "readFeedsFilterState"
|
||||
static let readArticlesFilterStateKeys = "readArticlesFilterStateKey"
|
||||
static let readArticlesFilterStateValues = "readArticlesFilterStateValue"
|
||||
static let selectedFeedsState = "selectedFeedsState"
|
||||
static let isShowingExtractedArticle = "isShowingExtractedArticle"
|
||||
|
||||
static let articleWindowScrollY = "articleWindowScrollY"
|
||||
static let isSidebarHidden = "isSidebarHidden"
|
||||
}
|
||||
Reference in new issue
Block a user