Fix more members not being loaded in chat details

parent 1dce8eff
......@@ -43,26 +43,11 @@ class ChatSettingsBloc extends Bloc<ChatSettingsEvent, ChatSettingsState> {
@override
Stream<ChatSettingsState> mapEventToState(ChatSettingsEvent event) async* {
if (event is FetchMembers) {
final me = _room.members[_matrix.user.id] ??
// TODO: Fix fallback member being needed
Member.fromEvent(
MemberChangeEvent(
RoomEventArgs(
roomId: _room.id,
senderId: _matrix.user.id,
time: DateTime.now(),
),
content: MemberChange(
membership: _room.me.membership,
displayName: _matrix.user.name,
avatarUrl: _matrix.user.avatarUrl,
),
stateKey: _matrix.user.id.toString(),
),
);
yield MembersLoading(state.members);
if (_room.members.length < 6 &&
_room.members.length != _room.summary.joinedMembersCount) {
if ((!event.all && _room.members.length < 6) ||
(event.all &&
_room.members.length != _room.summary.joinedMembersCount)) {
final update = await _room.memberTimeline.load(
count: !event.all ? 6 : null,
);
......@@ -73,6 +58,7 @@ class ChatSettingsBloc extends Bloc<ChatSettingsEvent, ChatSettingsState> {
members = members.where((m) => m.membership is Joined).toList();
final me = _room.members[_matrix.user.id];
members.remove(me);
members.insert(0, me);
......
......@@ -31,7 +31,6 @@ import '../../widgets/chat_name.dart';
import '../../widgets/chat_member_tile.dart';
import '../../../../models/chat.dart';
import '../../../../models/chat_member.dart';
import '../../../../matrix.dart';
import '../../../../util/url.dart';
......@@ -274,10 +273,7 @@ class _MemberListState extends State<_MemberList> {
SizedBox(height: 4),
BlocBuilder<ChatSettingsBloc, ChatSettingsState>(
builder: (context, state) {
var members = <ChatMember>[];
if (state is MembersLoaded) {
members = state.members;
}
final members = state.members;
final isLoading = state is MembersLoading;
final allShown = members.length ==
......
......@@ -3,19 +3,24 @@ import 'package:equatable/equatable.dart';
import '../../../../models/chat_member.dart';
abstract class ChatSettingsState extends Equatable {
final List<ChatMember> members;
ChatSettingsState([List<ChatMember> members]) : members = members ?? [];
@override
List<Object> get props => [];
List<Object> get props => [members];
}
class ChatSettingsUninitialized extends ChatSettingsState {}
class MembersLoading extends ChatSettingsState {}
// TODO: Move Member stuff to seperate widget and bloc
class MembersLoaded extends ChatSettingsState {
final List<ChatMember> members;
class ChatSettingsUninitialized extends ChatSettingsState {
ChatSettingsUninitialized([List<ChatMember> members]) : super(members);
}
MembersLoaded(this.members);
class MembersLoading extends ChatSettingsState {
MembersLoading([List<ChatMember> members]) : super(members);
}
@override
List<Object> get props => [members];
class MembersLoaded extends ChatSettingsState {
MembersLoaded([List<ChatMember> members]) : super(members);
}
......@@ -337,8 +337,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: af6942c6b4eb2152a91a0c8bb50847b934d0be6e
resolved-ref: af6942c6b4eb2152a91a0c8bb50847b934d0be6e
ref: e1f4ab98d34270253b4ebafdf0f1443b76104d13
resolved-ref: e1f4ab98d34270253b4ebafdf0f1443b76104d13
url: "https://pattle.dev/pattle/library/matrix-dart-sdk.git"
source: git
version: "0.0.0"
......
......@@ -13,7 +13,7 @@ dependencies:
matrix_sdk:
git:
url: https://pattle.dev/pattle/library/matrix-dart-sdk.git
ref: af6942c6b4eb2152a91a0c8bb50847b934d0be6e
ref: e1f4ab98d34270253b4ebafdf0f1443b76104d13
async: ^2.3.0
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment