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