mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
fixup! Allow editing unsent messages
This commit is contained in:
parent
9f798e76ed
commit
f8d2564e46
2 changed files with 21 additions and 7 deletions
|
@ -193,6 +193,19 @@ EventStore::EventStore(std::string room_id, QObject *)
|
||||||
cache::client()->getEvent(room_id_, related_event_id).value();
|
cache::client()->getEvent(room_id_, related_event_id).value();
|
||||||
auto relations = mtx::accessors::relations(related_event.data);
|
auto relations = mtx::accessors::relations(related_event.data);
|
||||||
|
|
||||||
|
// Replace the blockquote in fallback reply
|
||||||
|
auto related_text =
|
||||||
|
std::get_if<mtx::events::RoomEvent<mtx::events::msg::Text>>(
|
||||||
|
&related_event.data);
|
||||||
|
if (related_text && relations.reply_to() == txn_id) {
|
||||||
|
size_t index =
|
||||||
|
related_text->content.formatted_body.find(txn_id);
|
||||||
|
if (index != std::string::npos) {
|
||||||
|
related_text->content.formatted_body.replace(
|
||||||
|
index, event_id.length(), event_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (mtx::common::Relation &rel : relations.relations) {
|
for (mtx::common::Relation &rel : relations.relations) {
|
||||||
if (rel.event_id == txn_id)
|
if (rel.event_id == txn_id)
|
||||||
rel.event_id = event_id;
|
rel.event_id = event_id;
|
||||||
|
@ -203,12 +216,10 @@ EventStore::EventStore(std::string room_id, QObject *)
|
||||||
cache::client()->replaceEvent(
|
cache::client()->replaceEvent(
|
||||||
room_id_, related_event_id, related_event);
|
room_id_, related_event_id, related_event);
|
||||||
|
|
||||||
auto id = idToIndex(event_id);
|
auto idx = idToIndex(related_event_id);
|
||||||
|
|
||||||
events_by_id_.remove({room_id_, related_event_id});
|
events_by_id_.remove({room_id_, related_event_id});
|
||||||
events_.remove({room_id_, toInternalIdx(*id)});
|
events_.remove({room_id_, toInternalIdx(*idx)});
|
||||||
|
|
||||||
emit dataChanged(*id, *id);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,10 +231,10 @@ EventStore::EventStore(std::string room_id, QObject *)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
auto id = idToIndex(event_id);
|
auto idx = idToIndex(event_id);
|
||||||
|
|
||||||
if (id)
|
if (idx)
|
||||||
emit dataChanged(id.value(), id.value());
|
emit dataChanged(*idx, *idx);
|
||||||
|
|
||||||
cache::client()->removePendingStatus(room_id_, txn_id);
|
cache::client()->removePendingStatus(room_id_, txn_id);
|
||||||
this->current_txn = "";
|
this->current_txn = "";
|
||||||
|
|
|
@ -383,6 +383,9 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
edit_ = QString::fromStdString(event_id);
|
edit_ = QString::fromStdString(event_id);
|
||||||
emit editChanged(edit_);
|
emit editChanged(edit_);
|
||||||
}
|
}
|
||||||
|
if (reply_.toStdString() == txn_id) {
|
||||||
|
reply_ = QString::fromStdString(event_id);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
showEventTimer.callOnTimeout(this, &TimelineModel::scrollTimerEvent);
|
showEventTimer.callOnTimeout(this, &TimelineModel::scrollTimerEvent);
|
||||||
|
|
Loading…
Reference in a new issue