Trying to prevent crash in call history trying to get CallLog ID

This commit is contained in:
Sylvain Berfini 2023-03-20 09:49:17 +01:00
parent 09bde054d0
commit feec8b9758
5 changed files with 21 additions and 5 deletions

View file

@ -22,6 +22,15 @@ Group changes to describe their impact on the project, as follows:
- Replaced voice recordings file name by localized placeholder text, like for video conferences invitations
- Removed jetifier as it is not needed
## [5.0.8] - 2023-03-20
### Fixed
- Trying to prevent crash in call history
- Color icon in dark mode in chat for files & replies
### Changed
- Updated translations
## [5.0.7] - 2023-02-27
### Fixed

View file

@ -145,7 +145,7 @@ private class CallLogDiffCallback : DiffUtil.ItemCallback<GroupedCallLogData>()
oldItem: GroupedCallLogData,
newItem: GroupedCallLogData
): Boolean {
return oldItem.lastCallLog.callId == newItem.lastCallLog.callId
return oldItem.lastCallLogId == newItem.lastCallLogId
}
override fun areContentsTheSame(

View file

@ -23,8 +23,10 @@ import org.linphone.activities.main.history.viewmodels.CallLogViewModel
import org.linphone.core.CallLog
class GroupedCallLogData(callLog: CallLog) {
var lastCallLog: CallLog = callLog
val callLogs = arrayListOf(callLog)
var lastCallLog: CallLog = callLog
var lastCallLogId: String? = callLog.callId
val lastCallLogViewModel: CallLogViewModel
get() {
if (::_lastCallLogViewModel.isInitialized) {
@ -41,4 +43,9 @@ class GroupedCallLogData(callLog: CallLog) {
lastCallLogViewModel
}
}
fun updateLastCallLog(callLog: CallLog) {
lastCallLog = callLog
lastCallLogId = callLog.callId
}
}

View file

@ -160,7 +160,7 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
val deletedCallGroup = adapter.currentList[index]
listViewModel.deleteCallLogGroup(deletedCallGroup)
if (!binding.slidingPane.isSlideable &&
deletedCallGroup.lastCallLog.callId == sharedViewModel.selectedCallLogGroup.value?.lastCallLog?.callId
deletedCallGroup.lastCallLogId == sharedViewModel.selectedCallLogGroup.value?.lastCallLogId
) {
Log.i("[History] Currently displayed history has been deleted, removing detail fragment")
clearDisplayedCallHistory()
@ -282,7 +282,7 @@ class MasterCallLogsFragment : MasterFragment<HistoryMasterFragmentBinding, Call
val callLogGroup = adapter.currentList[index]
list.add(callLogGroup)
if (callLogGroup.lastCallLog.callId == sharedViewModel.selectedCallLogGroup.value?.lastCallLog?.callId) {
if (callLogGroup.lastCallLogId == sharedViewModel.selectedCallLogGroup.value?.lastCallLogId) {
closeSlidingPane = true
}
}

View file

@ -127,7 +127,7 @@ class CallLogsListViewModel : ViewModel() {
)
) {
previousCallLogGroup.callLogs.add(callLog)
previousCallLogGroup.lastCallLog = callLog
previousCallLogGroup.updateLastCallLog(callLog)
} else {
list.add(previousCallLogGroup)
previousCallLogGroup = GroupedCallLogData(callLog)