Space Home Page

Add a space homepage with the ability to both create new room and add existing rooms to the space. This uses a tree model for the space hierarchy and will go to any number of levels. The user should only see the add options if they have appropriate permissions.

This MR also combines the create space and room pages and adds a lot of optional functionality for managing space children.

![image](/uploads/1764b0319241ff870dc39b18b39f5d51/image.png)
This commit is contained in:
James Graham
2023-09-28 17:36:23 +00:00
parent 08711fc927
commit ecdad9f965
24 changed files with 1486 additions and 80 deletions

View File

@@ -179,7 +179,11 @@ void RoomManager::openRoomForActiveConnection()
const auto room = qobject_cast<NeoChatRoom *>(Controller::instance().activeConnection()->room(roomId));
if (room) {
enterRoom(room);
if (room->isSpace()) {
enterSpaceHome(room);
} else {
enterRoom(room);
}
}
}
}
@@ -222,6 +226,34 @@ void RoomManager::openWindow(NeoChatRoom *room)
Q_EMIT openRoomInNewWindow(room);
}
void RoomManager::enterSpaceHome(NeoChatRoom *spaceRoom)
{
if (!spaceRoom->isSpace()) {
return;
}
// If replacing a normal room message timeline make sure any edit is cancelled.
if (m_currentRoom && !m_currentRoom->chatBoxEditId().isEmpty()) {
m_currentRoom->setChatBoxEditId({});
}
// Save the chatbar text for the current room if any before switching
if (m_currentRoom && m_chatDocumentHandler) {
if (m_chatDocumentHandler->document()) {
m_currentRoom->setSavedText(m_chatDocumentHandler->document()->textDocument()->toPlainText());
}
}
m_lastCurrentRoom = std::exchange(m_currentRoom, spaceRoom);
Q_EMIT currentRoomChanged();
if (!m_lastCurrentRoom) {
Q_EMIT pushSpaceHome(spaceRoom);
} else {
Q_EMIT replaceSpaceHome(m_currentRoom);
}
// Save last open room
m_lastRoomConfig.writeEntry(Controller::instance().activeConnection()->userId(), spaceRoom->id());
}
UriResolveResult RoomManager::visitUser(User *user, const QString &action)
{
if (action == "mention"_ls || action.isEmpty()) {