fix: if membership gets out of sync on join space with code, get true value from matrix (#2188)

This commit is contained in:
ggurdin 2025-03-20 16:09:27 -04:00 committed by GitHub
parent 4c4bd781b4
commit 5420cb840e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:collection/collection.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:get_storage/get_storage.dart';
import 'package:go_router/go_router.dart';
@ -170,10 +171,22 @@ class ClassController extends BaseController {
GoogleAnalytics.joinClass(classCode);
if (room.client.getRoomById(room.id)?.membership != Membership.join) {
if (room.membership != Membership.join) {
await room.client.waitForRoomInSync(room.id, join: true);
}
// Sometimes, the invite event comes through after the join event and
// replaces it, so membership gets out of sync. In this case,
// load the true value from the server.
// Related github issue: https://github.com/pangeachat/client/issues/2098
if (room.membership !=
room
.getParticipants()
.firstWhereOrNull((u) => u.id == room?.client.userID)
?.membership) {
await room.requestParticipants();
}
context.push("/rooms/${room.id}/details");
} catch (e, s) {
ErrorHandler.logError(