-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show number of unread messages in back-button (#2280) #2303
Conversation
The current implementation doesn't show the number in case the account is muted. This kind of feels like a bug? So I was thinking about adding this additional piece, which just gets all accounts' fresh messages. WDYT @r10s? diff --git a/deltachat-ios/Controller/ChatListViewController.swift b/deltachat-ios/Controller/ChatListViewController.swift
index 64eadc64..0bfa5b03 100644
--- a/deltachat-ios/Controller/ChatListViewController.swift
+++ b/deltachat-ios/Controller/ChatListViewController.swift
@@ -253,7 +253,7 @@ class ChatListViewController: UITableViewController {
}
private func updateNextScreensBackButton(accountId: Int? = nil, chatId: Int? = nil) {
- let numberOfUnreadMessages = DcAccounts.shared.getFreshMessageCount()
+ let numberOfUnreadMessages = DcAccounts.shared.getAllFreshMessages()
if isArchive {
navigationItem.backBarButtonItem = nil
diff --git a/deltachat-ios/DC/DcAccount.swift b/deltachat-ios/DC/DcAccount.swift
index ff1cbe9a..fca72f7f 100644
--- a/deltachat-ios/DC/DcAccount.swift
+++ b/deltachat-ios/DC/DcAccount.swift
@@ -129,6 +129,17 @@ public class DcAccounts {
return freshCount
}
+ public func getAllFreshMessages() -> Int {
+
+ let accountIDs = getAll()
+ let numberOfFreshMessages = accountIDs
+ .compactMap { get(id: $0) }
+ .compactMap { $0.getFreshMessages().count }
+ .reduce(0) { $0 + $1 }
+
+ return numberOfFreshMessages
+ }
+
@discardableResult
public func blockingCall(method: String, params: [AnyObject]) -> Data? {
if let paramsData = try? JSONSerialization.data(withJSONObject: params), |
2d012d6
to
ecc0adc
Compare
I think that would be expected. If you mute eg a group chat you don't want it still to show up in the back button because that would hide wether there is actual messages that you need to look at. |
ecc0adc
to
58e1ff0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i am using this PR since quite some time, and it is really great!
i am still a bit unsure about the displaying of "50 max" - discussed alternatives are
(1) using a normal number (this is what whatsapp is doing) or
(2) do not show a number at all but show a "unread dot" only if sth. new comes in or
(3) use a "real" badge (this is more effort, and we should really know that we want the badge to stay
however, let's stay with the current state, maybe it is just fine and good enough :)
wondering, btw about the reasoning of using updateNextScreensBackButton() to pass the event from ChatListViewController to ChatViewController. is that because of improved performance as when using an event in ChatViewController, one has to calculate things again?
Consider this WIP as there's still some flickering when receiving a message when on a chat. Something, something event-handling
Back-button wasn't updated when there were no more fresh messages
58e1ff0
to
573951b
Compare
Also: Fix build Xcode 18