Refactor room leaving
The old code has a small bug where the room would not be left in certain conditions.
This commit is contained in:
committed by
Carl Schwan
parent
21bd5fa94e
commit
ecc639fb0a
@@ -28,6 +28,17 @@ Kirigami.ScrollablePage {
|
|||||||
|
|
||||||
title: currentRoom.displayName
|
title: currentRoom.displayName
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: RoomManager
|
||||||
|
function onCurrentRoomChanged() {
|
||||||
|
if(!RoomManager.currentRoom) {
|
||||||
|
if(pageStack.lastItem == page) {
|
||||||
|
pageStack.pop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
signal switchRoomUp()
|
signal switchRoomUp()
|
||||||
signal switchRoomDown()
|
signal switchRoomDown()
|
||||||
|
|
||||||
|
|||||||
@@ -215,18 +215,14 @@ void RoomManager::reset()
|
|||||||
|
|
||||||
void RoomManager::leaveRoom(NeoChatRoom *room)
|
void RoomManager::leaveRoom(NeoChatRoom *room)
|
||||||
{
|
{
|
||||||
// close the room and open the last open room if it exist
|
if(m_lastCurrentRoom && room->id() == m_lastCurrentRoom->id()) {
|
||||||
// other open welcome page.
|
m_lastCurrentRoom = nullptr;
|
||||||
|
}
|
||||||
if (m_currentRoom && m_currentRoom->id() == room->id()) {
|
if (m_currentRoom && m_currentRoom->id() == room->id()) {
|
||||||
if (!m_lastCurrentRoom) {
|
|
||||||
Q_EMIT pushWelcomePage();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_currentRoom = m_lastCurrentRoom;
|
m_currentRoom = m_lastCurrentRoom;
|
||||||
m_lastCurrentRoom = nullptr;
|
m_lastCurrentRoom = nullptr;
|
||||||
|
|
||||||
Q_EMIT currentRoomChanged();
|
Q_EMIT currentRoomChanged();
|
||||||
Q_EMIT replaceRoom(m_lastCurrentRoom, QString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
room->forget();
|
room->forget();
|
||||||
|
|||||||
Reference in New Issue
Block a user