mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
fix: ensure proper channel updates to ChannelSetRepository
This commit is contained in:
parent
a2388d1d12
commit
8151aceea4
5 changed files with 70 additions and 38 deletions
|
|
@ -35,6 +35,18 @@ class ChannelSetRepository @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
suspend fun clearSettings() {
|
||||
channelSetStore.updateData { preference ->
|
||||
preference.toBuilder().clearSettings().build()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun addAllSettings(settingsList: List<ChannelSettings>) {
|
||||
channelSetStore.updateData { preference ->
|
||||
preference.toBuilder().addAllSettings(settingsList).build()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the [ChannelSettings] list with the provided channel and returns the index of the
|
||||
* admin channel after the update (if not found, returns 0).
|
||||
|
|
@ -42,11 +54,7 @@ class ChannelSetRepository @Inject constructor(
|
|||
suspend fun updateChannelSettings(channel: Channel): Int {
|
||||
channelSetStore.updateData { preference ->
|
||||
if (preference.settingsCount > channel.index) {
|
||||
if (channel.role == Channel.Role.DISABLED) {
|
||||
preference.toBuilder().removeSettings(channel.index).build()
|
||||
} else {
|
||||
preference.toBuilder().setSettings(channel.index, channel.settings).build()
|
||||
}
|
||||
preference.toBuilder().setSettings(channel.index, channel.settings).build()
|
||||
} else {
|
||||
preference.toBuilder().addSettings(channel.settings).build()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,14 @@ class RadioConfigRepository @Inject constructor(
|
|||
channelSetRepository.clearChannelSet()
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the [ChannelSettings] list with a new [settingsList].
|
||||
*/
|
||||
suspend fun replaceAllSettings(settingsList: List<ChannelSettings>) {
|
||||
channelSetRepository.clearSettings()
|
||||
channelSetRepository.addAllSettings(settingsList)
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the [ChannelSettings] list with the provided channel and returns the index of the
|
||||
* admin channel after the update (if not found, returns 0).
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue