Minor fixes

This commit is contained in:
Christian Pauly 2020-06-27 13:24:19 +02:00
parent e5cfacf4c1
commit 8def2fb81f
3 changed files with 39 additions and 16 deletions

View File

@ -15,18 +15,33 @@ class PublicRoomListItem extends StatelessWidget {
const PublicRoomListItem(this.publicRoomEntry, {Key key}) : super(key: key);
void joinAction(BuildContext context) async {
final success = await SimpleDialogs(context).tryRequestWithLoadingDialog(
Matrix.of(context).client.api.joinRoom(publicRoomEntry.roomId));
final success = await SimpleDialogs(context)
.tryRequestWithLoadingDialog(_joinRoomAndWait(context));
if (success != false) {
await Navigator.of(context).push(
AppRoute.defaultRoute(
context,
ChatView(publicRoomEntry.roomId),
ChatView(success),
),
);
}
}
Future<String> _joinRoomAndWait(BuildContext context) async {
final roomId = await Matrix.of(context)
.client
.api
.joinRoomOrAlias(publicRoomEntry.roomId);
if (Matrix.of(context).client.getRoomById(roomId) == null) {
await Matrix.of(context)
.client
.onRoomUpdate
.stream
.firstWhere((r) => r.id == roomId);
}
return roomId;
}
@override
Widget build(BuildContext context) {
final hasTopic =
@ -43,8 +58,10 @@ class PublicRoomListItem extends StatelessWidget {
subtitle: Text(
hasTopic
? publicRoomEntry.topic
: L10n.of(context).countParticipants(
publicRoomEntry.numJoinedMembers?.toString() ?? '0'),
: publicRoomEntry.numJoinedMembers == null
? L10n.of(context).joinRoom
: L10n.of(context).countParticipants(
publicRoomEntry.numJoinedMembers.toString()),
maxLines: 1,
),
onTap: () => joinAction(context),

View File

@ -463,6 +463,8 @@ class L10n extends MatrixLocalizations {
args: [username],
);
String get joinRoom => Intl.message('Join room');
String get keysCached => Intl.message("Keys are cached", name: "keysCached");
String get keysMissing =>

View File

@ -390,17 +390,21 @@ class _ChatListState extends State<ChatList> {
a.lastEvent.originServerTs));
return ListView.separated(
controller: _scrollController,
separatorBuilder:
(BuildContext context, int i) =>
i == totalCount - publicRoomsCount
? Material(
elevation: 2,
child: ListTile(
title: Text(L10n.of(context)
.publicRooms),
),
)
: Container(),
separatorBuilder: (BuildContext context,
int i) =>
i == totalCount - publicRoomsCount
? ListTile(
title: Text(
L10n.of(context).publicRooms +
':',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Theme.of(context)
.primaryColor,
),
),
)
: Container(),
itemCount: totalCount + 1,
itemBuilder: (BuildContext context, int i) {
if (i == 0) {