mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
De-duplicate the m.room.encryption event
This commit is contained in:
parent
a9f02128a2
commit
31d09dbd68
2 changed files with 13 additions and 4 deletions
|
@ -165,7 +165,7 @@ protected:
|
||||||
private:
|
private:
|
||||||
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
using TimelineEvent = mtx::events::collections::TimelineEvents;
|
||||||
|
|
||||||
QWidget *relativeWidget(TimelineItem *item, int dt) const;
|
QWidget *relativeWidget(QWidget *item, int dt) const;
|
||||||
|
|
||||||
DecryptionResult parseEncryptedEvent(
|
DecryptionResult parseEncryptedEvent(
|
||||||
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);
|
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);
|
||||||
|
@ -265,6 +265,9 @@ private:
|
||||||
QWidget *parseMessageEvent(const mtx::events::collections::TimelineEvents &event,
|
QWidget *parseMessageEvent(const mtx::events::collections::TimelineEvents &event,
|
||||||
TimelineDirection direction);
|
TimelineDirection direction);
|
||||||
|
|
||||||
|
//! Store the event id associated with the given widget.
|
||||||
|
void saveEventId(QWidget *widget);
|
||||||
|
|
||||||
QVBoxLayout *top_layout_;
|
QVBoxLayout *top_layout_;
|
||||||
QVBoxLayout *scroll_layout_;
|
QVBoxLayout *scroll_layout_;
|
||||||
|
|
||||||
|
@ -313,7 +316,7 @@ private:
|
||||||
void renderTopEvents(const std::vector<TimelineEvent> &events);
|
void renderTopEvents(const std::vector<TimelineEvent> &events);
|
||||||
|
|
||||||
// The events currently rendered. Used for duplicate detection.
|
// The events currently rendered. Used for duplicate detection.
|
||||||
QMap<QString, TimelineItem *> eventIds_;
|
QMap<QString, QWidget *> eventIds_;
|
||||||
QQueue<PendingMessage> pending_msgs_;
|
QQueue<PendingMessage> pending_msgs_;
|
||||||
QList<PendingMessage> pending_sent_msgs_;
|
QList<PendingMessage> pending_sent_msgs_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -222,8 +222,14 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents &
|
||||||
return nullptr;
|
return nullptr;
|
||||||
} else if (mpark::holds_alternative<StateEvent<state::Encryption>>(event)) {
|
} else if (mpark::holds_alternative<StateEvent<state::Encryption>>(event)) {
|
||||||
auto msg = mpark::get<StateEvent<state::Encryption>>(event);
|
auto msg = mpark::get<StateEvent<state::Encryption>>(event);
|
||||||
|
auto event_id = QString::fromStdString(msg.event_id);
|
||||||
|
|
||||||
|
if (eventIds_.contains(event_id))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
auto item = new InfoMessage(tr("Encryption is enabled"), this);
|
auto item = new InfoMessage(tr("Encryption is enabled"), this);
|
||||||
item->saveDatetime(QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts));
|
item->saveDatetime(QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts));
|
||||||
|
eventIds_[event_id] = item;
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
} else if (mpark::holds_alternative<RoomEvent<msg::Audio>>(event)) {
|
} else if (mpark::holds_alternative<RoomEvent<msg::Audio>>(event)) {
|
||||||
|
@ -993,7 +999,7 @@ TimelineView::removeEvent(const QString &event_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *
|
QWidget *
|
||||||
TimelineView::relativeWidget(TimelineItem *item, int dt) const
|
TimelineView::relativeWidget(QWidget *item, int dt) const
|
||||||
{
|
{
|
||||||
int pos = scroll_layout_->indexOf(item);
|
int pos = scroll_layout_->indexOf(item);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue