mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-26 21:18:48 +03:00
Hide spaces by default, unless they are in the current space filter
This commit is contained in:
parent
0ec7be3090
commit
f349b0cce0
4 changed files with 59 additions and 7 deletions
|
@ -167,6 +167,25 @@ CommunitiesModel::sync(const mtx::responses::Rooms &rooms)
|
||||||
mtx::events::AccountDataEvent<mtx::events::account_data::Tags>>(e)) {
|
mtx::events::AccountDataEvent<mtx::events::account_data::Tags>>(e)) {
|
||||||
tagsUpdated = true;
|
tagsUpdated = true;
|
||||||
}
|
}
|
||||||
|
for (const auto &e : room.state.events)
|
||||||
|
if (std::holds_alternative<
|
||||||
|
mtx::events::StateEvent<mtx::events::state::space::Child>>(e) ||
|
||||||
|
std::holds_alternative<
|
||||||
|
mtx::events::StateEvent<mtx::events::state::space::Parent>>(e)) {
|
||||||
|
tagsUpdated = true;
|
||||||
|
}
|
||||||
|
for (const auto &e : room.timeline.events)
|
||||||
|
if (std::holds_alternative<
|
||||||
|
mtx::events::StateEvent<mtx::events::state::space::Child>>(e) ||
|
||||||
|
std::holds_alternative<
|
||||||
|
mtx::events::StateEvent<mtx::events::state::space::Parent>>(e)) {
|
||||||
|
tagsUpdated = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto &[roomid, room] : rooms.leave) {
|
||||||
|
(void)room;
|
||||||
|
if (spaceOrder_.contains(QString::fromStdString(roomid)))
|
||||||
|
tagsUpdated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagsUpdated)
|
if (tagsUpdated)
|
||||||
|
|
|
@ -85,8 +85,9 @@ RoomlistModel::data(const QModelIndex &index, int role) const
|
||||||
case Roles::NotificationCount:
|
case Roles::NotificationCount:
|
||||||
return room->notificationCount();
|
return room->notificationCount();
|
||||||
case Roles::IsInvite:
|
case Roles::IsInvite:
|
||||||
case Roles::IsSpace:
|
|
||||||
return false;
|
return false;
|
||||||
|
case Roles::IsSpace:
|
||||||
|
return room->isSpace();
|
||||||
case Roles::Tags: {
|
case Roles::Tags: {
|
||||||
auto info = cache::singleRoomInfo(roomid.toStdString());
|
auto info = cache::singleRoomInfo(roomid.toStdString());
|
||||||
QStringList list;
|
QStringList list;
|
||||||
|
@ -429,7 +430,9 @@ enum NotificationImportance : short
|
||||||
AllEventsRead = 0,
|
AllEventsRead = 0,
|
||||||
NewMessage = 1,
|
NewMessage = 1,
|
||||||
NewMentions = 2,
|
NewMentions = 2,
|
||||||
Invite = 3
|
Invite = 3,
|
||||||
|
SubSpace = 4,
|
||||||
|
CurrentSpace = 5,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +442,13 @@ FilteredRoomlistModel::calculateImportance(const QModelIndex &idx) const
|
||||||
// Returns the degree of importance of the unread messages in the room.
|
// Returns the degree of importance of the unread messages in the room.
|
||||||
// If sorting by importance is disabled in settings, this only ever
|
// If sorting by importance is disabled in settings, this only ever
|
||||||
// returns ImportanceDisabled or Invite
|
// returns ImportanceDisabled or Invite
|
||||||
if (sourceModel()->data(idx, RoomlistModel::IsInvite).toBool()) {
|
if (sourceModel()->data(idx, RoomlistModel::IsSpace).toBool()) {
|
||||||
|
if (filterType == FilterBy::Space &&
|
||||||
|
filterStr == sourceModel()->data(idx, RoomlistModel::RoomId).toString())
|
||||||
|
return CurrentSpace;
|
||||||
|
else
|
||||||
|
return SubSpace;
|
||||||
|
} else if (sourceModel()->data(idx, RoomlistModel::IsInvite).toBool()) {
|
||||||
return Invite;
|
return Invite;
|
||||||
} else if (!this->sortByImportance) {
|
} else if (!this->sortByImportance) {
|
||||||
return ImportanceDisabled;
|
return ImportanceDisabled;
|
||||||
|
@ -539,6 +548,10 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
|
||||||
for (const auto &t : parents)
|
for (const auto &t : parents)
|
||||||
if (hiddenSpaces.contains(t))
|
if (hiddenSpaces.contains(t))
|
||||||
return false;
|
return false;
|
||||||
|
} else if (sourceModel()
|
||||||
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
|
||||||
|
.toBool()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -561,6 +574,10 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
|
||||||
for (const auto &t : parents)
|
for (const auto &t : parents)
|
||||||
if (hiddenSpaces.contains(t))
|
if (hiddenSpaces.contains(t))
|
||||||
return false;
|
return false;
|
||||||
|
} else if (sourceModel()
|
||||||
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
|
||||||
|
.toBool()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else if (filterType == FilterBy::Space) {
|
} else if (filterType == FilterBy::Space) {
|
||||||
|
@ -572,7 +589,11 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
|
||||||
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags)
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::Tags)
|
||||||
.toStringList();
|
.toStringList();
|
||||||
|
|
||||||
if (!parents.contains(filterStr))
|
if (filterStr == sourceModel()
|
||||||
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::RoomId)
|
||||||
|
.toString())
|
||||||
|
return true;
|
||||||
|
else if (!parents.contains(filterStr))
|
||||||
return false;
|
return false;
|
||||||
else if (!hiddenTags.empty()) {
|
else if (!hiddenTags.empty()) {
|
||||||
for (const auto &t : tags)
|
for (const auto &t : tags)
|
||||||
|
@ -582,6 +603,11 @@ FilteredRoomlistModel::filterAcceptsRow(int sourceRow, const QModelIndex &) cons
|
||||||
for (const auto &t : parents)
|
for (const auto &t : parents)
|
||||||
if (hiddenSpaces.contains(t))
|
if (hiddenSpaces.contains(t))
|
||||||
return false;
|
return false;
|
||||||
|
} else if (sourceModel()
|
||||||
|
->data(sourceModel()->index(sourceRow, 0), RoomlistModel::IsSpace)
|
||||||
|
.toBool() &&
|
||||||
|
!parents.contains(filterStr)) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -320,6 +320,10 @@ TimelineModel::TimelineModel(TimelineViewManager *manager, QString room_id, QObj
|
||||||
{
|
{
|
||||||
lastMessage_.timestamp = 0;
|
lastMessage_.timestamp = 0;
|
||||||
|
|
||||||
|
if (auto create =
|
||||||
|
cache::client()->getStateEvent<mtx::events::state::Create>(room_id.toStdString()))
|
||||||
|
this->isSpace_ = create->content.type == mtx::events::state::room_type::space;
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
this,
|
this,
|
||||||
&TimelineModel::redactionFailed,
|
&TimelineModel::redactionFailed,
|
||||||
|
|
|
@ -161,6 +161,7 @@ class TimelineModel : public QAbstractListModel
|
||||||
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
|
Q_PROPERTY(QString roomName READ roomName NOTIFY roomNameChanged)
|
||||||
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged)
|
Q_PROPERTY(QString roomAvatarUrl READ roomAvatarUrl NOTIFY roomAvatarUrlChanged)
|
||||||
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
|
Q_PROPERTY(QString roomTopic READ roomTopic NOTIFY roomTopicChanged)
|
||||||
|
Q_PROPERTY(bool isSpace READ isSpace CONSTANT)
|
||||||
Q_PROPERTY(InputBar *input READ input CONSTANT)
|
Q_PROPERTY(InputBar *input READ input CONSTANT)
|
||||||
Q_PROPERTY(Permissions *permissions READ permissions NOTIFY permissionsChanged)
|
Q_PROPERTY(Permissions *permissions READ permissions NOTIFY permissionsChanged)
|
||||||
|
|
||||||
|
@ -262,6 +263,7 @@ public:
|
||||||
RelatedInfo relatedInfo(QString id);
|
RelatedInfo relatedInfo(QString id);
|
||||||
|
|
||||||
DescInfo lastMessage() const { return lastMessage_; }
|
DescInfo lastMessage() const { return lastMessage_; }
|
||||||
|
bool isSpace() const { return isSpace_; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setCurrentIndex(int index);
|
void setCurrentIndex(int index);
|
||||||
|
@ -366,9 +368,6 @@ private:
|
||||||
|
|
||||||
QString room_id_;
|
QString room_id_;
|
||||||
|
|
||||||
bool decryptDescription = true;
|
|
||||||
bool m_paginationInProgress = false;
|
|
||||||
|
|
||||||
QString currentId, currentReadId;
|
QString currentId, currentReadId;
|
||||||
QString reply_, edit_;
|
QString reply_, edit_;
|
||||||
QString textBeforeEdit, replyBeforeEdit;
|
QString textBeforeEdit, replyBeforeEdit;
|
||||||
|
@ -388,6 +387,10 @@ private:
|
||||||
friend struct SendMessageVisitor;
|
friend struct SendMessageVisitor;
|
||||||
|
|
||||||
int notification_count = 0, highlight_count = 0;
|
int notification_count = 0, highlight_count = 0;
|
||||||
|
|
||||||
|
bool decryptDescription = true;
|
||||||
|
bool m_paginationInProgress = false;
|
||||||
|
bool isSpace_ = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
|
|
Loading…
Reference in a new issue