reload space hierarchy on invite update (#3949)

pull/2245/head
ggurdin 2 months ago committed by GitHub
parent 96b4142b34
commit 141d3c5175
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -759,8 +759,11 @@ class CourseChatsController extends State<CourseChats> {
/// space so that the view can be auto-reloaded in the room subscription /// space so that the view can be auto-reloaded in the room subscription
bool _hasHierarchyUpdate(SyncUpdate update) { bool _hasHierarchyUpdate(SyncUpdate update) {
final joinUpdate = update.rooms?.join; final joinUpdate = update.rooms?.join;
final inviteUpdate = update.rooms?.invite;
final leaveUpdate = update.rooms?.leave; final leaveUpdate = update.rooms?.leave;
if (joinUpdate == null && leaveUpdate == null) return false; if (joinUpdate == null && leaveUpdate == null && inviteUpdate == null) {
return false;
}
final joinedRooms = joinUpdate?.entries final joinedRooms = joinUpdate?.entries
.where( .where(
@ -769,6 +772,13 @@ class CourseChatsController extends State<CourseChats> {
.map((e) => e.value.timeline?.events) .map((e) => e.value.timeline?.events)
.whereType<List<MatrixEvent>>(); .whereType<List<MatrixEvent>>();
final invitedRooms = inviteUpdate?.entries
.where(
(e) => childrenIds.contains(e.key),
)
.map((e) => e.value.inviteState)
.whereType<List<StrippedStateEvent>>();
final leftRooms = leaveUpdate?.entries final leftRooms = leaveUpdate?.entries
.where( .where(
(e) => childrenIds.contains(e.key), (e) => childrenIds.contains(e.key),
@ -794,7 +804,7 @@ class CourseChatsController extends State<CourseChats> {
) ?? ) ??
false; false;
if (hasJoinedRoom || hasLeftRoom) { if (hasJoinedRoom || hasLeftRoom || (invitedRooms?.isNotEmpty ?? false)) {
return true; return true;
} }

@ -126,6 +126,10 @@ class CourseActivityRepo {
); );
final mediaIds = activityToMediaId.keys.whereType<String>().toList(); final mediaIds = activityToMediaId.keys.whereType<String>().toList();
if (mediaIds.isEmpty) {
return {};
}
final where = { final where = {
"id": {"in": mediaIds.join(",")}, "id": {"in": mediaIds.join(",")},
}; };

@ -124,6 +124,13 @@ class PayloadClient {
final endpoint = final endpoint =
'$basePath/$collection${queryParams.isNotEmpty ? '?${queryStringify(queryParams)}' : ''}'; '$basePath/$collection${queryParams.isNotEmpty ? '?${queryStringify(queryParams)}' : ''}';
final response = await get(endpoint); final response = await get(endpoint);
if (response.statusCode != 200) {
throw Exception(
'Failed to load documents: ${response.statusCode} ${response.body}',
);
}
final json = jsonDecode(response.body) as Map<String, dynamic>; final json = jsonDecode(response.body) as Map<String, dynamic>;
return PayloadPaginatedResponse.fromJson(json, fromJson); return PayloadPaginatedResponse.fromJson(json, fromJson);

Loading…
Cancel
Save