Trying to prevent 'network not reachable' alert displayed when it shouldn't + added logs to help debug conferences list

This commit is contained in:
Sylvain Berfini 2024-07-01 11:05:52 +02:00
parent af3cab475b
commit 77e99fbfd3
3 changed files with 18 additions and 4 deletions

View file

@ -171,7 +171,7 @@ class MeetingsListAdapter :
private class MeetingDiffCallback : DiffUtil.ItemCallback<MeetingListItemModel>() {
override fun areItemsTheSame(oldItem: MeetingListItemModel, newItem: MeetingListItemModel): Boolean {
if (oldItem.model is MeetingModel && newItem.model is MeetingModel) {
return oldItem.model.id == newItem.model.id
return oldItem.model.id.isNotEmpty() && oldItem.model.id == newItem.model.id
}
return false
}
@ -181,7 +181,7 @@ class MeetingsListAdapter :
newItem: MeetingListItemModel
): Boolean {
if (oldItem.model is MeetingModel && newItem.model is MeetingModel) {
return oldItem.model.subject.value == newItem.model.subject.value && oldItem.model.time == newItem.model.time
return oldItem.model.subject.value.orEmpty().isNotEmpty() && oldItem.model.subject.value == newItem.model.subject.value && oldItem.model.time == newItem.model.time
}
return false
}

View file

@ -103,8 +103,15 @@ class MeetingsListViewModel @UiThread constructor() : AbstractMainViewModel() {
var previousModel: MeetingModel? = null
var previousModelWeekLabel = ""
var meetingForTodayFound = false
Log.d("$TAG There are [${source.size}] conference info in DB")
for (info: ConferenceInfo in source) {
if (info.duration == 0) continue // This isn't a scheduled conference, don't display it
if (info.duration == 0) {
Log.d(
"$TAG Skipping conference info [${info.subject}] with uri [${info.uri?.asStringUriOnly()}] because it has no duration"
)
continue
} // This isn't a scheduled conference, don't display it
val add = if (filter.isNotEmpty()) {
val organizerCheck = info.organizer?.asStringUriOnly()?.contains(
filter,
@ -123,7 +130,7 @@ class MeetingsListViewModel @UiThread constructor() : AbstractMainViewModel() {
if (add) {
val model = MeetingModel(info)
val firstMeetingOfTheWeek = previousModelWeekLabel != model.weekLabel
var firstMeetingOfTheWeek = previousModelWeekLabel != model.weekLabel
val firstMeetingOfTheDay = if (previousModel != null) {
previousModel.day != model.day || previousModel.dayNumber != model.dayNumber
@ -146,6 +153,7 @@ class MeetingsListViewModel @UiThread constructor() : AbstractMainViewModel() {
list.add(MeetingListItemModel(null, first))
meetingForTodayFound = true
previousModelWeekLabel = todayWeekLabel
firstMeetingOfTheWeek = false
} else {
previousModelWeekLabel = model.weekLabel
}
@ -165,6 +173,7 @@ class MeetingsListViewModel @UiThread constructor() : AbstractMainViewModel() {
list.add(MeetingListItemModel(null, firstMeetingOfTheWeek))
}
Log.d("$TAG We will display [${list.size}] conference info from the ones fetched from DB")
meetings.postValue(list)
}
}

View file

@ -175,6 +175,9 @@ class MainViewModel @UiThread constructor() : ViewModel() {
@WorkerThread
override fun onNetworkReachable(core: Core, reachable: Boolean) {
Log.i(
"$TAG According to SDK, network is ${if (reachable) "reachable" else "not reachable"}"
)
checkNetworkReachability()
}
@ -200,6 +203,8 @@ class MainViewModel @UiThread constructor() : ViewModel() {
}
}
RegistrationState.Ok -> {
removeAlert(NETWORK_NOT_REACHABLE) // Just in case
if (!firstAccountRegistered) {
triggerNativeAddressBookImport()
}