diff --git a/lib/pages/chat_members/chat_members.dart b/lib/pages/chat_members/chat_members.dart index c777d286e..09a5f72f7 100644 --- a/lib/pages/chat_members/chat_members.dart +++ b/lib/pages/chat_members/chat_members.dart @@ -1,7 +1,10 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:matrix/matrix.dart'; +import 'package:fluffychat/utils/stream_extension.dart'; import '../../widgets/matrix.dart'; import 'chat_members_view.dart'; @@ -20,6 +23,10 @@ class ChatMembersController extends State { final TextEditingController filterController = TextEditingController(); + // #Pangea + StreamSubscription? _subscription; + // Pangea# + void setFilter([_]) async { final filter = filterController.text.toLowerCase().trim(); @@ -50,7 +57,16 @@ class ChatMembersController extends State { final participants = await Matrix.of(context) .client .getRoomById(widget.roomId) - ?.requestParticipants(); + ?.requestParticipants( + // #Pangea + // without setting cache to true, each call to requestParticipants will + // result in a new entry in the roomState stream, because the member roomState is not + // stored in the database. This causes an infinite loop with the roomState listener. + [Membership.join, Membership.invite, Membership.knock], + false, + true, + // Pangea# + ); if (!mounted) return; @@ -71,8 +87,26 @@ class ChatMembersController extends State { void initState() { super.initState(); refreshMembers(); + // #Pangea + _subscription = Matrix.of(context) + .client + .onRoomState + .stream + .where((update) => update.roomId == widget.roomId) + .rateLimit(const Duration(seconds: 1)) + .listen((_) => refreshMembers()); + // Pangea# } + // #Pangea + @override + void dispose() { + _subscription?.cancel(); + filterController.dispose(); + super.dispose(); + } + // Pangea# + @override Widget build(BuildContext context) => ChatMembersView(this); } diff --git a/lib/pangea/activity_suggestions/activity_suggestions_area.dart b/lib/pangea/activity_suggestions/activity_suggestions_area.dart index 61fa8687e..99fb23138 100644 --- a/lib/pangea/activity_suggestions/activity_suggestions_area.dart +++ b/lib/pangea/activity_suggestions/activity_suggestions_area.dart @@ -61,19 +61,19 @@ class ActivitySuggestionsAreaState extends State { ); } - void _scrollToNextItem(AxisDirection direction) { - final currentOffset = _scrollController.offset; - final scrollAmount = _isColumnMode ? cardWidth : cardHeight; + // void _scrollToNextItem(AxisDirection direction) { + // final currentOffset = _scrollController.offset; + // final scrollAmount = _isColumnMode ? cardWidth : cardHeight; - _scrollController.animateTo( - (direction == AxisDirection.left - ? currentOffset - scrollAmount - : currentOffset + scrollAmount) - .clamp(0.0, _scrollController.position.maxScrollExtent), - duration: FluffyThemes.animationDuration, - curve: FluffyThemes.animationCurve, - ); - } + // _scrollController.animateTo( + // (direction == AxisDirection.left + // ? currentOffset - scrollAmount + // : currentOffset + scrollAmount) + // .clamp(0.0, _scrollController.position.maxScrollExtent), + // duration: FluffyThemes.animationDuration, + // curve: FluffyThemes.animationCurve, + // ); + // } Future _setActivityItems() async { final ActivityPlanRequest request = ActivityPlanRequest( diff --git a/lib/widgets/public_room_bottom_sheet.dart b/lib/widgets/public_room_bottom_sheet.dart index 94b213187..f354ddaab 100644 --- a/lib/widgets/public_room_bottom_sheet.dart +++ b/lib/widgets/public_room_bottom_sheet.dart @@ -107,7 +107,10 @@ class PublicRoomBottomSheetState extends State { // if (knock) { // return; // } - if (knock && !wasInRoom) return; + if (knock && !wasInRoom) { + Navigator.of(context).pop(); + return; + } // Pangea# if (result.error == null) { Navigator.of(context).pop(true);