diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index f29f929e..caa40353 100644
--- a/src/timeline/TimelineModel.cpp
+++ b/src/timeline/TimelineModel.cpp
@@ -320,6 +320,10 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
{
lastMessage_.timestamp = 0;
+ if (auto create =
+ cache::client()->getStateEvent<mtx::events::state::Create>(room_id.toStdString()))
+ this->isSpace_ = create->content.type == mtx::events::state::room_type::space;
+
connect(
this,
&TimelineModel::redactionFailed,
@@ -376,6 +380,27 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
this->updateFlowEventId(event_id);
});
+ // When a message is sent, check if the current edit/reply relates to that message,
+ // and update the event_id so that it points to the sent message and not the pending one.
+ connect(&events,
+ &EventStore::messageSent,
+ this,
+ [this](std::string txn_id, std::string event_id) {
+ if (edit_.toStdString() == txn_id) {
+ edit_ = QString::fromStdString(event_id);
+ emit editChanged(edit_);
+ }
+ if (reply_.toStdString() == txn_id) {
+ reply_ = QString::fromStdString(event_id);
+ emit replyChanged(reply_);
+ }
+ });
+
+ connect(manager_,
+ &TimelineViewManager::initialSyncChanged,
+ &events,
+ &EventStore::enableKeyRequests);
+
showEventTimer.callOnTimeout(this, &TimelineModel::scrollTimerEvent);
}
@@ -507,6 +532,10 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
const static QRegularExpression matchImgUri(
"(<img [^>]*)src=\"mxc://([^\"]*)\"([^>]*>)");
formattedBody_.replace(matchImgUri, "\\1 src=\"image://mxcImage/\\2\"\\3");
+ // Same regex but for single quotes around the src
+ const static QRegularExpression matchImgUri2(
+ "(<img [^>]*)src=\'mxc://([^\']*)\'([^>]*>)");
+ formattedBody_.replace(matchImgUri2, "\\1 src=\"image://mxcImage/\\2\"\\3");
const static QRegularExpression matchEmoticonHeight(
"(<img data-mx-emoticon [^>]*)height=\"([^\"]*)\"([^>]*>)");
formattedBody_.replace(matchEmoticonHeight,
@@ -568,10 +597,8 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
case IsEdited:
return QVariant(relations(event).replaces().has_value());
case IsEditable:
- return QVariant(!is_state_event(event) &&
- mtx::accessors::sender(event) ==
- http::client()->user_id().to_string() &&
- !event_id(event).empty() && event_id(event).front() == '$');
+ return QVariant(!is_state_event(event) && mtx::accessors::sender(event) ==
+ http::client()->user_id().to_string());
case IsEncrypted: {
auto id = event_id(event);
auto encrypted_event = events.get(id, "", false);
@@ -757,6 +784,7 @@ TimelineModel::syncState(const mtx::responses::State &s)
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
emit roomAvatarUrlChanged();
emit roomNameChanged();
+ emit roomMemberCountChanged();
}
}
}
@@ -813,6 +841,7 @@ TimelineModel::addEvents(const mtx::responses::Timeline &timeline)
} else if (std::holds_alternative<StateEvent<state::Member>>(e)) {
emit roomAvatarUrlChanged();
emit roomNameChanged();
+ emit roomMemberCountChanged();
}
}
updateLastMessage();
@@ -1787,7 +1816,8 @@ TimelineModel::formatMemberEvent(QString id)
}
if (event->content.reason != "") {
- rendered += tr(" Reason: %1").arg(QString::fromStdString(event->content.reason));
+ rendered +=
+ " " + tr("Reason: %1").arg(QString::fromStdString(event->content.reason));
}
return rendered;
@@ -1796,9 +1826,6 @@ TimelineModel::formatMemberEvent(QString id)
void
TimelineModel::setEdit(QString newEdit)
{
- if (edit_.startsWith('m'))
- return;
-
if (newEdit.isEmpty()) {
resetEdit();
return;
@@ -1921,3 +1948,9 @@ TimelineModel::roomTopic() const
return utils::replaceEmoji(utils::linkifyMessage(
QString::fromStdString(info[room_id_].topic).toHtmlEscaped()));
}
+
+int
+TimelineModel::roomMemberCount() const
+{
+ return (int)cache::client()->memberCount(room_id_.toStdString());
+}
|