fix: cancel new message notification when message is marked as read (#2057)

Co-authored-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
Łukasz Kosson 2025-06-09 19:45:20 +02:00 committed by GitHub
parent e781d6774b
commit f5b34d6408
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 2 deletions

View file

@ -61,6 +61,7 @@ import com.geeksville.mesh.repository.datastore.RadioConfigRepository
import com.geeksville.mesh.repository.location.LocationRepository
import com.geeksville.mesh.repository.radio.RadioInterfaceService
import com.geeksville.mesh.service.MeshService
import com.geeksville.mesh.service.MeshServiceNotifications
import com.geeksville.mesh.service.ServiceAction
import com.geeksville.mesh.ui.map.MAP_STYLE_ID
import com.geeksville.mesh.ui.node.components.NodeMenuAction
@ -190,7 +191,8 @@ class UIViewModel @Inject constructor(
private val quickChatActionRepository: QuickChatActionRepository,
private val locationRepository: LocationRepository,
firmwareReleaseRepository: FirmwareReleaseRepository,
private val preferences: SharedPreferences
private val preferences: SharedPreferences,
private val meshServiceNotifications: MeshServiceNotifications
) : ViewModel(), Logging {
private val _theme =
@ -573,6 +575,8 @@ class UIViewModel @Inject constructor(
fun clearUnreadCount(contact: String, timestamp: Long) = viewModelScope.launch(Dispatchers.IO) {
packetRepository.clearUnreadCount(contact, timestamp)
val unreadCount = packetRepository.getUnreadCount(contact)
if (unreadCount == 0) meshServiceNotifications.cancelMessageNotification(contact)
}
companion object {