Fix timestamps on some messages loaded from the recent-messages service on startup (#2020)

This commit is contained in:
Daniel
2020-10-03 07:37:07 -04:00
committed by GitHub
parent b67e20d962
commit 58a6983796
7 changed files with 52 additions and 52 deletions
+21
View File
@@ -58,4 +58,25 @@ inline QString parseTagString(const QString &input)
return output;
}
inline QTime calculateMessageTimestamp(const Communi::IrcMessage *message)
{
// Check if message is from recent-messages API
if (message->tags().contains("historical"))
{
bool customReceived = false;
qint64 ts =
message->tags().value("rm-received-ts").toLongLong(&customReceived);
if (!customReceived)
{
ts = message->tags().value("tmi-sent-ts").toLongLong();
}
return QDateTime::fromMSecsSinceEpoch(ts).time();
}
else
{
return QTime::currentTime();
}
}
} // namespace chatterino