Fix loading events when scrolling or opening a room for the first time
Fix #362
(cherry picked from commit bae7813f68)
This commit is contained in:
@@ -232,20 +232,17 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
model: !isLoaded ? undefined : sortedMessageEventModel
|
model: !isLoaded ? undefined : sortedMessageEventModel
|
||||||
|
|
||||||
onContentYChanged: fetchMoreContent()
|
|
||||||
|
|
||||||
function fetchMoreContent() {
|
|
||||||
if(!noNeedMoreContent && contentY - 5000 < originY) {
|
|
||||||
currentRoom.getPreviousContent(20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageEventModel {
|
MessageEventModel {
|
||||||
id: messageEventModel
|
id: messageEventModel
|
||||||
|
|
||||||
room: currentRoom
|
room: currentRoom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HACK: The view should do this automatically but doesn't.
|
||||||
|
onAtYBeginningChanged: if (atYBeginning && messageEventModel.canFetchMore(messageEventModel.index(0, 0))) {
|
||||||
|
messageEventModel.fetchMore(messageEventModel.index(0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
QQC2.Popup {
|
QQC2.Popup {
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
@@ -596,7 +593,11 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
DelegateChoice {
|
DelegateChoice {
|
||||||
roleValue: "other"
|
roleValue: "other"
|
||||||
delegate: Item {}
|
delegate: Rectangle {
|
||||||
|
height: 10
|
||||||
|
width: ListView.view.width
|
||||||
|
color: "red"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -646,10 +647,10 @@ Kirigami.ScrollablePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
updateReadMarker()
|
|
||||||
if (currentRoom) {
|
if (currentRoom) {
|
||||||
if (currentRoom.timelineSize < 20)
|
if (currentRoom.timelineSize < 20) {
|
||||||
currentRoom.getPreviousContent(50)
|
currentRoom.getPreviousContent(50);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
positionViewAtBeginning();
|
positionViewAtBeginning();
|
||||||
|
|||||||
@@ -370,6 +370,20 @@ int MessageEventModel::rowCount(const QModelIndex &parent) const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MessageEventModel::canFetchMore(const QModelIndex &parent) const
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
|
||||||
|
return m_currentRoom && !m_currentRoom->eventsHistoryJob() && !m_currentRoom->allHistoryLoaded();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessageEventModel::fetchMore(const QModelIndex &parent)
|
||||||
|
{
|
||||||
|
Q_UNUSED(parent);
|
||||||
|
m_currentRoom->getPreviousContent(20);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline QVariantMap userAtEvent(NeoChatUser *user, NeoChatRoom *room, const RoomEvent &evt)
|
inline QVariantMap userAtEvent(NeoChatUser *user, NeoChatRoom *room, const RoomEvent &evt)
|
||||||
{
|
{
|
||||||
Q_UNUSED(evt)
|
Q_UNUSED(evt)
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ private:
|
|||||||
[[nodiscard]] QDateTime makeMessageTimestamp(const Quotient::Room::rev_iter_t &baseIt) const;
|
[[nodiscard]] QDateTime makeMessageTimestamp(const Quotient::Room::rev_iter_t &baseIt) const;
|
||||||
[[nodiscard]] static QString renderDate(const QDateTime ×tamp);
|
[[nodiscard]] static QString renderDate(const QDateTime ×tamp);
|
||||||
|
|
||||||
|
bool canFetchMore(const QModelIndex &parent) const override;
|
||||||
|
void fetchMore(const QModelIndex &parent) override;
|
||||||
|
|
||||||
void refreshLastUserEvents(int baseTimelineRow);
|
void refreshLastUserEvents(int baseTimelineRow);
|
||||||
void refreshEventRoles(int row, const QVector<int> &roles = {});
|
void refreshEventRoles(int row, const QVector<int> &roles = {});
|
||||||
int refreshEventRoles(const QString &eventId, const QVector<int> &roles = {});
|
int refreshEventRoles(const QString &eventId, const QVector<int> &roles = {});
|
||||||
|
|||||||
Reference in New Issue
Block a user