From fbc26945c212e58040e213d5ca23921fd7160dc2 Mon Sep 17 00:00:00 2001 From: Eric Andrews Date: Fri, 6 Oct 2023 20:39:37 -0400 Subject: [PATCH] Fixed inbox unread counter bug (#701) --- Mlem/Views/Tabs/Inbox/Inbox View Logic.swift | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Mlem/Views/Tabs/Inbox/Inbox View Logic.swift b/Mlem/Views/Tabs/Inbox/Inbox View Logic.swift index 841fbb95d..8b42af6c5 100644 --- a/Mlem/Views/Tabs/Inbox/Inbox View Logic.swift +++ b/Mlem/Views/Tabs/Inbox/Inbox View Logic.swift @@ -147,7 +147,16 @@ extension InboxView { // MARK: - Replies + /// Marks a comment reply as read or unread. Has no effect if the requested read status is already the current read status + /// - Parameters: + /// - commentReplyView: commentReplyView to mark + /// - read: true to mark as read, false to mark as unread func markCommentReplyRead(commentReplyView: APICommentReplyView, read: Bool) async { + // skip noop case + guard commentReplyView.commentReply.read != read else { + return + } + do { let response = try await commentRepository.markCommentReadStatus( id: commentReplyView.id, @@ -212,7 +221,16 @@ extension InboxView { // MARK: Mentions + /// Marks a person mention as read or unread. Has no effect if the requested read status is already the current read status + /// - Parameters: + /// - mention: mention to mark + /// - read: true to mark as read, false to mark as unread func markMentionRead(mention: APIPersonMentionView, read: Bool) async { + // skip noop case + guard mention.personMention.read != read else { + return + } + do { let updatedMention = try await apiClient.markPersonMentionAsRead( mentionId: mention.personMention.id,