Reduce allocations for presence states a bit

This commit is contained in:
Nicolas Werner 2021-12-29 22:45:30 +01:00
parent 497c3df50e
commit 7cfb7dcea4
No known key found for this signature in database
GPG key ID: C8D75E610773F2D9

View file

@ -128,10 +128,17 @@ QString
TimelineViewManager::userPresence(QString id) const
{
if (id.isEmpty())
return QString();
return {};
else
return QString::fromStdString(
mtx::presence::to_string(cache::presenceState(id.toStdString())));
switch (cache::presenceState(id.toStdString())) {
case mtx::presence::PresenceState::offline:
return QStringLiteral("offline");
case mtx::presence::PresenceState::unavailable:
return QStringLiteral("unavailable");
case mtx::presence::PresenceState::online:
default:
return QStringLiteral("online");
}
}
QString