Allow editing unsent messages
As of 0db4d71ec2 (Prevent edits of
unsent messages), messages that are edits of (or replies to) unsent
messages were not allowed. This change was made because otherwise
the edits were discarded due to use of txnid rather than mxid in the
"m.relates_to" object. Remove this restriction and fix the issue by
replacing txnid with mxid in all related events when the message is
sent (and we obtain mxid from the server).
This commit is contained in:
parent
9e2b5a1061
commit
9f798e76ed
4 changed files with 67 additions and 7 deletions
|
|
@ -375,6 +375,15 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
|||
connect(&events, &EventStore::updateFlowEventId, this, [this](std::string event_id) {
|
||||
this->updateFlowEventId(event_id);
|
||||
});
|
||||
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_);
|
||||
}
|
||||
});
|
||||
|
||||
showEventTimer.callOnTimeout(this, &TimelineModel::scrollTimerEvent);
|
||||
}
|
||||
|
|
@ -568,10 +577,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);
|
||||
|
|
@ -1796,9 +1803,6 @@ TimelineModel::formatMemberEvent(QString id)
|
|||
void
|
||||
TimelineModel::setEdit(QString newEdit)
|
||||
{
|
||||
if (edit_.startsWith('m'))
|
||||
return;
|
||||
|
||||
if (newEdit.isEmpty()) {
|
||||
resetEdit();
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue