Skip to content

Commit 3d02ebb

Browse files
committed
Revert "Revert to this commit to test PR #432"
This reverts commit 77dc999.
1 parent 77dc999 commit 3d02ebb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

WooCommerce/Classes/ViewRelated/Notifications/NotificationsViewController.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ class NotificationsViewController: UIViewController {
5353
///
5454
private let formatter = StringFormatter()
5555

56-
private var nextStatus = false
57-
5856
/// UI Active State
5957
///
6058
private var state: State = .results {
@@ -173,7 +171,11 @@ private extension NotificationsViewController {
173171
}
174172

175173
@IBAction func markAllAsRead() {
176-
let unread = resultsController.fetchedObjects
174+
let unread = resultsController.fetchedObjects.filter { $0.read == false }
175+
if unread.isEmpty {
176+
DDLogVerbose("# Every single notification is already marked as Read!")
177+
return
178+
}
177179

178180
markAsRead(notes: unread)
179181
hapticGenerator.notificationOccurred(.success)
@@ -189,14 +191,13 @@ private extension NotificationsViewController {
189191
///
190192
func markAsRead(notes: [Note]) {
191193
let identifiers = notes.map { $0.noteId }
192-
let action = NotificationAction.updateMultipleReadStatus(noteIds: identifiers, read: nextStatus) { error in
194+
let action = NotificationAction.updateMultipleReadStatus(noteIds: identifiers, read: true) { error in
193195
if let error = error {
194196
DDLogError("⛔️ Error marking notifications as read: \(error)")
195197
}
196198
}
197199

198200
StoresManager.shared.dispatch(action)
199-
nextStatus = !nextStatus
200201
}
201202

202203
/// Synchronizes the Notifications associated to the active WordPress.com account.

0 commit comments

Comments
 (0)