mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-29 06:08:48 +03:00
Fix crash when fetching global profile
This commit is contained in:
parent
9570c3ccc4
commit
242b7d5506
3 changed files with 35 additions and 10 deletions
|
@ -67,6 +67,7 @@ Q_DECLARE_METATYPE(mtx::events::collections::TimelineEvents)
|
||||||
Q_DECLARE_METATYPE(std::vector<DeviceInfo>)
|
Q_DECLARE_METATYPE(std::vector<DeviceInfo>)
|
||||||
Q_DECLARE_METATYPE(std::vector<mtx::responses::PublicRoomsChunk>)
|
Q_DECLARE_METATYPE(std::vector<mtx::responses::PublicRoomsChunk>)
|
||||||
Q_DECLARE_METATYPE(mtx::responses::PublicRoom)
|
Q_DECLARE_METATYPE(mtx::responses::PublicRoom)
|
||||||
|
Q_DECLARE_METATYPE(mtx::responses::Profile)
|
||||||
|
|
||||||
MainWindow *MainWindow::instance_ = nullptr;
|
MainWindow *MainWindow::instance_ = nullptr;
|
||||||
|
|
||||||
|
@ -145,6 +146,7 @@ MainWindow::registerQmlTypes()
|
||||||
qRegisterMetaType<mtx::events::msg::KeyVerificationRequest>();
|
qRegisterMetaType<mtx::events::msg::KeyVerificationRequest>();
|
||||||
qRegisterMetaType<mtx::events::msg::KeyVerificationStart>();
|
qRegisterMetaType<mtx::events::msg::KeyVerificationStart>();
|
||||||
qRegisterMetaType<mtx::responses::PublicRoom>();
|
qRegisterMetaType<mtx::responses::PublicRoom>();
|
||||||
|
qRegisterMetaType<mtx::responses::Profile>();
|
||||||
qRegisterMetaType<CombinedImagePackModel *>();
|
qRegisterMetaType<CombinedImagePackModel *>();
|
||||||
qRegisterMetaType<mtx::events::collections::TimelineEvents>();
|
qRegisterMetaType<mtx::events::collections::TimelineEvents>();
|
||||||
qRegisterMetaType<std::vector<DeviceInfo>>();
|
qRegisterMetaType<std::vector<DeviceInfo>>();
|
||||||
|
|
|
@ -487,17 +487,27 @@ UserProfile::isLoading() const
|
||||||
void
|
void
|
||||||
UserProfile::getGlobalProfileData()
|
UserProfile::getGlobalProfileData()
|
||||||
{
|
{
|
||||||
http::client()->get_profile(
|
auto profProx = std::make_shared<UserProfileFetchProxy>();
|
||||||
userid_.toStdString(), [this](const mtx::responses::Profile &res, mtx::http::RequestErr err) {
|
connect(profProx.get(),
|
||||||
if (err) {
|
&UserProfileFetchProxy::profileFetched,
|
||||||
nhlog::net()->warn("failed to retrieve profile info for {}", userid_.toStdString());
|
this,
|
||||||
return;
|
[this](const mtx::responses::Profile &res) {
|
||||||
}
|
|
||||||
|
|
||||||
emit globalUsernameRetrieved(QString::fromStdString(res.display_name));
|
emit globalUsernameRetrieved(QString::fromStdString(res.display_name));
|
||||||
globalAvatarUrl = QString::fromStdString(res.avatar_url);
|
globalAvatarUrl = QString::fromStdString(res.avatar_url);
|
||||||
emit avatarUrlChanged();
|
emit avatarUrlChanged();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
http::client()->get_profile(userid_.toStdString(),
|
||||||
|
[prox = std::move(profProx), user = userid_.toStdString()](
|
||||||
|
const mtx::responses::Profile &res, mtx::http::RequestErr err) {
|
||||||
|
if (err) {
|
||||||
|
nhlog::net()->warn("failed to retrieve profile info for {}",
|
||||||
|
user);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit prox->profileFetched(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -32,6 +32,19 @@ Q_ENUM_NS(Status)
|
||||||
class DeviceVerificationFlow;
|
class DeviceVerificationFlow;
|
||||||
class TimelineViewManager;
|
class TimelineViewManager;
|
||||||
|
|
||||||
|
class UserProfileFetchProxy : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
UserProfileFetchProxy(QObject *p = nullptr)
|
||||||
|
: QObject(p)
|
||||||
|
{}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void profileFetched(mtx::responses::Profile);
|
||||||
|
};
|
||||||
|
|
||||||
class DeviceInfo
|
class DeviceInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue