|
|
@ -552,17 +552,40 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline) |
|
|
|
updateLastMessage(); |
|
|
|
updateLastMessage(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> |
|
|
|
|
|
|
|
auto |
|
|
|
|
|
|
|
isMessage(const mtx::events::RoomEvent<T> &e) |
|
|
|
|
|
|
|
-> std::enable_if_t<std::is_same<decltype(e.content.msgtype), std::string>::value, bool> |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template<typename T> |
|
|
|
|
|
|
|
auto |
|
|
|
|
|
|
|
isMessage(const mtx::events::Event<T> &) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
TimelineModel::updateLastMessage() |
|
|
|
TimelineModel::updateLastMessage() |
|
|
|
{ |
|
|
|
{ |
|
|
|
auto event = events.value(eventOrder.back()); |
|
|
|
for (auto it = eventOrder.rbegin(); it != eventOrder.rend(); ++it) { |
|
|
|
if (auto e = boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(&event)) { |
|
|
|
auto event = events.value(*it); |
|
|
|
|
|
|
|
if (auto e = boost::get<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>( |
|
|
|
|
|
|
|
&event)) { |
|
|
|
event = decryptEvent(*e).event; |
|
|
|
event = decryptEvent(*e).event; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!boost::apply_visitor([](const auto &e) -> bool { return isMessage(e); }, |
|
|
|
|
|
|
|
event)) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
auto description = utils::getMessageDescription( |
|
|
|
auto description = utils::getMessageDescription( |
|
|
|
event, QString::fromStdString(http::client()->user_id().to_string()), room_id_); |
|
|
|
event, QString::fromStdString(http::client()->user_id().to_string()), room_id_); |
|
|
|
emit manager_->updateRoomsLastMessage(room_id_, description); |
|
|
|
emit manager_->updateRoomsLastMessage(room_id_, description); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<QString> |
|
|
|
std::vector<QString> |
|
|
|