Skip to content

Commit

Permalink
fix: npe for last run time
Browse files Browse the repository at this point in the history
  • Loading branch information
aanorbel committed May 24, 2024
1 parent 977e027 commit 6f13727
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.view.View
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import org.openobservatory.engine.BaseNettest
import org.openobservatory.ooniprobe.R
import org.openobservatory.ooniprobe.activity.AbstractActivity
import org.openobservatory.ooniprobe.common.AbstractDescriptor
import org.openobservatory.ooniprobe.common.Application
Expand Down Expand Up @@ -124,9 +125,11 @@ class OverviewViewModel @Inject constructor(var application: Application, var pr

fun getLastTime(): String? {
return descriptor.value?.let {
DateUtils.getRelativeTimeSpanString(
Result.getLastResult(it.name).start_time.time
).toString()
Result.getLastResult(it.name)?.start_time?.time?.let { time ->
DateUtils.getRelativeTimeSpanString(
time
).toString()
}?: application.getString(R.string.Dashboard_Overview_LastRun_Never)
}
}

Expand Down

0 comments on commit 6f13727

Please sign in to comment.