De-duplicate the m.room.encryption event

remotes/origin/HEAD
Konstantinos Sideris 6 years ago
parent a9f02128a2
commit 31d09dbd68
  1. 7
      include/timeline/TimelineView.h
  2. 10
      src/timeline/TimelineView.cc

@ -165,7 +165,7 @@ protected:
private:
using TimelineEvent = mtx::events::collections::TimelineEvents;
QWidget *relativeWidget(TimelineItem *item, int dt) const;
QWidget *relativeWidget(QWidget *item, int dt) const;
DecryptionResult parseEncryptedEvent(
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);
@ -265,6 +265,9 @@ private:
QWidget *parseMessageEvent(const mtx::events::collections::TimelineEvents &event,
TimelineDirection direction);
//! Store the event id associated with the given widget.
void saveEventId(QWidget *widget);
QVBoxLayout *top_layout_;
QVBoxLayout *scroll_layout_;
@ -313,7 +316,7 @@ private:
void renderTopEvents(const std::vector<TimelineEvent> &events);
// The events currently rendered. Used for duplicate detection.
QMap<QString, TimelineItem *> eventIds_;
QMap<QString, QWidget *> eventIds_;
QQueue<PendingMessage> pending_msgs_;
QList<PendingMessage> pending_sent_msgs_;
};

@ -221,9 +221,15 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents &
return nullptr;
} 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);
item->saveDatetime(QDateTime::fromMSecsSinceEpoch(msg.origin_server_ts));
eventIds_[event_id] = item;
return item;
} else if (mpark::holds_alternative<RoomEvent<msg::Audio>>(event)) {
@ -993,7 +999,7 @@ TimelineView::removeEvent(const QString &event_id)
}
QWidget *
TimelineView::relativeWidget(TimelineItem *item, int dt) const
TimelineView::relativeWidget(QWidget *item, int dt) const
{
int pos = scroll_layout_->indexOf(item);

Loading…
Cancel
Save