fix(ui/modules/Linphone/Chat/Chat): use Connections component

This commit is contained in:
Ronan Abhamon 2017-02-20 11:42:10 +01:00
parent 4a228d3109
commit 92d076ffb8

View file

@ -52,6 +52,13 @@ Rectangle {
}
}
function _initView () {
_tryToLoadMoreEntries = false
_bindToEnd = true
positionViewAtEnd()
}
// -----------------------------------------------------------------------
Layout.fillHeight: true
@ -77,28 +84,12 @@ Rectangle {
}
goToEnd()
var initView = function () {
_tryToLoadMoreEntries = false
_bindToEnd = true
positionViewAtEnd()
}
// Received only if more entries were loaded.
proxyModel.moreEntriesLoaded.connect(function (n) {
positionViewAtIndex(n - 1, ListView.Beginning)
_tryToLoadMoreEntries = false
})
// When the view is changed (for example `Calls` -> `Messages`),
// the position is set at end and it can be possible to load
// more entries.
proxyModel.entryTypeFilterChanged.connect(initView)
// First render.
initView()
_initView()
}
// -----------------------------------------------------------------------
onMovementStarted: _bindToEnd = false
onMovementEnded: {
if (atYEnd) {
@ -108,6 +99,22 @@ Rectangle {
onContentYChanged: _loadMoreEntries()
// -----------------------------------------------------------------------
Connections {
target: proxyModel
// When the view is changed (for example `Calls` -> `Messages`),
// the position is set at end and it can be possible to load
// more entries.
onEntryTypeFilterChanged: _initView()
onMoreEntriesLoaded: {
chat.positionViewAtIndex(n - 1, ListView.Beginning)
chat._tryToLoadMoreEntries = false
}
}
// -----------------------------------------------------------------------
// Heading.
// -----------------------------------------------------------------------