feat: Refactor MeshService into smaller, single-responsibility components (#4108)

Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
James Rich 2026-01-02 11:13:38 -06:00 committed by GitHub
parent 0fa690eb61
commit b3ebe760dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
35 changed files with 3568 additions and 2816 deletions

View file

@ -57,8 +57,7 @@ constructor(
/** Replaces the [ChannelSettings] list with a new [settingsList]. */
suspend fun replaceAllSettings(settingsList: List<ChannelSettings>) {
channelSetDataSource.clearSettings()
channelSetDataSource.addAllSettings(settingsList)
channelSetDataSource.replaceAllSettings(settingsList)
}
/**

View file

@ -329,7 +329,7 @@ interface PacketDao {
val newIndex = if (oldPSK != null) pskToNewIndex[oldPSK] else null
if (oldPSK != null && newIndex != null && oldIndex != newIndex) {
// Rebuild contact_key with the new index, keeping the rest unchanged
val oldKeySuffix = packet.contact_key.drop(1) // removes only the channelIndex prefix
val oldKeySuffix = packet.contact_key.dropWhile { it.isDigit() }
val newContactKey = "$newIndex$oldKeySuffix"
update(packet.copy(contact_key = newContactKey, data = packet.data.copy(channel = newIndex)))
}

View file

@ -47,12 +47,11 @@ class ChannelSetDataSource @Inject constructor(private val channelSetStore: Data
channelSetStore.updateData { preference -> preference.toBuilder().clear().build() }
}
suspend fun clearSettings() {
channelSetStore.updateData { preference -> preference.toBuilder().clearSettings().build() }
}
suspend fun addAllSettings(settingsList: List<ChannelSettings>) {
channelSetStore.updateData { preference -> preference.toBuilder().addAllSettings(settingsList).build() }
/** Replaces all [ChannelSettings] in a single atomic operation. */
suspend fun replaceAllSettings(settingsList: List<ChannelSettings>) {
channelSetStore.updateData { preference ->
preference.toBuilder().clearSettings().addAllSettings(settingsList).build()
}
}
/** Updates the [ChannelSettings] list with the provided channel. */