fix: Include deviceId when saving config after validation

The device ID was being fetched and saved to DataStore during BYOD
device validation, but it wasn't included in the TrmnlDeviceConfig
object when saving the full configuration. This caused the device ID
to be null in the loaded config, resulting in battery reporting being
skipped with 'device ID is null' warnings.

Now we retrieve the device ID from DataStore before saving the full
config and include it in the TrmnlDeviceConfig object for BYOD devices.
This commit is contained in:
Hossain Khan
2026-01-31 16:15:04 -05:00
parent 5be5695bc7
commit 8737038c16
@@ -552,6 +552,14 @@ class AppSettingsPresenter
TrmnlDeviceType.TRMNL -> false
}
// For BYOD devices, retrieve the device ID that was fetched during validation
val deviceId =
if (deviceType == TrmnlDeviceType.BYOD) {
deviceConfigStore.getDeviceId()
} else {
null
}
deviceConfigStore.saveDeviceConfig(
TrmnlDeviceConfig(
type = deviceType,
@@ -566,6 +574,8 @@ class AppSettingsPresenter
// We still persist the token here; any invalid or expired token will be
// detected and surfaced via downstream API error handling.
userApiToken = userApiToken.ifBlank { null },
// Include device ID for BYOD devices (fetched during validation)
deviceId = deviceId,
),
)
trmnlWorkScheduler.updateRefreshInterval(result.refreshRateSecs)