handle notifications throttling on backlog finish event
This commit is contained in:
parent
501de4f997
commit
888ed9643f
|
@ -395,7 +395,23 @@ public class NotificationService {
|
||||||
count = getBacklogMessageCount(account);
|
count = getBacklogMessageCount(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateNotification(count > 0, conversations);
|
boolean shouldNotify = count > 0;
|
||||||
|
|
||||||
|
if (shouldNotify) {
|
||||||
|
boolean allConversationsShouldBeThrottled = true;
|
||||||
|
for (String c : conversations) {
|
||||||
|
if (!shouldNotificationSoundBeThrottled(c)) {
|
||||||
|
allConversationsShouldBeThrottled = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allConversationsShouldBeThrottled) {
|
||||||
|
shouldNotify = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
updateNotification(shouldNotify, conversations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
synchronized (mMissedCalls) {
|
synchronized (mMissedCalls) {
|
||||||
|
@ -733,7 +749,7 @@ public class NotificationService {
|
||||||
(!(this.mIsInForeground && this.mOpenConversation == null) || isScreenLocked)
|
(!(this.mIsInForeground && this.mOpenConversation == null) || isScreenLocked)
|
||||||
&& !account.inGracePeriod()
|
&& !account.inGracePeriod()
|
||||||
&& !this.inMiniGracePeriod(account) &&
|
&& !this.inMiniGracePeriod(account) &&
|
||||||
!shouldNotificationSoundBeThrottled(conversation);
|
!shouldNotificationSoundBeThrottled(conversation.getUuid());
|
||||||
|
|
||||||
updateNotification(doNotify, Collections.singletonList(conversation.getUuid()));
|
updateNotification(doNotify, Collections.singletonList(conversation.getUuid()));
|
||||||
|
|
||||||
|
@ -940,8 +956,8 @@ public class NotificationService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldNotificationSoundBeThrottled(@Nullable Conversational conversation) {
|
private boolean shouldNotificationSoundBeThrottled(@Nullable String conversationUuid) {
|
||||||
if (conversation == null) {
|
if (conversationUuid == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,7 +967,7 @@ public class NotificationService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastNotificationTimestamp = ensureLastNotificationTimeByConversation().getLong(conversation.getUuid(), -1L);
|
long lastNotificationTimestamp = ensureLastNotificationTimeByConversation().getLong(conversationUuid, -1L);
|
||||||
|
|
||||||
if (lastNotificationTimestamp <= 0L) {
|
if (lastNotificationTimestamp <= 0L) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue