mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Fix memory leak and invite filtering
This commit is contained in:
parent
1295e84020
commit
2abd2870e0
2 changed files with 12 additions and 10 deletions
|
@ -954,18 +954,17 @@ InputBar::command(const QString &command, QString args)
|
||||||
void
|
void
|
||||||
InputBar::toggleIgnore(const QString &user, const bool ignored)
|
InputBar::toggleIgnore(const QString &user, const bool ignored)
|
||||||
{
|
{
|
||||||
QSharedPointer<UserProfile> profile(
|
UserProfile *profile = new UserProfile(QString(), user, TimelineViewManager::instance());
|
||||||
new UserProfile(QString(), user, TimelineViewManager::instance()));
|
connect(profile, &UserProfile::failedToFetchProfile, [user] {
|
||||||
connect(profile.get(), &UserProfile::failedToFetchProfile, [user] {
|
|
||||||
MainWindow::instance()->showNotification(tr("Failed to fetch user %1").arg(user));
|
MainWindow::instance()->showNotification(tr("Failed to fetch user %1").arg(user));
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(profile.get(),
|
connect(
|
||||||
&UserProfile::globalUsernameRetrieved,
|
profile, &UserProfile::globalUsernameRetrieved, [profile, ignored](const QString &user_id) {
|
||||||
[profile, ignored](const QString &user_id) {
|
Q_UNUSED(user_id)
|
||||||
Q_UNUSED(user_id)
|
profile->setIgnored(ignored);
|
||||||
profile->setIgnored(ignored);
|
profile->deleteLater();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
MediaUpload::MediaUpload(std::unique_ptr<QIODevice> source_,
|
||||||
|
|
|
@ -281,9 +281,12 @@ UserProfile::setIgnored(bool ignore)
|
||||||
|
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
const QHash<QString, RoomInfo> invites = cache::invites();
|
const QHash<QString, RoomInfo> invites = cache::invites();
|
||||||
|
FilteredRoomlistModel *room_model = FilteredRoomlistModel::instance();
|
||||||
|
|
||||||
for (auto room = invites.keyBegin(), end = invites.keyEnd(); room != end; room++) {
|
for (auto room = invites.keyBegin(), end = invites.keyEnd(); room != end; room++) {
|
||||||
FilteredRoomlistModel::instance()->declineInvite(*room);
|
if (room_model->getRoomPreviewById(*room).inviterUserId() == userid) {
|
||||||
|
room_model->declineInvite(*room);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue