From 92d076ffb8c3d29f5c8d95ef784d12b22e16b379 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 20 Feb 2017 11:42:10 +0100 Subject: [PATCH] fix(ui/modules/Linphone/Chat/Chat): use `Connections` component --- .../ui/modules/Linphone/Chat/Chat.qml | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml b/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml index 8b9474728..dd8e2fa6b 100644 --- a/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml +++ b/linphone-desktop/ui/modules/Linphone/Chat/Chat.qml @@ -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. // -----------------------------------------------------------------------