From 73dbd3c8dd78b41c8d93392eac74231e5b4a20d5 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Sat, 14 Jul 2018 12:08:16 +0300 Subject: Re-enable groups --- src/ChatPage.cc | 60 +++++++++++++++++---------------------------------------- 1 file changed, 18 insertions(+), 42 deletions(-) (limited to 'src/ChatPage.cc') diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 336ea7c3..7f6306f6 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -501,31 +501,8 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect(room_list_, &RoomList::roomAvatarChanged, this, &ChatPage::updateTopBarAvatar); - // connect(http::client(), - // SIGNAL(getOwnCommunitiesResponse(QList)), - // this, - // SLOT(updateOwnCommunitiesInfo(QList))); - // connect(http::client(), - // &MatrixClient::communityProfileRetrieved, - // this, - // [this](QString communityId, QJsonObject profile) { - // communities_[communityId]->parseProfile(profile); - // }); - // connect(http::client(), - // &MatrixClient::communityRoomsRetrieved, - // this, - // [this](QString communityId, QJsonObject rooms) { - // communities_[communityId]->parseRooms(rooms); - - // if (communityId == current_community_) { - // if (communityId == "world") { - // room_list_->setFilterRooms(false); - // } else { - // room_list_->setRoomFilter( - // communities_[communityId]->getRoomList()); - // } - // } - // }); + connect( + this, &ChatPage::updateGroupsInfo, communitiesList_, &CommunitiesList::setCommunities); connect(this, &ChatPage::leftRoom, this, &ChatPage::removeRoom); connect(this, &ChatPage::notificationsRetrieved, this, &ChatPage::sendDesktopNotifications); @@ -533,13 +510,13 @@ ChatPage::ChatPage(QSharedPointer userSettings, QWidget *parent) connect(communitiesList_, &CommunitiesList::communityChanged, this, - [this](const QString &communityId) { - current_community_ = communityId; + [this](const QString &groupId) { + current_community_ = groupId; - if (communityId == "world") + if (groupId == "world") room_list_->setFilterRooms(false); else - room_list_->setRoomFilter(communities_[communityId]->getRoomList()); + room_list_->setRoomFilter(communitiesList_->roomList(groupId)); }); connect(¬ificationsManager, @@ -758,18 +735,6 @@ ChatPage::updateTopBarAvatar(const QString &roomid, const QPixmap &img) top_bar_->updateRoomAvatar(img.toImage()); } -void -ChatPage::updateOwnCommunitiesInfo(const QList &own_communities) -{ - for (int i = 0; i < own_communities.size(); i++) { - QSharedPointer community = QSharedPointer(new Community()); - - communities_[own_communities[i]] = community; - } - - communitiesList_->setCommunities(communities_); -} - void ChatPage::changeTopRoomInfo(const QString &room_id) { @@ -1335,7 +1300,18 @@ ChatPage::getProfileInfo() QImage::fromData(QByteArray(data.data(), data.size()))); }); }); - // TODO http::client()->getOwnCommunities(); + + http::v2::client()->joined_groups( + [this](const mtx::responses::JoinedGroups &res, mtx::http::RequestErr err) { + if (err) { + nhlog::net()->critical("failed to retrieve joined groups: {} {}", + static_cast(err->status_code), + err->matrix_error.error); + return; + } + + emit updateGroupsInfo(res); + }); } void -- cgit 1.5.1