mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2025-01-08 08:12:37 +01:00
fix: Don't make space filter scrolling lag
This commit is contained in:
parent
91b29f7b70
commit
45c9321c70
@ -51,10 +51,14 @@ class ChatListController extends State<ChatList> {
|
|||||||
|
|
||||||
String _activeSpaceId;
|
String _activeSpaceId;
|
||||||
String get activeSpaceId => _activeSpaceId;
|
String get activeSpaceId => _activeSpaceId;
|
||||||
|
final _roomCheckCache = <String, bool>{};
|
||||||
|
|
||||||
void setActiveSpaceId(BuildContext context, String spaceId) {
|
void setActiveSpaceId(BuildContext context, String spaceId) {
|
||||||
Scaffold.of(context).openEndDrawer();
|
Scaffold.of(context).openEndDrawer();
|
||||||
setState(() => _activeSpaceId = spaceId);
|
setState(() {
|
||||||
|
_activeSpaceId = spaceId;
|
||||||
|
_roomCheckCache.clear();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void editSpace(BuildContext context, String spaceId) async {
|
void editSpace(BuildContext context, String spaceId) async {
|
||||||
@ -189,26 +193,35 @@ class ChatListController extends State<ChatList> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool roomCheck(Room room) {
|
bool roomCheck(Room room) {
|
||||||
if (room.isSpace && room.membership == Membership.join) return false;
|
if (room.isSpace && room.membership == Membership.join) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (activeSpaceId != null) {
|
if (activeSpaceId != null) {
|
||||||
|
if (_roomCheckCache.containsKey(room.id)) {
|
||||||
|
return _roomCheckCache[room.id];
|
||||||
|
}
|
||||||
|
final retCache = (b) {
|
||||||
|
_roomCheckCache[room.id] = b;
|
||||||
|
return b;
|
||||||
|
};
|
||||||
final space = Matrix.of(context).client.getRoomById(activeSpaceId);
|
final space = Matrix.of(context).client.getRoomById(activeSpaceId);
|
||||||
if (space.spaceChildren?.any((child) => child.roomId == room.id) ??
|
if (space.spaceChildren?.any((child) => child.roomId == room.id) ??
|
||||||
false) {
|
false) {
|
||||||
return true;
|
return retCache(true);
|
||||||
}
|
}
|
||||||
if (room.spaceParents?.any((parent) => parent.roomId == activeSpaceId) ??
|
if (room.spaceParents?.any((parent) => parent.roomId == activeSpaceId) ??
|
||||||
false) {
|
false) {
|
||||||
return true;
|
return retCache(true);
|
||||||
}
|
}
|
||||||
if (room.isDirectChat &&
|
if (room.isDirectChat &&
|
||||||
room.summary?.mHeroes != null &&
|
room.summary?.mHeroes != null &&
|
||||||
room.summary.mHeroes.any((userId) {
|
room.summary.mHeroes.any((userId) {
|
||||||
final user = space.getState(EventTypes.RoomMember, userId)?.asUser;
|
final user = space.getState(EventTypes.RoomMember, userId)?.asUser;
|
||||||
return user != null && user.membership == Membership.join;
|
return retCache(user != null && user.membership == Membership.join);
|
||||||
})) {
|
})) {
|
||||||
return true;
|
return retCache(true);
|
||||||
}
|
}
|
||||||
return false;
|
return retCache(false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -382,6 +395,7 @@ class ChatListController extends State<ChatList> {
|
|||||||
(space.summary?.mJoinedMemberCount ?? 0);
|
(space.summary?.mJoinedMemberCount ?? 0);
|
||||||
if (localMembers < actualMembersCount) {
|
if (localMembers < actualMembersCount) {
|
||||||
await space.requestParticipants();
|
await space.requestParticipants();
|
||||||
|
_roomCheckCache.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user