mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-05-12 08:42:01 -04:00
fix(auto): only include unread messages in conversation notif
The MIN_CONTEXT_MESSAGES fallback (pull 3 most recent history messages when unread < 3) was injecting already-read historical messages into the MessagingStyle. On Android Auto, Gearhead reads every message in the style aloud and shows them stacked on the HUN, so old context was announced alongside the new one. Just show the unread messages (up to MAX_HISTORY_MESSAGES). If nothing is unread, don't post at all — we only call this from paths that already check for fresh inbound content. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -119,7 +119,6 @@ class MeshServiceNotificationsImpl(
|
||||
const val MAX_BATTERY_LEVEL = 100
|
||||
private val NOTIFICATION_LIGHT_COLOR = Color.BLUE
|
||||
private const val MAX_HISTORY_MESSAGES = 10
|
||||
private const val MIN_CONTEXT_MESSAGES = 3
|
||||
private const val SNIPPET_LENGTH = 30
|
||||
private const val GROUP_KEY_MESSAGES = "com.geeksville.mesh.GROUP_MESSAGES"
|
||||
private const val SUMMARY_ID = 1
|
||||
@@ -426,14 +425,8 @@ class MeshServiceNotificationsImpl(
|
||||
.first()
|
||||
|
||||
val unread = history.filter { !it.read }
|
||||
val displayHistory =
|
||||
if (unread.size < MIN_CONTEXT_MESSAGES) {
|
||||
history.take(MIN_CONTEXT_MESSAGES).reversed()
|
||||
} else {
|
||||
unread.take(MAX_HISTORY_MESSAGES).reversed()
|
||||
}
|
||||
|
||||
if (displayHistory.isEmpty()) return
|
||||
if (unread.isEmpty()) return
|
||||
val displayHistory = unread.take(MAX_HISTORY_MESSAGES).reversed()
|
||||
|
||||
val notification =
|
||||
createConversationNotification(
|
||||
|
||||
Reference in New Issue
Block a user