chore: refresh chat participant list page on participants list change (#2167)
This commit is contained in:
parent
bd1c6c7437
commit
6b66affbc0
3 changed files with 51 additions and 14 deletions
|
|
@ -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<ChatMembersPage> {
|
|||
|
||||
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<ChatMembersPage> {
|
|||
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<ChatMembersPage> {
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,19 +61,19 @@ class ActivitySuggestionsAreaState extends State<ActivitySuggestionsArea> {
|
|||
);
|
||||
}
|
||||
|
||||
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<void> _setActivityItems() async {
|
||||
final ActivityPlanRequest request = ActivityPlanRequest(
|
||||
|
|
|
|||
|
|
@ -107,7 +107,10 @@ class PublicRoomBottomSheetState extends State<PublicRoomBottomSheet> {
|
|||
// if (knock) {
|
||||
// return;
|
||||
// }
|
||||
if (knock && !wasInRoom) return;
|
||||
if (knock && !wasInRoom) {
|
||||
Navigator.of(context).pop();
|
||||
return;
|
||||
}
|
||||
// Pangea#
|
||||
if (result.error == null) {
|
||||
Navigator.of(context).pop<bool>(true);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue