reload space hierarchy on invite update (#3949)
This commit is contained in:
parent
96b4142b34
commit
141d3c5175
3 changed files with 23 additions and 2 deletions
|
|
@ -759,8 +759,11 @@ class CourseChatsController extends State<CourseChats> {
|
|||
/// space so that the view can be auto-reloaded in the room subscription
|
||||
bool _hasHierarchyUpdate(SyncUpdate update) {
|
||||
final joinUpdate = update.rooms?.join;
|
||||
final inviteUpdate = update.rooms?.invite;
|
||||
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
|
||||
.where(
|
||||
|
|
@ -769,6 +772,13 @@ class CourseChatsController extends State<CourseChats> {
|
|||
.map((e) => e.value.timeline?.events)
|
||||
.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
|
||||
.where(
|
||||
(e) => childrenIds.contains(e.key),
|
||||
|
|
@ -794,7 +804,7 @@ class CourseChatsController extends State<CourseChats> {
|
|||
) ??
|
||||
false;
|
||||
|
||||
if (hasJoinedRoom || hasLeftRoom) {
|
||||
if (hasJoinedRoom || hasLeftRoom || (invitedRooms?.isNotEmpty ?? false)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,10 @@ class CourseActivityRepo {
|
|||
);
|
||||
|
||||
final mediaIds = activityToMediaId.keys.whereType<String>().toList();
|
||||
if (mediaIds.isEmpty) {
|
||||
return {};
|
||||
}
|
||||
|
||||
final where = {
|
||||
"id": {"in": mediaIds.join(",")},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -124,6 +124,13 @@ class PayloadClient {
|
|||
final endpoint =
|
||||
'$basePath/$collection${queryParams.isNotEmpty ? '?${queryStringify(queryParams)}' : ''}';
|
||||
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>;
|
||||
|
||||
return PayloadPaginatedResponse.fromJson(json, fromJson);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue