mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Reenable redactions
This commit is contained in:
parent
0d3c9390c6
commit
aee29c6ed5
6 changed files with 26 additions and 8 deletions
|
@ -199,6 +199,7 @@ Rectangle {
|
|||
}
|
||||
MenuItem {
|
||||
text: qsTr("Redact message")
|
||||
onTriggered: chat.model.redactEvent(model.id)
|
||||
}
|
||||
MenuItem {
|
||||
visible: model.type == MtxEvent.ImageMessage || model.type == MtxEvent.VideoMessage || model.type == MtxEvent.AudioMessage || model.type == MtxEvent.FileMessage
|
||||
|
|
|
@ -115,11 +115,6 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||
contentLayout_->addWidget(top_bar_);
|
||||
contentLayout_->addWidget(view_manager_->getWidget());
|
||||
|
||||
connect(this,
|
||||
&ChatPage::removeTimelineEvent,
|
||||
view_manager_,
|
||||
&TimelineViewManager::removeTimelineEvent);
|
||||
|
||||
// Splitter
|
||||
splitter->addWidget(sideBar_);
|
||||
splitter->addWidget(content_);
|
||||
|
|
|
@ -125,8 +125,6 @@ signals:
|
|||
void showUserSettingsPage();
|
||||
void showOverlayProgressBar();
|
||||
|
||||
void removeTimelineEvent(const QString &room_id, const QString &event_id);
|
||||
|
||||
void ownProfileOk();
|
||||
void setUserDisplayName(const QString &name);
|
||||
void setUserAvatar(const QString &avatar);
|
||||
|
|
|
@ -321,6 +321,9 @@ TimelineModel::TimelineModel(QString room_id, QObject *parent)
|
|||
|
||||
emit dataChanged(index(idx, 0), index(idx, 0));
|
||||
});
|
||||
connect(this, &TimelineModel::redactionFailed, this, [](const QString &msg) {
|
||||
emit ChatPage::instance()->showNotification(msg);
|
||||
});
|
||||
}
|
||||
|
||||
QHash<int, QByteArray>
|
||||
|
@ -745,6 +748,25 @@ TimelineModel::readReceiptsAction(QString id) const
|
|||
MainWindow::instance()->openReadReceiptsDialog(id);
|
||||
}
|
||||
|
||||
void
|
||||
TimelineModel::redactEvent(QString id)
|
||||
{
|
||||
if (!id.isEmpty())
|
||||
http::client()->redact_event(
|
||||
room_id_.toStdString(),
|
||||
id.toStdString(),
|
||||
[this, id](const mtx::responses::EventId &, mtx::http::RequestErr err) {
|
||||
if (err) {
|
||||
emit redactionFailed(
|
||||
tr("Message redaction failed: %1")
|
||||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
return;
|
||||
}
|
||||
|
||||
emit eventRedacted(id);
|
||||
});
|
||||
}
|
||||
|
||||
int
|
||||
TimelineModel::idToIndex(QString id) const
|
||||
{
|
||||
|
|
|
@ -149,6 +149,7 @@ public:
|
|||
Q_INVOKABLE void viewRawMessage(QString id) const;
|
||||
Q_INVOKABLE void replyAction(QString id);
|
||||
Q_INVOKABLE void readReceiptsAction(QString id) const;
|
||||
Q_INVOKABLE void redactEvent(QString id);
|
||||
Q_INVOKABLE int idToIndex(QString id) const;
|
||||
Q_INVOKABLE QString indexToId(int index) const;
|
||||
|
||||
|
@ -175,6 +176,8 @@ signals:
|
|||
void messageFailed(QString txn_id);
|
||||
void messageSent(QString txn_id, QString event_id);
|
||||
void currentIndexChanged(int index);
|
||||
void redactionFailed(QString id);
|
||||
void eventRedacted(QString id);
|
||||
|
||||
private:
|
||||
DecryptionResult decryptEvent(
|
||||
|
|
|
@ -66,7 +66,6 @@ signals:
|
|||
|
||||
public slots:
|
||||
void updateReadReceipts(const QString &room_id, const std::vector<QString> &event_ids);
|
||||
void removeTimelineEvent(const QString &room_id, const QString &event_id) {}
|
||||
void initWithMessages(const std::map<QString, mtx::responses::Timeline> &msgs);
|
||||
|
||||
void setHistoryView(const QString &room_id);
|
||||
|
|
Loading…
Reference in a new issue