feat: Integrate notification management and preferences across platforms (#4819)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-03-16 20:17:34 -05:00 committed by GitHub
parent 0b2e89c46f
commit 8c964a15ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 1304 additions and 61 deletions

View file

@ -42,8 +42,8 @@ import org.meshtastic.core.model.Node
import org.meshtastic.core.model.service.ServiceAction
import org.meshtastic.core.repository.CustomEmojiPrefs
import org.meshtastic.core.repository.HomoglyphPrefs
import org.meshtastic.core.repository.MeshServiceNotifications
import org.meshtastic.core.repository.NodeRepository
import org.meshtastic.core.repository.NotificationManager
import org.meshtastic.core.repository.PacketRepository
import org.meshtastic.core.repository.RadioConfigRepository
import org.meshtastic.core.repository.ServiceRepository
@ -64,7 +64,7 @@ class MessageViewModel(
private val uiPrefs: UiPrefs,
private val customEmojiPrefs: CustomEmojiPrefs,
private val homoglyphEncodingPrefs: HomoglyphPrefs,
private val meshServiceNotifications: MeshServiceNotifications,
private val notificationManager: NotificationManager,
private val sendMessageUseCase: SendMessageUseCase,
) : ViewModel() {
private val _title = MutableStateFlow("")
@ -235,6 +235,6 @@ class MessageViewModel(
packetRepository.clearUnreadCount(contact, lastReadTimestamp)
packetRepository.updateLastReadMessage(contact, messageUuid, lastReadTimestamp)
val unreadCount = packetRepository.getUnreadCount(contact)
if (unreadCount == 0) meshServiceNotifications.cancelMessageNotification(contact)
if (unreadCount == 0) notificationManager.cancel(contact.hashCode())
}
}

View file

@ -26,7 +26,6 @@ import org.meshtastic.core.data.repository.QuickChatActionRepository
import org.meshtastic.core.model.service.ServiceAction
import org.meshtastic.core.repository.CustomEmojiPrefs
import org.meshtastic.core.repository.HomoglyphPrefs
import org.meshtastic.core.repository.MeshServiceNotifications
import org.meshtastic.core.repository.RadioConfigRepository
import org.meshtastic.core.repository.ServiceRepository
import org.meshtastic.core.repository.UiPrefs
@ -60,7 +59,6 @@ class MessageViewModelTest {
private lateinit var customEmojiPrefs: CustomEmojiPrefs
private lateinit var homoglyphPrefs: HomoglyphPrefs
private lateinit var uiPrefs: UiPrefs
private lateinit var meshServiceNotifications: MeshServiceNotifications
private fun setUp() {
// Create saved state with test contact ID
@ -86,7 +84,6 @@ class MessageViewModelTest {
homoglyphPrefs =
mockk(relaxed = true) { every { homoglyphEncodingEnabled } returns MutableStateFlow<Boolean>(false) }
uiPrefs = mockk(relaxed = true) { every { showQuickChat } returns MutableStateFlow<Boolean>(false) }
meshServiceNotifications = mockk(relaxed = true)
// Create ViewModel with mocked dependencies
viewModel =
@ -101,7 +98,7 @@ class MessageViewModelTest {
customEmojiPrefs = customEmojiPrefs,
homoglyphEncodingPrefs = homoglyphPrefs,
uiPrefs = uiPrefs,
meshServiceNotifications = meshServiceNotifications,
notificationManager = mockk(relaxed = true),
)
}