Refactor utils::getMessageDescription
This commit is contained in:
parent
b67024149c
commit
95120c602b
@ -19,12 +19,11 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QImage>
|
||||||
#include <json.hpp>
|
#include <json.hpp>
|
||||||
#include <lmdb++.h>
|
#include <lmdb++.h>
|
||||||
#include <mtx/responses.hpp>
|
#include <mtx/responses.hpp>
|
||||||
|
|
||||||
#include "Utils.h"
|
|
||||||
|
|
||||||
struct SearchResult
|
struct SearchResult
|
||||||
{
|
{
|
||||||
QString user_id;
|
QString user_id;
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
#include <mtx.hpp>
|
#include <mtx.hpp>
|
||||||
|
|
||||||
class LeaveRoomDialog;
|
class LeaveRoomDialog;
|
||||||
@ -32,7 +31,9 @@ class OverlayModal;
|
|||||||
class RoomInfoListItem;
|
class RoomInfoListItem;
|
||||||
class Sync;
|
class Sync;
|
||||||
class UserSettings;
|
class UserSettings;
|
||||||
|
class Cache;
|
||||||
struct DescInfo;
|
struct DescInfo;
|
||||||
|
struct RoomInfo;
|
||||||
|
|
||||||
class RoomList : public QWidget
|
class RoomList : public QWidget
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Cache.h"
|
||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
|
#include "timeline/widgets/AudioItem.h"
|
||||||
|
#include "timeline/widgets/FileItem.h"
|
||||||
|
#include "timeline/widgets/ImageItem.h"
|
||||||
|
#include "timeline/widgets/VideoItem.h"
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <mtx/events/collections.hpp>
|
#include <mtx/events/collections.hpp>
|
||||||
@ -27,6 +32,64 @@ firstChar(const QString &input);
|
|||||||
QString
|
QString
|
||||||
humanReadableFileSize(uint64_t bytes);
|
humanReadableFileSize(uint64_t bytes);
|
||||||
|
|
||||||
|
//! Match widgets/events with a description message.
|
||||||
|
template<class T>
|
||||||
|
QString
|
||||||
|
messageDescription(const QString &username = "", const QString &body = "")
|
||||||
|
{
|
||||||
|
using Audio = mtx::events::RoomEvent<mtx::events::msg::Audio>;
|
||||||
|
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
||||||
|
using File = mtx::events::RoomEvent<mtx::events::msg::File>;
|
||||||
|
using Image = mtx::events::RoomEvent<mtx::events::msg::Image>;
|
||||||
|
using Notice = mtx::events::RoomEvent<mtx::events::msg::Notice>;
|
||||||
|
using Sticker = mtx::events::Sticker;
|
||||||
|
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||||
|
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
|
|
||||||
|
if (std::is_same<T, AudioItem>::value || std::is_same<T, Audio>::value)
|
||||||
|
return QString("sent an audio clip");
|
||||||
|
else if (std::is_same<T, ImageItem>::value || std::is_same<T, Image>::value)
|
||||||
|
return QString("sent an image");
|
||||||
|
else if (std::is_same<T, FileItem>::value || std::is_same<T, File>::value)
|
||||||
|
return QString("sent a file");
|
||||||
|
else if (std::is_same<T, VideoItem>::value || std::is_same<T, Video>::value)
|
||||||
|
return QString("sent a video clip");
|
||||||
|
else if (std::is_same<T, StickerItem>::value || std::is_same<T, Sticker>::value)
|
||||||
|
return QString("sent a sticker");
|
||||||
|
else if (std::is_same<T, Notice>::value)
|
||||||
|
return QString("sent a notification");
|
||||||
|
else if (std::is_same<T, Text>::value)
|
||||||
|
return QString(": %1").arg(body);
|
||||||
|
else if (std::is_same<T, Emote>::value)
|
||||||
|
return QString("* %1 %2").arg(username).arg(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T, class Event>
|
||||||
|
DescInfo
|
||||||
|
createDescriptionInfo(const Event &event, const QString &localUser, const QString &room_id)
|
||||||
|
{
|
||||||
|
using Text = mtx::events::RoomEvent<mtx::events::msg::Text>;
|
||||||
|
using Emote = mtx::events::RoomEvent<mtx::events::msg::Emote>;
|
||||||
|
|
||||||
|
const auto msg = mpark::get<T>(event);
|
||||||
|
const auto sender = QString::fromStdString(msg.sender);
|
||||||
|
|
||||||
|
const auto username = Cache::displayName(room_id, sender);
|
||||||
|
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
||||||
|
|
||||||
|
bool isText = std::is_same<T, Text>::value;
|
||||||
|
bool isEmote = std::is_same<T, Emote>::value;
|
||||||
|
|
||||||
|
return DescInfo{
|
||||||
|
isEmote ? "" : (sender == localUser ? "You" : username),
|
||||||
|
sender,
|
||||||
|
(isText || isEmote)
|
||||||
|
? messageDescription<T>(username, QString::fromStdString(msg.content.body).trimmed())
|
||||||
|
: QString(" %1").arg(messageDescription<T>()),
|
||||||
|
utils::descriptiveTime(ts),
|
||||||
|
ts};
|
||||||
|
}
|
||||||
|
|
||||||
//! Scale down an image to fit to the given width & height limitations.
|
//! Scale down an image to fit to the given width & height limitations.
|
||||||
template<class ImageType>
|
template<class ImageType>
|
||||||
ImageType
|
ImageType
|
||||||
|
@ -26,11 +26,12 @@
|
|||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
|
|
||||||
#include "AvatarProvider.h"
|
#include "AvatarProvider.h"
|
||||||
#include "Cache.h"
|
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
#include "Cache.h"
|
||||||
|
|
||||||
class ImageItem;
|
class ImageItem;
|
||||||
class StickerItem;
|
class StickerItem;
|
||||||
class AudioItem;
|
class AudioItem;
|
||||||
@ -136,16 +137,10 @@ private:
|
|||||||
void addSaveImageAction(ImageItem *image);
|
void addSaveImageAction(ImageItem *image);
|
||||||
|
|
||||||
template<class Widget>
|
template<class Widget>
|
||||||
void setupLocalWidgetLayout(Widget *widget,
|
void setupLocalWidgetLayout(Widget *widget, const QString &userid, bool withSender);
|
||||||
const QString &userid,
|
|
||||||
const QString &msgDescription,
|
|
||||||
bool withSender);
|
|
||||||
|
|
||||||
template<class Event, class Widget>
|
template<class Event, class Widget>
|
||||||
void setupWidgetLayout(Widget *widget,
|
void setupWidgetLayout(Widget *widget, const Event &event, bool withSender);
|
||||||
const Event &event,
|
|
||||||
const QString &msgDescription,
|
|
||||||
bool withSender);
|
|
||||||
|
|
||||||
void generateBody(const QString &body);
|
void generateBody(const QString &body);
|
||||||
void generateBody(const QString &userid, const QString &body);
|
void generateBody(const QString &userid, const QString &body);
|
||||||
@ -184,17 +179,14 @@ private:
|
|||||||
|
|
||||||
template<class Widget>
|
template<class Widget>
|
||||||
void
|
void
|
||||||
TimelineItem::setupLocalWidgetLayout(Widget *widget,
|
TimelineItem::setupLocalWidgetLayout(Widget *widget, const QString &userid, bool withSender)
|
||||||
const QString &userid,
|
|
||||||
const QString &msgDescription,
|
|
||||||
bool withSender)
|
|
||||||
{
|
{
|
||||||
auto displayName = Cache::displayName(room_id_, userid);
|
auto displayName = Cache::displayName(room_id_, userid);
|
||||||
auto timestamp = QDateTime::currentDateTime();
|
auto timestamp = QDateTime::currentDateTime();
|
||||||
|
|
||||||
descriptionMsg_ = {"You",
|
descriptionMsg_ = {"You",
|
||||||
userid,
|
userid,
|
||||||
QString(" %1").arg(msgDescription),
|
QString(" %1").arg(utils::messageDescription<Widget>()),
|
||||||
utils::descriptiveTime(timestamp),
|
utils::descriptiveTime(timestamp),
|
||||||
timestamp};
|
timestamp};
|
||||||
|
|
||||||
@ -227,10 +219,7 @@ TimelineItem::setupLocalWidgetLayout(Widget *widget,
|
|||||||
|
|
||||||
template<class Event, class Widget>
|
template<class Event, class Widget>
|
||||||
void
|
void
|
||||||
TimelineItem::setupWidgetLayout(Widget *widget,
|
TimelineItem::setupWidgetLayout(Widget *widget, const Event &event, bool withSender)
|
||||||
const Event &event,
|
|
||||||
const QString &msgDescription,
|
|
||||||
bool withSender)
|
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@ -243,7 +232,7 @@ TimelineItem::setupWidgetLayout(Widget *widget,
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
descriptionMsg_ = {sender == settings.value("auth/user_id") ? "You" : displayName,
|
descriptionMsg_ = {sender == settings.value("auth/user_id") ? "You" : displayName,
|
||||||
sender,
|
sender,
|
||||||
msgDescription,
|
QString(" %1").arg(utils::messageDescription<Widget>()),
|
||||||
utils::descriptiveTime(timestamp),
|
utils::descriptiveTime(timestamp),
|
||||||
timestamp};
|
timestamp};
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include <variant.hpp>
|
#include <variant.hpp>
|
||||||
|
|
||||||
#include "Cache.h"
|
#include "Cache.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
//! Should be changed when a breaking change occurs in the cache format.
|
//! Should be changed when a breaking change occurs in the cache format.
|
||||||
//! This will reset client's data.
|
//! This will reset client's data.
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "RoomInfoListItem.h"
|
#include "RoomInfoListItem.h"
|
||||||
#include "RoomList.h"
|
#include "RoomList.h"
|
||||||
#include "UserSettingsPage.h"
|
#include "UserSettingsPage.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
RoomList::RoomList(QSharedPointer<MatrixClient> client,
|
RoomList::RoomList(QSharedPointer<MatrixClient> client,
|
||||||
QSharedPointer<UserSettings> userSettings,
|
QSharedPointer<UserSettings> userSettings,
|
||||||
|
97
src/Utils.cc
97
src/Utils.cc
@ -1,7 +1,5 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
#include "Cache.h"
|
|
||||||
|
|
||||||
#include <variant.hpp>
|
#include <variant.hpp>
|
||||||
|
|
||||||
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
||||||
@ -36,100 +34,21 @@ utils::getMessageDescription(const TimelineEvent &event,
|
|||||||
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
using Video = mtx::events::RoomEvent<mtx::events::msg::Video>;
|
||||||
|
|
||||||
if (mpark::holds_alternative<Audio>(event)) {
|
if (mpark::holds_alternative<Audio>(event)) {
|
||||||
const auto msg = mpark::get<Audio>(event);
|
return createDescriptionInfo<Audio>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
|
|
||||||
return DescInfo{sender == localUser ? "You" : username,
|
|
||||||
sender,
|
|
||||||
" sent an audio clip",
|
|
||||||
utils::descriptiveTime(ts),
|
|
||||||
ts};
|
|
||||||
} else if (mpark::holds_alternative<Emote>(event)) {
|
} else if (mpark::holds_alternative<Emote>(event)) {
|
||||||
auto msg = mpark::get<Emote>(event);
|
return createDescriptionInfo<Emote>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
const auto body = QString::fromStdString(msg.content.body).trimmed();
|
|
||||||
|
|
||||||
return DescInfo{"",
|
|
||||||
sender,
|
|
||||||
QString("* %1 %2").arg(username).arg(body),
|
|
||||||
utils::descriptiveTime(ts),
|
|
||||||
ts};
|
|
||||||
} else if (mpark::holds_alternative<File>(event)) {
|
} else if (mpark::holds_alternative<File>(event)) {
|
||||||
const auto msg = mpark::get<File>(event);
|
return createDescriptionInfo<File>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
|
|
||||||
return DescInfo{sender == localUser ? "You" : username,
|
|
||||||
sender,
|
|
||||||
" sent a file",
|
|
||||||
utils::descriptiveTime(ts),
|
|
||||||
ts};
|
|
||||||
} else if (mpark::holds_alternative<Image>(event)) {
|
} else if (mpark::holds_alternative<Image>(event)) {
|
||||||
const auto msg = mpark::get<Image>(event);
|
return createDescriptionInfo<Image>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
|
|
||||||
return DescInfo{sender == localUser ? "You" : username,
|
|
||||||
sender,
|
|
||||||
" sent an image",
|
|
||||||
utils::descriptiveTime(ts),
|
|
||||||
ts};
|
|
||||||
} else if (mpark::holds_alternative<Notice>(event)) {
|
} else if (mpark::holds_alternative<Notice>(event)) {
|
||||||
const auto msg = mpark::get<Notice>(event);
|
return createDescriptionInfo<Notice>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
|
|
||||||
return DescInfo{
|
|
||||||
username, sender, " sent a notification", utils::descriptiveTime(ts), ts};
|
|
||||||
} else if (mpark::holds_alternative<Text>(event)) {
|
} else if (mpark::holds_alternative<Text>(event)) {
|
||||||
const auto msg = mpark::get<Text>(event);
|
return createDescriptionInfo<Text>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
const auto body = QString::fromStdString(msg.content.body).trimmed();
|
|
||||||
|
|
||||||
return DescInfo{sender == localUser ? "You" : username,
|
|
||||||
sender,
|
|
||||||
QString(": %1").arg(body),
|
|
||||||
utils::descriptiveTime(ts),
|
|
||||||
ts};
|
|
||||||
} else if (mpark::holds_alternative<Video>(event)) {
|
} else if (mpark::holds_alternative<Video>(event)) {
|
||||||
const auto msg = mpark::get<Video>(event);
|
return createDescriptionInfo<Video>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
|
|
||||||
return DescInfo{sender == localUser ? "You" : username,
|
|
||||||
sender,
|
|
||||||
" sent a video clip",
|
|
||||||
utils::descriptiveTime(ts),
|
|
||||||
ts};
|
|
||||||
} else if (mpark::holds_alternative<mtx::events::Sticker>(event)) {
|
} else if (mpark::holds_alternative<mtx::events::Sticker>(event)) {
|
||||||
const auto msg = mpark::get<mtx::events::Sticker>(event);
|
return createDescriptionInfo<mtx::events::Sticker>(event, localUser, room_id);
|
||||||
QString sender = QString::fromStdString(msg.sender);
|
|
||||||
|
|
||||||
const auto username = Cache::displayName(room_id, sender);
|
|
||||||
const auto ts = QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts);
|
|
||||||
|
|
||||||
return DescInfo{sender == localUser ? "You" : username,
|
|
||||||
sender,
|
|
||||||
" sent a sticker",
|
|
||||||
utils::descriptiveTime(ts),
|
|
||||||
ts};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DescInfo{};
|
return DescInfo{};
|
||||||
|
@ -152,7 +152,7 @@ TimelineItem::TimelineItem(ImageItem *image,
|
|||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
setupLocalWidgetLayout<ImageItem>(image, userid, "sent an image", withSender);
|
setupLocalWidgetLayout<ImageItem>(image, userid, withSender);
|
||||||
|
|
||||||
addSaveImageAction(image);
|
addSaveImageAction(image);
|
||||||
}
|
}
|
||||||
@ -167,7 +167,7 @@ TimelineItem::TimelineItem(FileItem *file,
|
|||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
setupLocalWidgetLayout<FileItem>(file, userid, "sent a file", withSender);
|
setupLocalWidgetLayout<FileItem>(file, userid, withSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineItem::TimelineItem(AudioItem *audio,
|
TimelineItem::TimelineItem(AudioItem *audio,
|
||||||
@ -180,7 +180,7 @@ TimelineItem::TimelineItem(AudioItem *audio,
|
|||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
setupLocalWidgetLayout<AudioItem>(audio, userid, "sent an audio clip", withSender);
|
setupLocalWidgetLayout<AudioItem>(audio, userid, withSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineItem::TimelineItem(VideoItem *video,
|
TimelineItem::TimelineItem(VideoItem *video,
|
||||||
@ -193,7 +193,7 @@ TimelineItem::TimelineItem(VideoItem *video,
|
|||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
|
|
||||||
setupLocalWidgetLayout<VideoItem>(video, userid, "sent a video clip", withSender);
|
setupLocalWidgetLayout<VideoItem>(video, userid, withSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineItem::TimelineItem(ImageItem *image,
|
TimelineItem::TimelineItem(ImageItem *image,
|
||||||
@ -205,7 +205,7 @@ TimelineItem::TimelineItem(ImageItem *image,
|
|||||||
, room_id_{room_id}
|
, room_id_{room_id}
|
||||||
{
|
{
|
||||||
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::Image>, ImageItem>(
|
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::Image>, ImageItem>(
|
||||||
image, event, " sent an image", with_sender);
|
image, event, with_sender);
|
||||||
|
|
||||||
addSaveImageAction(image);
|
addSaveImageAction(image);
|
||||||
}
|
}
|
||||||
@ -218,8 +218,7 @@ TimelineItem::TimelineItem(StickerItem *image,
|
|||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
, room_id_{room_id}
|
, room_id_{room_id}
|
||||||
{
|
{
|
||||||
setupWidgetLayout<mtx::events::Sticker, StickerItem>(
|
setupWidgetLayout<mtx::events::Sticker, StickerItem>(image, event, with_sender);
|
||||||
image, event, " sent a sticker", with_sender);
|
|
||||||
|
|
||||||
addSaveImageAction(image);
|
addSaveImageAction(image);
|
||||||
}
|
}
|
||||||
@ -233,7 +232,7 @@ TimelineItem::TimelineItem(FileItem *file,
|
|||||||
, room_id_{room_id}
|
, room_id_{room_id}
|
||||||
{
|
{
|
||||||
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::File>, FileItem>(
|
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::File>, FileItem>(
|
||||||
file, event, " sent a file", with_sender);
|
file, event, with_sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineItem::TimelineItem(AudioItem *audio,
|
TimelineItem::TimelineItem(AudioItem *audio,
|
||||||
@ -245,7 +244,7 @@ TimelineItem::TimelineItem(AudioItem *audio,
|
|||||||
, room_id_{room_id}
|
, room_id_{room_id}
|
||||||
{
|
{
|
||||||
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::Audio>, AudioItem>(
|
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::Audio>, AudioItem>(
|
||||||
audio, event, " sent an audio clip", with_sender);
|
audio, event, with_sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
TimelineItem::TimelineItem(VideoItem *video,
|
TimelineItem::TimelineItem(VideoItem *video,
|
||||||
@ -257,7 +256,7 @@ TimelineItem::TimelineItem(VideoItem *video,
|
|||||||
, room_id_{room_id}
|
, room_id_{room_id}
|
||||||
{
|
{
|
||||||
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::Video>, VideoItem>(
|
setupWidgetLayout<mtx::events::RoomEvent<mtx::events::msg::Video>, VideoItem>(
|
||||||
video, event, " sent a video clip", with_sender);
|
video, event, with_sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
#include "Cache.h"
|
||||||
#include "ChatPage.h"
|
#include "ChatPage.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
#include "FloatingButton.h"
|
#include "FloatingButton.h"
|
||||||
@ -212,8 +213,9 @@ TimelineView::addBackwardsEvents(const QString &room_id, const mtx::responses::M
|
|||||||
isTimelineFinished = false;
|
isTimelineFinished = false;
|
||||||
|
|
||||||
// Queue incoming messages to be rendered later.
|
// Queue incoming messages to be rendered later.
|
||||||
for (auto const &e : msgs.chunk)
|
topMessages_.insert(topMessages_.end(),
|
||||||
topMessages_.emplace_back(e);
|
std::make_move_iterator(msgs.chunk.begin()),
|
||||||
|
std::make_move_iterator(msgs.chunk.end()));
|
||||||
|
|
||||||
// The RoomList message preview will be updated only if this
|
// The RoomList message preview will be updated only if this
|
||||||
// is the first batch of messages received through /messages
|
// is the first batch of messages received through /messages
|
||||||
@ -361,8 +363,9 @@ TimelineView::addEvents(const mtx::responses::Timeline &timeline)
|
|||||||
isInitialSync = false;
|
isInitialSync = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &e : timeline.events)
|
bottomMessages_.insert(bottomMessages_.end(),
|
||||||
bottomMessages_.push_back(e);
|
std::make_move_iterator(timeline.events.begin()),
|
||||||
|
std::make_move_iterator(timeline.events.end()));
|
||||||
|
|
||||||
if (!bottomMessages_.empty())
|
if (!bottomMessages_.empty())
|
||||||
notifyForLastEvent(findLastViewableEvent(bottomMessages_));
|
notifyForLastEvent(findLastViewableEvent(bottomMessages_));
|
||||||
|
Loading…
Reference in New Issue
Block a user