fixes for null check / disposed widget errors

pull/1384/head
ggurdin 1 year ago
parent c9e023e684
commit 4f1445d975

@ -416,7 +416,7 @@ class ChatController extends State<ChatPageWithRoom>
onInsert: onInsert,
);
// #Pangea
if (visibleEvents.length < 10) {
if (visibleEvents.length < 10 && timeline != null) {
int prevNumEvents = timeline!.events.length;
await requestHistory();
int numRequests = 0;

@ -130,19 +130,27 @@ class _SpaceViewState extends State<SpaceView> {
if (prevBatch != null) {
response.rooms.insertAll(0, _lastResponse[activeSpaceId]?.rooms ?? []);
}
// #Pangea
if (mounted) {
// Pangea#
setState(() {
_lastResponse[activeSpaceId] = response;
});
}
return _lastResponse[activeSpaceId]!;
} catch (e) {
// #Pangea
if (mounted) {
// Pangea#
setState(() {
error = e;
});
}
rethrow;
} finally {
// #Pangea
if (activeSpace != null) {
await setChatCount(
setChatCount(
activeSpace,
_lastResponse[activeSpaceId] ??
GetSpaceHierarchyResponse(
@ -150,12 +158,14 @@ class _SpaceViewState extends State<SpaceView> {
),
);
}
if (mounted) {
// Pangea#
setState(() {
loading = false;
});
}
}
}
void _onJoinSpaceChild(SpaceRoomsChunk spaceChild) async {
final client = Matrix.of(context).client;
@ -499,6 +509,7 @@ class _SpaceViewState extends State<SpaceView> {
}
bool includeSpaceChild(sc, matchingSpaceChildren) {
if (!mounted) return false;
final bool isAnalyticsRoom = sc.roomType == PangeaRoomTypes.analytics;
final bool isMember = [Membership.join, Membership.invite]
.contains(Matrix.of(context).client.getRoomById(sc.roomId)?.membership);

Loading…
Cancel
Save