Changeset View
Changeset View
Standalone View
Standalone View
src/matrix-room-timeline.cpp
| Show All 17 Lines | |||||
| #include "matrix-event.hpp" | #include "matrix-event.hpp" | ||||
| #include "helper.hpp" | #include "helper.hpp" | ||||
| #include "kazv-log.hpp" | #include "kazv-log.hpp" | ||||
| using namespace Kazv; | using namespace Kazv; | ||||
| MatrixRoomTimeline::MatrixRoomTimeline(Kazv::Room room, QObject *parent) | MatrixRoomTimeline::MatrixRoomTimeline(lager::reader<immer::flex_vector<std::string>> eventIds, lager::reader<immer::map<std::string, Kazv::Event>> messagesMap, lager::reader<immer::flex_vector<LocalEchoDesc>> localEchoes, lager::reader<immer::map<std::string, std::string>> timelineGaps, Kazv::Room room, QObject *parent) | ||||
| : KazvAbstractListModel(parent) | : KazvAbstractListModel(parent) | ||||
| , m_room(room) | , m_room(room) | ||||
| , m_timelineEventIds(m_room.timelineEventIds()) | , m_timelineEventIds(eventIds) | ||||
| , m_messagesMap(m_room.messagesMap()) | , m_messagesMap(messagesMap) | ||||
| , m_localEchoes(m_room.localEchoes()) | , m_localEchoes(localEchoes) | ||||
| , m_timelineGaps(m_room.timelineGaps()) | , m_timelineGaps(timelineGaps) | ||||
| , LAGER_QT(gaps)(m_timelineGaps.map([](auto g) { | , LAGER_QT(gaps)(m_timelineGaps.map([](auto g) { | ||||
| QSet<QString> res{}; | QSet<QString> res{}; | ||||
| for (const auto &[k, _v] : g) { | for (const auto &[k, _v] : g) { | ||||
| res.insert(QString::fromStdString(k)); | res.insert(QString::fromStdString(k)); | ||||
| } | } | ||||
| return res; | return res; | ||||
| })) | })) | ||||
| { | { | ||||
| initCountCursor(lager::with( | initCountCursor(lager::with( | ||||
| m_timelineEventIds.xform(containerSize), | m_timelineEventIds.xform(containerSize), | ||||
| m_localEchoes.xform(containerSize) | m_localEchoes.xform(containerSize) | ||||
| ).map([](const auto &tlSize, const auto &localSize) { return tlSize + localSize; }), InitLater); | ).map([](const auto &tlSize, const auto &localSize) { return tlSize + localSize; }), InitLater); | ||||
| } | |||||
| MatrixRoomTimeline::MatrixRoomTimeline(Kazv::Room room, QObject *parent) | |||||
| : MatrixRoomTimeline( | |||||
| room.timelineEventIds(), | |||||
| room.messagesMap(), | |||||
| room.localEchoes(), | |||||
| room.timelineGaps(), | |||||
| room, | |||||
| parent | |||||
| ) | |||||
| { | |||||
| } | } | ||||
| MatrixRoomTimeline::~MatrixRoomTimeline() = default; | MatrixRoomTimeline::~MatrixRoomTimeline() = default; | ||||
| MatrixEvent *MatrixRoomTimeline::at(int index) const | MatrixEvent *MatrixRoomTimeline::at(int index) const | ||||
| { | { | ||||
| return new MatrixEvent(lager::with(m_timelineEventIds, m_messagesMap, m_localEchoes, LAGER_QT(count)) | return new MatrixEvent(lager::with(m_timelineEventIds, m_messagesMap, m_localEchoes, LAGER_QT(count)) | ||||
| .map([index](const auto &tlEventIds, const auto &messagesMap, const auto &localEchoes, const auto &count) -> std::variant<Kazv::Event, Kazv::LocalEchoDesc> { | .map([index](const auto &tlEventIds, const auto &messagesMap, const auto &localEchoes, const auto &count) -> std::variant<Kazv::Event, Kazv::LocalEchoDesc> { | ||||
| ▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines | |||||