|
|
@ -24,6 +24,7 @@ UserProfile::UserProfile(QString roomid, |
|
|
|
, model(parent) |
|
|
|
, model(parent) |
|
|
|
{ |
|
|
|
{ |
|
|
|
fetchDeviceList(this->userid_); |
|
|
|
fetchDeviceList(this->userid_); |
|
|
|
|
|
|
|
globalAvatarUrl = ""; |
|
|
|
|
|
|
|
|
|
|
|
connect(cache::client(), |
|
|
|
connect(cache::client(), |
|
|
|
&Cache::verificationStatusChanged, |
|
|
|
&Cache::verificationStatusChanged, |
|
|
@ -56,16 +57,9 @@ UserProfile::UserProfile(QString roomid, |
|
|
|
&UserProfile::setGlobalUsername, |
|
|
|
&UserProfile::setGlobalUsername, |
|
|
|
Qt::QueuedConnection); |
|
|
|
Qt::QueuedConnection); |
|
|
|
|
|
|
|
|
|
|
|
http::client()->get_profile( |
|
|
|
if (isGlobalUserProfile()) { |
|
|
|
userid_.toStdString(), |
|
|
|
getGlobalProfileData(); |
|
|
|
[this](const mtx::responses::Profile &res, mtx::http::RequestErr err) { |
|
|
|
|
|
|
|
if (err) { |
|
|
|
|
|
|
|
nhlog::net()->warn("failed to retrieve own profile info"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
emit globalUsernameRetrieved(QString::fromStdString(res.display_name)); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QHash<int, QByteArray> |
|
|
|
QHash<int, QByteArray> |
|
|
@ -125,7 +119,10 @@ UserProfile::displayName() |
|
|
|
QString |
|
|
|
QString |
|
|
|
UserProfile::avatarUrl() |
|
|
|
UserProfile::avatarUrl() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return cache::avatarUrl(roomid_, userid_); |
|
|
|
return (isGlobalUserProfile() && globalAvatarUrl != "") |
|
|
|
|
|
|
|
? globalAvatarUrl |
|
|
|
|
|
|
|
: cache::avatarUrl(roomid_, userid_); |
|
|
|
|
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool |
|
|
|
bool |
|
|
@ -353,6 +350,7 @@ UserProfile::changeAvatar() |
|
|
|
|
|
|
|
|
|
|
|
isLoading_ = false; |
|
|
|
isLoading_ = false; |
|
|
|
emit loadingChanged(); |
|
|
|
emit loadingChanged(); |
|
|
|
|
|
|
|
getGlobalProfileData(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// change room username
|
|
|
|
// change room username
|
|
|
@ -394,3 +392,20 @@ UserProfile::isLoading() const |
|
|
|
{ |
|
|
|
{ |
|
|
|
return isLoading_; |
|
|
|
return isLoading_; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
UserProfile::getGlobalProfileData() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
http::client()->get_profile( |
|
|
|
|
|
|
|
userid_.toStdString(), |
|
|
|
|
|
|
|
[this](const mtx::responses::Profile &res, mtx::http::RequestErr err) { |
|
|
|
|
|
|
|
if (err) { |
|
|
|
|
|
|
|
nhlog::net()->warn("failed to retrieve own profile info"); |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit globalUsernameRetrieved(QString::fromStdString(res.display_name)); |
|
|
|
|
|
|
|
globalAvatarUrl = QString::fromStdString(res.avatar_url); |
|
|
|
|
|
|
|
emit avatarUrlChanged(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |