Skip to content

Commit 8316999

Browse files
danieltigsejorgeblacio
authored andcommitted
real fix in the push notifications (#542)
1 parent ae1a0bf commit 8316999

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ android {
4747
defaultConfig {
4848
minSdkVersion 21
4949
targetSdkVersion 28
50-
versionCode 84
51-
versionName "0.21.7"
50+
versionCode 85
51+
versionName "0.21.8"
5252
applicationId "com.criptext.mail"
5353
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
5454
multiDexEnabled true

src/main/kotlin/com/criptext/mail/push/data/PushAPIRequestHandler.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ class PushAPIRequestHandler(private val not: CriptextNotification,
204204
private fun handleNotificationCount(notificationId: Int, key: KeyValueStorage.StringKey, id: Int){
205205
val notCount = storage.getInt(key, 0)
206206
manager.cancel(notificationId)
207-
if((notCount - 1) == 0) {
207+
if((notCount - 1) <= 0) {
208208
manager.cancel(id)
209209
}
210-
storage.putInt(key, notCount - 1)
210+
storage.putInt(key, if(notCount <= 0) 0 else notCount - 1)
211211
}
212212

213213
private fun postNotification(cn: CriptextNotification,

src/main/kotlin/com/criptext/mail/push/services/NewMailActionService.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ class NewMailActionService : IntentService("New Mail Action Service") {
5050
}
5151
DELETE -> {
5252
val notCount = storage.getInt(KeyValueStorage.StringKey.NewMailNotificationCount, 0)
53-
if((notCount - 1) == 0) {
53+
if((notCount - 1) <= 0) {
5454
manager.cancel(CriptextNotification.INBOX_ID)
5555
}
56-
val newNotCount = if(notCount == 0) notCount else notCount - 1
57-
storage.putInt(KeyValueStorage.StringKey.NewMailNotificationCount, newNotCount)
56+
storage.putInt(KeyValueStorage.StringKey.NewMailNotificationCount,
57+
if(notCount <= 0) 0 else notCount - 1)
5858
}
5959
else -> throw IllegalArgumentException("Unsupported action: " + data.action)
6060
}

src/main/kotlin/com/criptext/mail/services/MessagingService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ class MessagingService : FirebaseMessagingService(){
5858
.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager
5959
val notCount = storage.getInt(key, 0)
6060
manager.cancel(notificationId)
61-
if((notCount - 1) == 0) {
61+
if((notCount - 1) <= 0) {
6262
manager.cancel(headerId)
6363
}
64-
storage.putInt(key, notCount - 1)
64+
storage.putInt(key, if(notCount <= 0) 0 else notCount - 1)
6565
}
6666

6767
companion object {

0 commit comments

Comments
 (0)