mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
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:
parent
e781d6774b
commit
f5b34d6408
4 changed files with 17 additions and 2 deletions
|
|
@ -23,6 +23,7 @@ import android.content.SharedPreferences
|
|||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import androidx.lifecycle.ProcessLifecycleOwner
|
||||
import com.geeksville.mesh.service.MeshServiceNotifications
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
|
|
@ -45,4 +46,9 @@ object ApplicationModule {
|
|||
fun provideProcessLifecycle(processLifecycleOwner: LifecycleOwner): Lifecycle {
|
||||
return processLifecycleOwner.lifecycle
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providesMeshServiceNotifications(application: Application): MeshServiceNotifications {
|
||||
return MeshServiceNotifications(application)
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -150,6 +150,9 @@ class MeshService : Service(), Logging {
|
|||
@Inject
|
||||
lateinit var mqttRepository: MQTTRepository
|
||||
|
||||
@Inject
|
||||
lateinit var serviceNotifications: MeshServiceNotifications
|
||||
|
||||
companion object : Logging {
|
||||
|
||||
// Intents broadcast by MeshService
|
||||
|
|
@ -212,7 +215,6 @@ class MeshService : Service(), Logging {
|
|||
|
||||
// A mapping of receiver class name to package name - used for explicit broadcasts
|
||||
private val clientPackages = mutableMapOf<String, String>()
|
||||
private val serviceNotifications = MeshServiceNotifications(this)
|
||||
private val serviceBroadcasts = MeshServiceBroadcasts(this, clientPackages) {
|
||||
connectionState.also { radioConfigRepository.setConnectionState(it) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,6 +35,9 @@ class ReplyReceiver : BroadcastReceiver() {
|
|||
@Inject
|
||||
lateinit var serviceRepository: ServiceRepository
|
||||
|
||||
@Inject
|
||||
lateinit var meshServiceNotifications: MeshServiceNotifications
|
||||
|
||||
companion object {
|
||||
const val REPLY_ACTION = "com.geeksville.mesh.REPLY_ACTION"
|
||||
const val CONTACT_KEY = "contactKey"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue