added deviceUpdateGlobal field in HomeFragment

This commit is contained in:
chandrashekhar reddy
2024-03-05 14:45:47 +05:30
parent 1aaf2ba485
commit 1742363f1a

View File

@@ -1159,7 +1159,7 @@ class HomeFragment : Fragment() {
val deviceUpdateAvailableGlobal= deviceData.deviceUpdateAvailable
val updatePathGlobal= deviceData.updatePath
// if(deviceUpdateAvailableGlobal){
db.collection("devices").whereEqualTo("deviceId", deviceId).get().addOnSuccessListener { documentSnapshotNew ->
if (documentSnapshotNew.documents.isNotEmpty()) {
documentSnapshotNew.documents.forEach{
@@ -1183,14 +1183,24 @@ class HomeFragment : Fragment() {
Log.d("HomeFragmentUpdate","Device update not available")
}
}else{
if(!globalUpdateDone){
val update = db.collection("devices").document(it.id).update("globalUpdateDone",true)
update.addOnSuccessListener {
Log.d("HomeFragmentUpdate","Device global update done")
if(deviceUpdateAvailableGlobal) {
if (!globalUpdateDone) {
val update =
db.collection("devices").document(it.id)
.update("globalUpdateDone", true)
update.addOnSuccessListener {
Log.d(
"HomeFragmentUpdate",
"Device global update done"
)
initiateUpdate(updatePathGlobal)
}.addOnFailureListener{
Log.e("fetchDeviceUpdate", "update fail.")
initiateUpdate(updatePathGlobal)
}.addOnFailureListener {
Log.e(
"fetchDeviceUpdate",
"update fail."
)
}
}
}
}
@@ -1212,8 +1222,7 @@ class HomeFragment : Fragment() {
"fetchDeviceCredentials",
"deviceVersion: $deviceVersion, Password: $deviceUpdateAvailableGlobal, updatePath: $updatePathGlobal"
)
// } ?: Log.e("fetchDeviceUpdate", "Failed to parse device data.")
// ?: Log.e("fetchDeviceUpdate", "Failed to parse device data.")
} else {
Log.e("fetchDeviceUpdate", "Document does not exist.")
}