Skip to content

Commit 05a2984

Browse files
committed
feat(settings): add "mark as read on open" setting for iOS and macOS
# Conflicts: # Mac/Base.lproj/Preferences.storyboard
1 parent 3792cd3 commit 05a2984

9 files changed

Lines changed: 113 additions & 7 deletions

File tree

Mac/AppDefaults.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ final class AppDefaults: Sendable {
4242
static let exportOPMLAccountID = "exportOPMLAccountID"
4343
static let defaultBrowserID = "defaultBrowserID"
4444
static let currentThemeName = "currentThemeName"
45+
static let markAsReadOnOpenEnabled = "markAsReadOnOpenEnabled"
4546
static let articleContentJavascriptEnabled = "articleContentJavascriptEnabled"
4647

4748
// Hidden prefs
@@ -307,6 +308,15 @@ final class AppDefaults: Sendable {
307308
}
308309
}
309310

311+
var isMarkAsReadOnOpenEnabled: Bool {
312+
get {
313+
UserDefaults.standard.bool(forKey: Key.markAsReadOnOpenEnabled)
314+
}
315+
set {
316+
UserDefaults.standard.set(newValue, forKey: Key.markAsReadOnOpenEnabled)
317+
}
318+
}
319+
310320
var isArticleContentJavascriptEnabled: Bool {
311321
get {
312322
UserDefaults.standard.bool(forKey: Key.articleContentJavascriptEnabled)
@@ -333,6 +343,7 @@ final class AppDefaults: Sendable {
333343
Key.refreshInterval: RefreshInterval.everyHour.rawValue,
334344
Key.showDebugMenu: showDebugMenu,
335345
Key.currentThemeName: Self.defaultThemeName,
346+
Key.markAsReadOnOpenEnabled: true,
336347
Key.articleContentJavascriptEnabled: true
337348
]
338349

Mac/Base.lproj/Preferences.storyboard

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</textFieldCell>
4747
</textField>
4848
<popUpButton horizontalHuggingPriority="249" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="Z6O-Zt-V1g">
49-
<rect key="frame" x="117" y="400" width="282" height="24"/>
49+
<rect key="frame" x="114" y="380" width="289" height="25"/>
5050
<popUpButtonCell key="cell" type="push" title="Medium" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="2" imageScaling="proportionallyDown" inset="2" selectedItem="jMV-2o-5Oh" id="6pw-Vq-tjM">
5151
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
5252
<font key="font" metaFont="message"/>
@@ -118,6 +118,26 @@
118118
<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
119119
</textFieldCell>
120120
</textField>
121+
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="FZh-t4-coy">
122+
<rect key="frame" x="117" y="328" width="283" height="16"/>
123+
<buttonCell key="cell" type="check" title="Mark as Read on Open" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="mF5-NC-6s2">
124+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
125+
<font key="font" metaFont="system"/>
126+
</buttonCell>
127+
<connections>
128+
<binding destination="mAF-gO-1PI" name="value" keyPath="values.markAsReadOnOpenEnabled" id="MarkAsRead-Binding">
129+
<dictionary key="options">
130+
<bool key="NSAllowsEditingMultipleValuesSelection" value="NO"/>
131+
<bool key="NSConditionallySetsEnabled" value="NO"/>
132+
<integer key="NSMultipleValuesPlaceholder" value="1"/>
133+
<integer key="NSNoSelectionPlaceholder" value="1"/>
134+
<integer key="NSNotApplicablePlaceholder" value="1"/>
135+
<integer key="NSNullPlaceholder" value="1"/>
136+
<bool key="NSRaisesForNotApplicableKeys" value="NO"/>
137+
</dictionary>
138+
</binding>
139+
</connections>
140+
</button>
121141
<button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="UI6-sq-M15">
122142
<rect key="frame" x="117" y="300" width="283" height="16"/>
123143
<buttonCell key="cell" type="check" title="Enable JavaScript" bezelStyle="regularSquare" imagePosition="left" state="on" inset="2" id="GUo-0M-xMc">
@@ -244,7 +264,7 @@
244264
</textFieldCell>
245265
</textField>
246266
<popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="SFF-mL-yc8">
247-
<rect key="frame" x="117" y="4" width="282" height="24"/>
267+
<rect key="frame" x="114" y="0.0" width="289" height="25"/>
248268
<popUpButtonCell key="cell" type="push" title="Every 30 minutes" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="3" imageScaling="proportionallyDown" inset="2" selectedItem="rZU-Tg-xwo" id="Jwn-HD-eP6">
249269
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
250270
<font key="font" metaFont="message"/>
@@ -282,6 +302,7 @@
282302
<constraints>
283303
<constraint firstItem="Ci4-fW-KjU" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="0Do-jh-Hqq"/>
284304
<constraint firstItem="92N-8I-bOs" firstAttribute="trailing" secondItem="S2Z-bG-jYk" secondAttribute="trailing" id="2ZD-KR-H5A"/>
305+
<constraint firstItem="FZh-t4-coy" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="43S-zb-paT"/>
285306
<constraint firstItem="S2Z-bG-jYk" firstAttribute="trailing" secondItem="pR2-Bf-7Fd" secondAttribute="trailing" id="4wu-2O-1fb"/>
286307
<constraint firstItem="Tdg-6Y-gvW" firstAttribute="top" secondItem="0W5-tO-S63" secondAttribute="bottom" constant="20" id="5a3-LF-TvY"/>
287308
<constraint firstItem="0W5-tO-S63" firstAttribute="top" secondItem="UI6-sq-M15" secondAttribute="bottom" constant="8" id="5mw-aE-uy4"/>
@@ -290,7 +311,7 @@
290311
<constraint firstItem="hQy-ng-ijd" firstAttribute="top" secondItem="Yrc-6Q-kx8" secondAttribute="bottom" constant="20" id="7iQ-QN-Ubh"/>
291312
<constraint firstItem="Yrc-6Q-kx8" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="AQY-vT-qR7"/>
292313
<constraint firstItem="yrg-M3-Dbz" firstAttribute="leading" secondItem="Ut3-yd-q6G" secondAttribute="leading" id="Bmt-Mn-CCl"/>
293-
<constraint firstItem="UI6-sq-M15" firstAttribute="top" secondItem="1w0-nA-DEO" secondAttribute="bottom" constant="12" id="DMk-OP-dpa"/>
314+
<constraint firstItem="FZh-t4-coy" firstAttribute="top" secondItem="1w0-nA-DEO" secondAttribute="bottom" constant="12" id="DMk-OP-dpa"/>
294315
<constraint firstItem="Ubm-Pk-l7x" firstAttribute="top" secondItem="Ci4-fW-KjU" secondAttribute="bottom" constant="12" id="E3r-xf-7aZ"/>
295316
<constraint firstAttribute="bottom" secondItem="SFF-mL-yc8" secondAttribute="bottom" constant="4" id="FAd-wh-IFu"/>
296317
<constraint firstItem="pR2-Bf-7Fd" firstAttribute="leading" secondItem="Ut3-yd-q6G" secondAttribute="leading" constant="8" id="G0C-1M-LW1"/>
@@ -300,7 +321,7 @@
300321
<constraint firstItem="ISO-Wu-R60" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="M2S-SQ-vXb"/>
301322
<constraint firstItem="ucw-vG-yLt" firstAttribute="trailing" secondItem="pR2-Bf-7Fd" secondAttribute="trailing" id="Nnp-Vh-NEA"/>
302323
<constraint firstItem="ISO-Wu-R60" firstAttribute="top" secondItem="Z6O-Zt-V1g" secondAttribute="bottom" constant="12" id="Obh-mq-3Tg"/>
303-
<constraint firstItem="92N-8I-bOs" firstAttribute="firstBaseline" secondItem="UI6-sq-M15" secondAttribute="firstBaseline" id="P1b-YG-fd6"/>
324+
<constraint firstItem="92N-8I-bOs" firstAttribute="firstBaseline" secondItem="FZh-t4-coy" secondAttribute="firstBaseline" id="P1b-YG-fd6"/>
304325
<constraint firstItem="Ubm-Pk-l7x" firstAttribute="leading" secondItem="Z6O-Zt-V1g" secondAttribute="leading" id="PXc-G4-8pH"/>
305326
<constraint firstItem="S2Z-bG-jYk" firstAttribute="firstBaseline" secondItem="ISO-Wu-R60" secondAttribute="firstBaseline" id="QBC-MT-MY5"/>
306327
<constraint firstAttribute="trailing" secondItem="Z6O-Zt-V1g" secondAttribute="trailing" constant="1" id="Qa5-bc-lvY"/>
@@ -313,6 +334,7 @@
313334
<constraint firstItem="ucw-vG-yLt" firstAttribute="firstBaseline" secondItem="SFF-mL-yc8" secondAttribute="firstBaseline" id="XHk-Fk-1pC"/>
314335
<constraint firstAttribute="trailing" secondItem="wtY-Zd-Ps9" secondAttribute="trailing" id="YAf-to-Ruz"/>
315336
<constraint firstItem="1w0-nA-DEO" firstAttribute="top" secondItem="ISO-Wu-R60" secondAttribute="bottom" constant="12" id="Yal-X7-BjE"/>
337+
<constraint firstItem="UI6-sq-M15" firstAttribute="top" secondItem="FZh-t4-coy" secondAttribute="bottom" constant="12" id="a9E-Wa-PdK"/>
316338
<constraint firstAttribute="trailing" secondItem="hQy-ng-ijd" secondAttribute="trailing" constant="1" id="aaL-6A-h6v"/>
317339
<constraint firstItem="92N-8I-bOs" firstAttribute="leading" secondItem="Ut3-yd-q6G" secondAttribute="leading" id="bfi-Tx-kxY"/>
318340
<constraint firstItem="S2Z-bG-jYk" firstAttribute="leading" secondItem="Ut3-yd-q6G" secondAttribute="leading" id="cAs-rZ-scx"/>
@@ -323,7 +345,8 @@
323345
<constraint firstAttribute="trailing" secondItem="Ci4-fW-KjU" secondAttribute="trailing" constant="1" id="h0b-Nh-tJJ"/>
324346
<constraint firstAttribute="trailing" secondItem="SFF-mL-yc8" secondAttribute="trailing" constant="1" id="hYk-Ff-wTy"/>
325347
<constraint firstItem="SFF-mL-yc8" firstAttribute="leading" secondItem="hQy-ng-ijd" secondAttribute="trailing" constant="-282" id="hhb-8Q-KWc"/>
326-
<constraint firstItem="0W5-tO-S63" firstAttribute="leading" secondItem="UI6-sq-M15" secondAttribute="leading" constant="22" id="jmc-lb-wp2"/>
348+
<constraint firstItem="0W5-tO-S63" firstAttribute="leading" secondItem="UI6-sq-M15" secondAttribute="leading" constant="20" id="jmc-lb-wp2"/>
349+
<constraint firstAttribute="trailing" secondItem="FZh-t4-coy" secondAttribute="trailing" id="kAo-hE-vfB"/>
327350
<constraint firstAttribute="trailing" secondItem="Yrc-6Q-kx8" secondAttribute="trailing" id="o3L-x4-mEr"/>
328351
<constraint firstItem="Wsb-Lr-8Q7" firstAttribute="trailing" secondItem="pR2-Bf-7Fd" secondAttribute="trailing" id="obL-84-81H"/>
329352
<constraint firstItem="Wsb-Lr-8Q7" firstAttribute="firstBaseline" secondItem="Ci4-fW-KjU" secondAttribute="firstBaseline" id="pCJ-eR-07V"/>

Mac/MainWindow/Timeline/TimelineViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ extension TimelineViewController: NSTableViewDelegate {
934934
return
935935
}
936936

937-
if selectedArticles.count == 1 {
937+
if selectedArticles.count == 1 && AppDefaults.shared.isMarkAsReadOnOpenEnabled {
938938
let article = selectedArticles.first!
939939
if !article.status.read {
940940
markArticles(Set([article]), statusKey: .read, flag: true)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
enum SecretKey {
2+
static var feedlyClientID: String { fatalError("update with live secret") }
3+
static var feedlyClientSecret: String { fatalError("update with live secret") }
4+
static var inoreaderAppID: String { fatalError("update with live secret") }
5+
static var inoreaderAppKey: String { fatalError("update with live secret") }
6+
}

Shared/SecretKey.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
enum SecretKey {
2+
static var mercuryClientID: String { fatalError("update with live secret") }
3+
static var mercuryClientSecret: String { fatalError("update with live secret") }
4+
}

iOS/AppDefaults.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ final class AppDefaults: Sendable {
5656
static let timelineSortDirection = "timelineSortDirection"
5757
static let articleFullscreenAvailable = "articleFullscreenAvailable"
5858
static let articleFullscreenEnabled = "articleFullscreenEnabled"
59+
static let markAsReadOnOpen = "markAsReadOnOpen"
5960
static let confirmMarkAllAsRead = "confirmMarkAllAsRead"
6061
static let lastRefresh = "lastRefresh"
6162
static let addFeedAccountID = "addFeedAccountID"
@@ -198,6 +199,15 @@ final class AppDefaults: Sendable {
198199
articleFullscreenAvailable && articleFullscreenEnabled
199200
}
200201

202+
var markAsReadOnOpen: Bool {
203+
get {
204+
return AppDefaults.bool(for: Key.markAsReadOnOpen)
205+
}
206+
set {
207+
AppDefaults.setBool(for: Key.markAsReadOnOpen, newValue)
208+
}
209+
}
210+
201211
var confirmMarkAllAsRead: Bool {
202212
get {
203213
return AppDefaults.bool(for: Key.confirmMarkAllAsRead)
@@ -382,6 +392,7 @@ final class AppDefaults: Sendable {
382392
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,
383393
Key.articleFullscreenAvailable: false,
384394
Key.articleFullscreenEnabled: false,
395+
Key.markAsReadOnOpen: true,
385396
Key.confirmMarkAllAsRead: true,
386397
Key.articleContentJavascriptEnabled: true,
387398
Key.currentThemeName: Self.defaultThemeName]

iOS/SceneCoordinator.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,9 @@ struct FeedNode: Hashable, Sendable {
985985
rootSplitViewController.show(.secondary)
986986

987987
// Mark article as read before navigating to it, so the read status does not flash unread/read on display
988-
markArticles(Set([article!]), statusKey: .read, flag: true)
988+
if AppDefaults.shared.markAsReadOnOpen {
989+
markArticles(Set([article!]), statusKey: .read, flag: true)
990+
}
989991

990992
mainTimelineViewController?.updateArticleSelection(animations: animations)
991993
articleViewController?.article = article

0 commit comments

Comments
 (0)