Update user colors to use Cache vs Utils
User colors are now stored in cache. This is consistent with other similar variables. I think there's a bug right now where it doesn't properly refresh colors for the TimeLineItem when the theme is changed.
This commit is contained in:
parent
4185b8d121
commit
2ba51c821e
6 changed files with 43 additions and 40 deletions
|
|
@ -2059,6 +2059,7 @@ Cache::roomMembers(const std::string &room_id)
|
|||
|
||||
QHash<QString, QString> Cache::DisplayNames;
|
||||
QHash<QString, QString> Cache::AvatarUrls;
|
||||
QHash<QString, QString> Cache::UserColors;
|
||||
|
||||
QString
|
||||
Cache::displayName(const QString &room_id, const QString &user_id)
|
||||
|
|
@ -2090,6 +2091,16 @@ Cache::avatarUrl(const QString &room_id, const QString &user_id)
|
|||
return QString();
|
||||
}
|
||||
|
||||
QString
|
||||
Cache::userColor(const QString &user_id)
|
||||
{
|
||||
if (UserColors.contains(user_id)) {
|
||||
return UserColors[user_id];
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
void
|
||||
Cache::insertDisplayName(const QString &room_id,
|
||||
const QString &user_id,
|
||||
|
|
@ -2119,3 +2130,21 @@ Cache::removeAvatarUrl(const QString &room_id, const QString &user_id)
|
|||
auto fmt = QString("%1 %2").arg(room_id).arg(user_id);
|
||||
AvatarUrls.remove(fmt);
|
||||
}
|
||||
|
||||
void
|
||||
Cache::insertUserColor(const QString &user_id, const QString &color_name)
|
||||
{
|
||||
UserColors.insert(user_id, color_name);
|
||||
}
|
||||
|
||||
void
|
||||
Cache::removeUserColor(const QString &user_id)
|
||||
{
|
||||
UserColors.remove(user_id);
|
||||
}
|
||||
|
||||
void
|
||||
Cache::clearUserColors()
|
||||
{
|
||||
UserColors.clear();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue