mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 04:58:49 +03:00
parent
f9fd03b958
commit
15931fc322
2 changed files with 24 additions and 3 deletions
|
@ -110,11 +110,17 @@ private:
|
||||||
using Membership = mtx::events::StateEvent<mtx::events::state::Member>;
|
using Membership = mtx::events::StateEvent<mtx::events::state::Member>;
|
||||||
using Memberships = std::map<std::string, Membership>;
|
using Memberships = std::map<std::string, Membership>;
|
||||||
|
|
||||||
using JoinedRooms = std::map<std::string, mtx::responses::JoinedRoom>;
|
using JoinedRooms = std::map<std::string, mtx::responses::JoinedRoom>;
|
||||||
using LeftRooms = std::map<std::string, mtx::responses::LeftRoom>;
|
using LeftRooms = std::map<std::string, mtx::responses::LeftRoom>;
|
||||||
|
using InvitedRooms = std::map<std::string, mtx::responses::InvitedRoom>;
|
||||||
|
|
||||||
void removeLeftRooms(const LeftRooms &rooms);
|
void removeLeftRooms(const LeftRooms &rooms);
|
||||||
void updateJoinedRooms(const JoinedRooms &rooms);
|
void updateJoinedRooms(const JoinedRooms &rooms);
|
||||||
|
void trackInvites(const InvitedRooms &rooms)
|
||||||
|
{
|
||||||
|
for (const auto &invite : rooms)
|
||||||
|
roomInvites_[QString::fromStdString(invite.first)] = true;
|
||||||
|
}
|
||||||
|
|
||||||
std::map<QString, QSharedPointer<RoomState>> generateMembershipDifference(
|
std::map<QString, QSharedPointer<RoomState>> generateMembershipDifference(
|
||||||
const JoinedRooms &rooms,
|
const JoinedRooms &rooms,
|
||||||
|
@ -181,6 +187,7 @@ private:
|
||||||
|
|
||||||
RoomStates roomStates_;
|
RoomStates roomStates_;
|
||||||
std::map<QString, QSharedPointer<RoomSettings>> roomSettings_;
|
std::map<QString, QSharedPointer<RoomSettings>> roomSettings_;
|
||||||
|
std::map<QString, bool> roomInvites_;
|
||||||
|
|
||||||
std::map<QString, QSharedPointer<Community>> communities_;
|
std::map<QString, QSharedPointer<Community>> communities_;
|
||||||
|
|
||||||
|
|
|
@ -493,6 +493,7 @@ ChatPage::syncCompleted(const mtx::responses::Sync &response)
|
||||||
|
|
||||||
room_list_->sync(roomStates_, roomSettings_);
|
room_list_->sync(roomStates_, roomSettings_);
|
||||||
room_list_->syncInvites(response.rooms.invite);
|
room_list_->syncInvites(response.rooms.invite);
|
||||||
|
trackInvites(response.rooms.invite);
|
||||||
|
|
||||||
view_manager_->sync(response.rooms);
|
view_manager_->sync(response.rooms);
|
||||||
|
|
||||||
|
@ -549,6 +550,7 @@ ChatPage::initialSyncCompleted(const mtx::responses::Sync &response)
|
||||||
// Initialize room list.
|
// Initialize room list.
|
||||||
room_list_->setInitialRooms(roomSettings_, roomStates_);
|
room_list_->setInitialRooms(roomSettings_, roomStates_);
|
||||||
room_list_->syncInvites(response.rooms.invite);
|
room_list_->syncInvites(response.rooms.invite);
|
||||||
|
trackInvites(response.rooms.invite);
|
||||||
|
|
||||||
client_->setNextBatchToken(QString::fromStdString(response.next_batch));
|
client_->setNextBatchToken(QString::fromStdString(response.next_batch));
|
||||||
client_->sync();
|
client_->sync();
|
||||||
|
@ -687,7 +689,10 @@ ChatPage::loadStateFromCache()
|
||||||
|
|
||||||
// Initialize room list from the restored state and settings.
|
// Initialize room list from the restored state and settings.
|
||||||
room_list_->setInitialRooms(roomSettings_, roomStates_);
|
room_list_->setInitialRooms(roomSettings_, roomStates_);
|
||||||
room_list_->syncInvites(cache_->invites());
|
|
||||||
|
const auto invites = cache_->invites();
|
||||||
|
room_list_->syncInvites(invites);
|
||||||
|
trackInvites(invites);
|
||||||
|
|
||||||
// Check periodically if the timelines have been loaded.
|
// Check periodically if the timelines have been loaded.
|
||||||
consensusTimer_->start(CONSENSUS_TIMEOUT);
|
consensusTimer_->start(CONSENSUS_TIMEOUT);
|
||||||
|
@ -773,7 +778,9 @@ ChatPage::removeRoom(const QString &room_id)
|
||||||
cache_->unmount();
|
cache_->unmount();
|
||||||
cache_->deleteData();
|
cache_->deleteData();
|
||||||
}
|
}
|
||||||
|
|
||||||
room_list_->removeRoom(room_id, room_id == current_room_);
|
room_list_->removeRoom(room_id, room_id == current_room_);
|
||||||
|
roomInvites_.erase(room_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -789,6 +796,7 @@ ChatPage::removeInvite(const QString &room_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
room_list_->removeRoom(room_id, room_id == current_room_);
|
room_list_->removeRoom(room_id, room_id == current_room_);
|
||||||
|
roomInvites_.erase(room_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -854,6 +862,9 @@ ChatPage::removeLeftRooms(const std::map<std::string, mtx::responses::LeftRoom>
|
||||||
|
|
||||||
if (roomStates_.find(room_id) != roomStates_.end())
|
if (roomStates_.find(room_id) != roomStates_.end())
|
||||||
removeRoom(room_id);
|
removeRoom(room_id);
|
||||||
|
|
||||||
|
if (roomInvites_.find(room_id) != roomInvites_.end())
|
||||||
|
removeInvite(room_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -863,6 +874,9 @@ ChatPage::updateJoinedRooms(const std::map<std::string, mtx::responses::JoinedRo
|
||||||
for (auto it = rooms.cbegin(); it != rooms.cend(); ++it) {
|
for (auto it = rooms.cbegin(); it != rooms.cend(); ++it) {
|
||||||
const auto roomid = QString::fromStdString(it->first);
|
const auto roomid = QString::fromStdString(it->first);
|
||||||
|
|
||||||
|
if (roomInvites_.find(roomid) != roomInvites_.end())
|
||||||
|
removeInvite(roomid);
|
||||||
|
|
||||||
updateTypingUsers(roomid, it->second.ephemeral.typing);
|
updateTypingUsers(roomid, it->second.ephemeral.typing);
|
||||||
updateRoomNotificationCount(roomid,
|
updateRoomNotificationCount(roomid,
|
||||||
it->second.unread_notifications.notification_count);
|
it->second.unread_notifications.notification_count);
|
||||||
|
|
Loading…
Reference in a new issue