Fix opening room in seperate window and unify leaving room code

This commit is contained in:
Carl Schwan
2021-04-28 15:06:57 +02:00
parent b7d98fc6d9
commit f30b17bf73
5 changed files with 27 additions and 20 deletions

View File

@@ -107,14 +107,6 @@ void RoomManager::enterRoom(NeoChatRoom *room)
void RoomManager::getBack()
{
Q_ASSERT(m_currentRoom);
if (!m_lastCurrentRoom) {
Q_EMIT pushWelcomePage();
return;
}
Q_EMIT replaceRoom(m_lastCurrentRoom, QString());
}
void RoomManager::openWindow(NeoChatRoom *room)
@@ -195,3 +187,22 @@ void RoomManager::reset()
m_lastCurrentRoom = nullptr;
Q_EMIT currentRoomChanged();
}
void RoomManager::leaveRoom(NeoChatRoom *room)
{
// close the room and open the last open room if it exist
// other open welcome page.
if (m_currentRoom && m_currentRoom->id() == room->id()) {
if (!m_lastCurrentRoom) {
Q_EMIT pushWelcomePage();
return;
}
m_currentRoom = m_lastCurrentRoom;
m_lastCurrentRoom = nullptr;
Q_EMIT currentRoomChanged();
Q_EMIT replaceRoom(m_lastCurrentRoom, QString());
}
room->forget();
}

View File

@@ -43,6 +43,9 @@ public:
Q_INVOKABLE void openWindow(NeoChatRoom *room);
/// Leave the room and close it if it is open.
Q_INVOKABLE void leaveRoom(NeoChatRoom *room);
/// Getter for the currentRoom property.
NeoChatRoom *currentRoom() const;