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