mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Merge pull request #1721 from deltachat/fix-notification-removal
do not use cached value to check for notifications
This commit is contained in:
@@ -139,18 +139,6 @@ public class ConversationListItem extends RelativeLayout
|
||||
int state = dcSummary.getState();
|
||||
int unreadCount = (state==DcMsg.DC_STATE_IN_FRESH || state==DcMsg.DC_STATE_IN_NOTICED)? thread.getUnreadCount() : 0;
|
||||
|
||||
// if the last message is not fresh or noticed, we assume, there are no unread things
|
||||
// and also remove notifications for the chat.
|
||||
// this might be improved at some point in core, https://github.com/deltachat/deltachat-core-rust/issues/1974
|
||||
// and the following call to removeNotifications() can go to DC_EVENT_MSGS_NOTICED handler.
|
||||
// however, for now it is not that bad
|
||||
// and ensures, things answered on device-A are no longer notified on device-B.
|
||||
if (unreadCount==0) {
|
||||
Util.runOnAnyBackgroundThread(() -> {
|
||||
dcContext.notificationCenter.removeNotifications((int) chatId);
|
||||
});
|
||||
}
|
||||
|
||||
if (highlightSubstring != null) {
|
||||
this.fromView.setText(getHighlightedSpan(locale, recipient.getName(), highlightSubstring));
|
||||
} else {
|
||||
|
||||
@@ -452,6 +452,13 @@ public class ApplicationDcContext extends DcContext {
|
||||
}
|
||||
break;
|
||||
|
||||
case DC_EVENT_MSGS_NOTICED:
|
||||
notificationCenter.removeNotifications(event.getData1Int());
|
||||
if (eventCenter != null) {
|
||||
eventCenter.sendToObservers(event);
|
||||
}
|
||||
break;
|
||||
|
||||
default: {
|
||||
if (eventCenter != null) {
|
||||
eventCenter.sendToObservers(event);
|
||||
|
||||
@@ -504,12 +504,12 @@ public class NotificationCenter {
|
||||
public void removeNotifications(int chatId) {
|
||||
boolean removeSummary;
|
||||
synchronized (inboxes) {
|
||||
if (inboxes.remove(chatId) == null) {
|
||||
return; // speed up things when there is nothing to remove
|
||||
}
|
||||
inboxes.remove(chatId);
|
||||
removeSummary = inboxes.isEmpty();
|
||||
}
|
||||
|
||||
// cancel notification independently of inboxes array,
|
||||
// due to restarts, the app may have notification even when inboxes is empty.
|
||||
try {
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
|
||||
notificationManager.cancel(ID_MSG_OFFSET + chatId);
|
||||
|
||||
Reference in New Issue
Block a user