Stop sync timer after logout

Silence errors from redacted events
This commit is contained in:
Konstantinos Sideris 2017-09-30 15:52:14 +03:00
parent 4c00e64f3f
commit b9521b0809
2 changed files with 22 additions and 1 deletions

View file

@ -264,6 +264,10 @@ ChatPage::setOwnAvatar(const QPixmap &img)
void void
ChatPage::syncFailed(const QString &msg) ChatPage::syncFailed(const QString &msg)
{ {
// Stop if sync is not active. e.g user is logged out.
if (client_->getHomeServer().isEmpty())
return;
qWarning() << "Sync error:" << msg; qWarning() << "Sync error:" << msg;
sync_timer_->start(sync_interval_ * 5); sync_timer_->start(sync_interval_ * 5);
} }

View file

@ -34,6 +34,19 @@
namespace events = matrix::events; namespace events = matrix::events;
namespace msgs = matrix::events::messages; namespace msgs = matrix::events::messages;
static bool
isRedactedEvent(const QJsonObject &event)
{
if (event.contains("redacted_because"))
return true;
if (event.contains("unsigned") &&
event.value("unsigned").toObject().contains("redacted_because"))
return true;
return false;
}
TimelineView::TimelineView(const Timeline &timeline, TimelineView::TimelineView(const Timeline &timeline,
QSharedPointer<MatrixClient> client, QSharedPointer<MatrixClient> client,
const QString &room_id, const QString &room_id,
@ -310,7 +323,11 @@ TimelineView::parseMessageEvent(const QJsonObject &event, TimelineDirection dire
return createTimelineItem(emote, with_sender); return createTimelineItem(emote, with_sender);
} else if (msg_type == events::MessageEventType::Unknown) { } else if (msg_type == events::MessageEventType::Unknown) {
qWarning() << "Unknown message type" << event; // TODO Handle redacted messages.
// Silenced for now.
if (!isRedactedEvent(event))
qWarning() << "Unknown message type" << event;
return nullptr; return nullptr;
} }
} }