Commit 9d8b2632 authored by Ronan Abhamon's avatar Ronan Abhamon

fix(ui/modules/Linphone/Calls/Calls): handle calls correctly

parent 63e4132d
......@@ -97,39 +97,29 @@ function handleCallRunning (index, call) {
calls._selectedCall = call
}
function handleRowsAboutToBeRemoved (_, first, last) {
function handleCountChanged (count) {
if (count === 0) {
return 0
}
var index = calls.currentIndex
if (index !== -1) {
return
}
if (index >= first && index <= last) { // Remove current call.
var model = calls.model
var model = calls.model
index = count - 1
if (model.rowCount() - (last - first + 1) <= 0) {
calls._selectedCall = null
} else {
if (first === 0) {
calls._selectedCall = model.data(model.index(last + 1, 0))
} else {
calls._selectedCall = model.data(model.index(0, 0))
}
}
}
calls.currentIndex = index
calls._selectedCall = model.data(model.index(index, 0))
}
function handleRowsRemoved (_, first, last) {
function handleRowsAboutToBeRemoved (_, first, last) {
var index = calls.currentIndex
// The current call has been removed.
if (index >= first && index <= last) {
if (calls.model.rowCount() === 0) {
calls.currentIndex = -1 // No calls.
} else {
calls.currentIndex = 0 // The first call becomes the selected call.
}
}
// Update the current index of the selected call if it was after the removed calls.
else if (last < index) {
calls.currentIndex = index - (last - first + 1)
calls.currentIndex = -1
calls._selectedCall = null
}
}
......@@ -141,8 +131,10 @@ function handleRowsInserted (_, first, last) {
var call = model.data(model.index(index, 0))
if (call.isOutgoing) {
calls.currentIndex = first
calls._selectedCall = model.data(model.index(first, 0))
calls.currentIndex = -1
calls._selectedCall = null
return
}
}
}
......@@ -25,13 +25,14 @@ ListView {
// ---------------------------------------------------------------------------
onCountChanged: Logic.handleCountChanged(count)
Connections {
target: model
onCallRunning: Logic.handleCallRunning(index, call)
onRowsAboutToBeRemoved: Logic.handleRowsAboutToBeRemoved(parent, first, last)
onRowsInserted: Logic.handleRowsInserted(parent, first, last)
onRowsRemoved: Logic.handleRowsRemoved(parent, first, last)
}
// ---------------------------------------------------------------------------
......@@ -123,8 +124,10 @@ ListView {
width: parent.width
onClicked: {
_selectedCall = $call
calls.currentIndex = index
if ($call.status !== CallModel.CallStatusEnded) {
_selectedCall = $call
calls.currentIndex = index
}
}
// -------------------------------------------------------------------------
......
......@@ -43,7 +43,7 @@ function handleRowsAboutToBeRemoved (parent, first, last) {
}
}
function handleCountChanged () {
function handleCountChanged (_) {
var sipAddress = timeline._selectedSipAddress
if (sipAddress.length > 0) {
setSelectedEntry(sipAddress)
......
......@@ -139,6 +139,6 @@ ColumnLayout {
}
}
onCountChanged: Logic.handleCountChanged()
onCountChanged: Logic.handleCountChanged(count)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment