summary refs log tree commit diff
path: root/src/timeline/RoomlistModel.cpp
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2023-03-18 14:02:03 +0000
committerGitHub <noreply@github.com>2023-03-18 14:02:03 +0000
commit9ad3f3f4fb62082b129180f412d0b665760cfe96 (patch)
treeeed3119ddda7b48c3cd2e77a6cfa3674da8b07c6 /src/timeline/RoomlistModel.cpp
parentTranslated using Weblate (Turkish) (diff)
parentCheck isPreviewFetched property for hints (diff)
downloadnheko-9ad3f3f4fb62082b129180f412d0b665760cfe96.tar.xz
Merge pull request #1404 from LcsTen/dont-show-private-rooms-in-space
Don't show inaccessible private rooms in spaces
Diffstat (limited to 'src/timeline/RoomlistModel.cpp')
-rw-r--r--src/timeline/RoomlistModel.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/timeline/RoomlistModel.cpp b/src/timeline/RoomlistModel.cpp

index 455ea94f..12fee262 100644 --- a/src/timeline/RoomlistModel.cpp +++ b/src/timeline/RoomlistModel.cpp
@@ -222,7 +222,7 @@ RoomlistModel::data(const QModelIndex &index, int role) const case Roles::RoomName: return tr("No preview available"); case Roles::LastMessage: - return QString(); + return tr("This room is possibly inaccessible"); case Roles::Time: return QString(); case Roles::Timestamp: @@ -796,11 +796,13 @@ RoomlistModel::setCurrentRoom(const QString &roomid) p.roomName_ = QString::fromStdString(i->name); p.roomTopic_ = QString::fromStdString(i->topic); p.roomAvatarUrl_ = QString::fromStdString(i->avatar_url); + p.isFetched_ = true; currentRoomPreview_ = std::move(p); nhlog::ui()->debug("Switched to (preview): {}", currentRoomPreview_->roomid_.toStdString()); } else { p.roomid_ = roomid; + p.isFetched_ = false; currentRoomPreview_ = p; nhlog::ui()->debug("Switched to (empty): {}", currentRoomPreview_->roomid_.toStdString()); @@ -1100,6 +1102,15 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons .toBool(); } + // If it is a preview but it can't be fetched, it is probably an inaccessible private room. + // Hide it if the user isn't an admin. + auto index = sourceModel()->index(sourceRow, 0); + if (sourceModel()->data(index, RoomlistModel::IsPreview).toBool() && + !sourceModel()->data(index, RoomlistModel::IsPreviewFetched).toBool() && + !Permissions(filterStr).canChange(qml_mtx_events::SpaceChild)) { + return false; + } + return true; } else { return true;