Avoids double notifications.
This commit is contained in:
@@ -2306,6 +2306,10 @@ object LocalCache {
|
|||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun hasConsumed(notificationEvent: Event): Boolean {
|
||||||
|
return notes.containsKey(notificationEvent.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Stable
|
@Stable
|
||||||
|
|||||||
+4
-2
@@ -64,9 +64,9 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
|||||||
account: Account,
|
account: Account,
|
||||||
) {
|
) {
|
||||||
pushWrappedEvent.cachedGift(account.signer) { notificationEvent ->
|
pushWrappedEvent.cachedGift(account.signer) { notificationEvent ->
|
||||||
LocalCache.justConsume(notificationEvent, null)
|
if (!LocalCache.hasConsumed(notificationEvent) && LocalCache.justVerify(notificationEvent)) {
|
||||||
|
|
||||||
unwrapAndConsume(notificationEvent, account) { innerEvent ->
|
unwrapAndConsume(notificationEvent, account) { innerEvent ->
|
||||||
|
if (!LocalCache.hasConsumed(innerEvent)) {
|
||||||
if (innerEvent is PrivateDmEvent) {
|
if (innerEvent is PrivateDmEvent) {
|
||||||
notify(innerEvent, account)
|
notify(innerEvent, account)
|
||||||
} else if (innerEvent is LnZapEvent) {
|
} else if (innerEvent is LnZapEvent) {
|
||||||
@@ -77,6 +77,8 @@ class EventNotificationConsumer(private val applicationContext: Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun unwrapAndConsume(
|
private fun unwrapAndConsume(
|
||||||
event: Event,
|
event: Event,
|
||||||
|
|||||||
Reference in New Issue
Block a user