Fix opening room in seperate window and unify leaving room code
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user