Skip to content

Commit 0e1ab37

Browse files
sowjanyakchAndyScherzinger
authored andcommitted
don't show zero emoji count
Signed-off-by: sowjanyakch <[email protected]>
1 parent 2fdc5aa commit 0e1ab37

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

app/src/main/java/com/nextcloud/talk/repositories/reactions/ReactionsRepositoryImpl.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,13 @@ class ReactionsRepositoryImpl @Inject constructor(private val ncApi: NcApi, priv
144144
message.reactionsSelf = ArrayList()
145145
}
146146

147-
var amount = message.reactions!![emoji]
148-
if (amount == null) {
149-
amount = 0
147+
val currentEmojiCount = message.reactions!![emoji] ?: 0
148+
val newEmojiCount = currentEmojiCount - 1
149+
if (newEmojiCount <= 0) {
150+
message.reactions!!.remove(emoji)
151+
} else {
152+
message.reactions!![emoji] = newEmojiCount
150153
}
151-
message.reactions!![emoji] = amount - 1
152154
message.reactionsSelf!!.remove(emoji)
153155

154156
// 3. Call DAO again, to update the singular ChatMessageEntity with params

0 commit comments

Comments
 (0)