Commit 1149e9ad authored by Ronan Abhamon's avatar Ronan Abhamon

fix(ui/modules/Linphone/Chat/Chat): block at each scroll

parent ceef883d
......@@ -25,7 +25,7 @@ void ChatModelFilter::setEntryTypeFilter (ChatModel::EntryType type) {
// ===================================================================
const unsigned int ChatProxyModel::ENTRIES_CHUNK_SIZE = 25;
const unsigned int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50;
ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
setSourceModel(&m_chat_model_filter);
......@@ -43,8 +43,10 @@ void ChatProxyModel::loadMoreEntries () {
invalidateFilter();
if (count < rowCount())
emit moreEntriesLoaded();
count = rowCount() - count;
if (count > 0)
emit moreEntriesLoaded(count);
}
}
......
......@@ -42,7 +42,7 @@ class ChatProxyModel : public QSortFilterProxyModel {
signals:
void sipAddressChanged (const QString &sipAddress);
void moreEntriesLoaded ();
void moreEntriesLoaded (int n);
void entryTypeFilterChanged (ChatModel::EntryType type);
public:
......
......@@ -15,10 +15,6 @@ ColumnLayout {
// Can be a model or a proxy chat model.
property alias proxyModel: chat.model
// Set the offset position to load more entries.
// Not a style property.
property int _loadMoreEntriesAtPosition: 25
// -----------------------------------------------------------------
spacing: 0
......@@ -28,12 +24,10 @@ ColumnLayout {
property bool _tryToLoadMoreEntries: true
function _loadMoreEntries (force) {
if ((
chat.visibleArea.yPosition * chat.height <= _loadMoreEntriesAtPosition &&
!_tryToLoadMoreEntries
) || force) {
function _loadMoreEntries () {
if (atYBeginning && !_tryToLoadMoreEntries) {
_tryToLoadMoreEntries = true
positionViewAtIndex(0, ListView.Beginning)
proxyModel.loadMoreEntries()
}
}
......@@ -189,16 +183,9 @@ ColumnLayout {
}
// Received only if more entries was loaded.
proxyModel.moreEntriesLoaded.connect(function () {
if (ScrollBar.vertical.pressed && atYBeginning) {
// Use a timeout to not increase call stack.
Utils.setTimeout(chat, 0, function () {
_loadMoreEntries(true)
positionViewAtIndex(1, ListView.Beginning)
})
} else {
_tryToLoadMoreEntries = false
}
proxyModel.moreEntriesLoaded.connect(function (n) {
positionViewAtIndex(n - 1, ListView.Beginning)
_tryToLoadMoreEntries = false
})
// When the view is changed (for example `Calls` -> `Messages`),
......
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