Skip to content

Commit

Permalink
chore: clear pending updates before fetching update
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed Jun 20, 2024
1 parent 4e631a1 commit f7cd7fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ private void onPeriodicWorkComplete(WorkInfo workInfo) {
}

public void fetchManualUpdate() {
updatesViewModel.clearDescriptors();
OneTimeWorkRequest manualWorkRequest = new OneTimeWorkRequest.Builder(ManualUpdateDescriptorsWorker.class)
.setConstraints(
new Constraints.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ import javax.inject.Singleton
@Singleton
class AvailableUpdatesViewModel @Inject() constructor(var gson: Gson) : ViewModel() {
var descriptors: MutableLiveData<List<ITestDescriptor>> = MutableLiveData()
var descriptorString: MutableLiveData<String> = MutableLiveData()

fun setDescriptorsWith(descriptorJson: String) {
descriptorString.value = descriptorJson
descriptors.value = gson.fromJson(descriptorJson, Array<ITestDescriptor>::class.java).toList()
}

fun getUpdatedDescriptor(runId: Long): String {
return gson.toJson(arrayOf(descriptors.value?.find { it.runId == runId }))
}

fun clearDescriptors() {
descriptors.value = emptyList()
}
}

0 comments on commit f7cd7fc

Please sign in to comment.