fix(auto): preserve raw channel index for shortcut/unread contactKey

Notifications and message routing key channel conversations by the raw
protocol channel index (e.g. "2^all"), but publishShortcuts and the
car screen were re-indexing after filtering out unnamed channels, so
named channels after a gap would never match their notification's
shortcutId/locusId and their unread badge would stay at zero.

Preserve the original index via mapIndexedNotNull { index to settings }.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
James Rich 2026-04-17 08:02:55 -05:00
parent 86bb9583b0
commit 36f770fd0b
3 changed files with 23 additions and 10 deletions

View file

@ -79,7 +79,9 @@ class ConversationShortcutManager(
val channelsFlow =
radioConfigRepository.channelSetFlow
.map { cs ->
cs.settings.filterIndexed { index, settings -> settings.name.isNotEmpty() || index == 0 }
cs.settings.mapIndexedNotNull { index, settings ->
if (index == 0 || settings.name.isNotEmpty()) index to settings else null
}
}
.distinctUntilChanged()
@ -94,11 +96,11 @@ class ConversationShortcutManager(
observeJob = null
}
private fun publishShortcuts(favorites: List<Node>, channels: List<ChannelSettings>) {
private fun publishShortcuts(favorites: List<Node>, channels: List<Pair<Int, ChannelSettings>>) {
val myNodeNum = nodeRepository.myNodeInfo.value?.myNodeNum
val shortcuts =
favorites.filter { it.num != myNodeNum }.map { buildFavoriteShortcut(it) } +
channels.mapIndexed { index, settings -> buildChannelShortcut(settings, index) }
channels.map { (index, settings) -> buildChannelShortcut(settings, index) }
try {
val limit = ShortcutManagerCompat.getMaxShortcutCountPerActivity(context)