From 3acc1fb1eb3435265bb9bd60585c58f148b1ec02 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Sat, 5 Dec 2026 07:54:20 -0800 Subject: [PATCH] Add mark-read behavior enum and setting. --- Shared/AppDefaults.swift | 12 ++++++++++++ Shared/MarkReadBehavior.swift | 22 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Shared/MarkReadBehavior.swift diff --git a/Shared/AppDefaults.swift b/Shared/AppDefaults.swift index d4fb0e6b3..8b54e1c57 100644 --- a/Shared/AppDefaults.swift +++ b/Shared/AppDefaults.swift @@ -23,6 +23,7 @@ enum AppDefaults { static let currentThemeName = "currentThemeName" static let articleContentJavascriptEnabled = "articleContentJavascriptEnabled" static let unreadCountDisplay = "unreadCountDisplay" + static let markReadBehavior = "markReadBehavior" static let timelineThumbnailsDisplay = "timelineThumbnailsDisplay" static let timelineFeedIconsDisplay = "timelineFeedIconsDisplay" static let userInterfaceColorPalette = "userInterfaceColorPalette" @@ -47,6 +48,7 @@ enum AppDefaults { Key.timelineGroupByFeed: false, Key.currentThemeName: defaultThemeName, Key.articleContentJavascriptEnabled: true, + Key.markReadBehavior: MarkReadBehavior.selection.rawValue, Key.timelineThumbnailsDisplay: TimelineThumbnailsDisplay.none.rawValue, Key.timelineFeedIconsDisplay: TimelineFeedIconsDisplay.automatic.rawValue, Key.userInterfaceColorPalette: UserInterfaceColorPalette.automatic.rawValue, @@ -134,6 +136,16 @@ enum AppDefaults { } } + static var markReadBehavior: MarkReadBehavior { + get { + MarkReadBehavior(rawValue: UserDefaults.standard.integer(forKey: Key.markReadBehavior)) ?? .selection + } + set { + UserDefaults.standard.set(newValue.rawValue, forKey: Key.markReadBehavior) + NotificationCenter.default.post(name: .markReadBehaviorDidChange, object: nil) + } + } + static var timelineThumbnailsDisplay: TimelineThumbnailsDisplay { get { TimelineThumbnailsDisplay(rawValue: UserDefaults.standard.integer(forKey: Key.timelineThumbnailsDisplay)) ?? .none diff --git a/Shared/MarkReadBehavior.swift b/Shared/MarkReadBehavior.swift new file mode 100644 index 000000000..2ba635040 --- /dev/null +++ b/Shared/MarkReadBehavior.swift @@ -0,0 +1,22 @@ +// +// MarkReadBehavior.swift +// NetNewsWire +// +// Created by Brent Simmons on 12/5/26. +// + +import Foundation + +extension Notification.Name { + static let markReadBehaviorDidChange = Notification.Name("MarkReadBehaviorDidChangeNotification") +} + +/// When articles are marked read without the user marking them. +enum MarkReadBehavior: Int, CaseIterable, Codable { + /// Only when the user marks them read. + case manual = 0 + /// When selected. + case selection = 1 + /// When selected, and when scrolled off the top of the timeline. + case selectionAndScrolledPast = 2 +}