chore: Update Matrix SDK and refactor

This commit is contained in:
Krille 2023-01-20 16:59:50 +01:00
parent ce889e2c23
commit 972df73dd9
17 changed files with 91 additions and 50 deletions

View File

@ -42,7 +42,7 @@ class ArchiveController extends State<Archive> {
context: context,
future: () async {
while (archive.isNotEmpty) {
Logs().v('Forget room ${archive.last.displayname}');
Logs().v('Forget room ${archive.last.getLocalizedDisplayname()}');
await archive.last.forget();
archive.removeLast();
}

View File

@ -134,15 +134,6 @@ class ChatController extends State<Chat> {
bool showEmojiPicker = false;
bool get isLeftDMRoom {
final room = this.room;
final userId = room?.directChatMatrixID;
if (room == null || userId == null) return false;
return room.isDirectChat &&
room.unsafeGetUserFromMemoryOrFallback(userId).membership ==
Membership.leave;
}
void recreateChat() async {
final room = this.room;
final userId = room?.directChatMatrixID;

View File

@ -47,7 +47,9 @@ class ChatAppBarTitle extends StatelessWidget {
tag: 'content_banner',
child: Avatar(
mxContent: room.avatar,
name: room.displayname,
name: room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
size: 32,
),
),

View File

@ -291,7 +291,8 @@ class ChatView extends StatelessWidget {
Brightness.light
? Colors.white
: Colors.black,
child: controller.isLeftDMRoom
child: controller.room?.isAbandonedDMRoom ==
true
? Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,

View File

@ -196,7 +196,7 @@ class InputBar extends StatelessWidget {
ret.add({
'type': 'room',
'mxid': (r.canonicalAlias.isNotEmpty) ? r.canonicalAlias : r.id,
'displayname': r.displayname,
'displayname': r.getLocalizedDisplayname(),
'avatar_url': r.avatar?.toString(),
});
}

View File

@ -18,6 +18,7 @@ import 'package:fluffychat/pages/chat_list/chat_list_view.dart';
import 'package:fluffychat/utils/famedlysdk_store.dart';
import 'package:fluffychat/utils/localized_exception_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import '../../../utils/account_bundles.dart';
import '../../utils/matrix_sdk_extensions/matrix_file_extension.dart';
@ -508,7 +509,8 @@ class ChatListController extends State<ChatList>
.map(
(space) => AlertDialogAction(
key: space.id,
label: space.displayname,
label: space
.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
),
)
.toList());

View File

@ -11,6 +11,7 @@ import 'package:fluffychat/pages/chat_list/space_view.dart';
import 'package:fluffychat/pages/chat_list/stories_header.dart';
import 'package:fluffychat/utils/adaptive_bottom_sheet.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/client_stories_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/profile_bottom_sheet.dart';
@ -205,8 +206,11 @@ class ChatListViewBody extends StatelessWidget {
);
}
i--;
if (!rooms[i].displayname.toLowerCase().contains(
controller.searchController.text.toLowerCase())) {
if (!rooms[i]
.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!))
.toLowerCase()
.contains(
controller.searchController.text.toLowerCase())) {
return Container();
}
return ChatListItem(

View File

@ -124,6 +124,9 @@ class ChatListItem extends StatelessWidget {
? 20.0
: 14.0
: 0.0;
final displayname = room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
);
return Material(
color: selected
? Theme.of(context).colorScheme.primaryContainer
@ -144,14 +147,14 @@ class ChatListItem extends StatelessWidget {
)
: Avatar(
mxContent: room.avatar,
name: room.displayname,
name: displayname,
onTap: onLongPress,
),
title: Row(
children: <Widget>[
Expanded(
child: Text(
room.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
displayname,
maxLines: 1,
overflow: TextOverflow.ellipsis,
softWrap: false,

View File

@ -10,6 +10,7 @@ import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/chat_list/navi_rail_item.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/unread_rooms_badge.dart';
import '../../widgets/matrix.dart';
@ -140,13 +141,16 @@ class ChatListView extends StatelessWidget {
controller.activeFilter == ActiveFilter.spaces &&
rootSpaces[i].id == controller.activeSpaceId;
return NaviRailItem(
toolTip: rootSpaces[i].displayname,
toolTip: rootSpaces[i].getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!)),
isSelected: isSelected,
onTap: () =>
controller.setActiveSpace(rootSpaces[i].id),
icon: Avatar(
mxContent: rootSpaces[i].avatar,
name: rootSpaces[i].displayname,
name: rootSpaces[i].getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
size: 32,
fontSize: 12,
),

View File

@ -10,6 +10,7 @@ import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
import 'package:fluffychat/pages/chat_list/search_title.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/widgets/avatar.dart';
import '../../utils/localized_exception_extension.dart';
import '../../widgets/matrix.dart';
@ -85,7 +86,10 @@ class _SpaceViewState extends State<SpaceView> {
activeSpaceId == null ? null : client.getRoomById(activeSpaceId);
final action = await showModalActionSheet<SpaceChildContextAction>(
context: context,
title: spaceChild?.name ?? room?.displayname,
title: spaceChild?.name ??
room?.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
message: spaceChild?.topic ?? room?.topic,
actions: [
if (room == null)
@ -148,25 +152,31 @@ class _SpaceViewState extends State<SpaceView> {
return ListView.builder(
itemCount: rootSpaces.length,
controller: widget.scrollController,
itemBuilder: (context, i) => Material(
color: Theme.of(context).backgroundColor,
child: ListTile(
leading: Avatar(
mxContent: rootSpaces[i].avatar,
name: rootSpaces[i].displayname,
itemBuilder: (context, i) {
final rootSpace = rootSpaces[i];
final displayname = rootSpace.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
);
return Material(
color: Theme.of(context).backgroundColor,
child: ListTile(
leading: Avatar(
mxContent: rootSpace.avatar,
name: displayname,
),
title: Text(
displayname,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(L10n.of(context)!
.numChats(rootSpace.spaceChildren.length.toString())),
onTap: () => widget.controller.setActiveSpace(rootSpace.id),
onLongPress: () => _onSpaceChildContextMenu(null, rootSpace),
trailing: const Icon(Icons.chevron_right_outlined),
),
title: Text(
rootSpaces[i].displayname,
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
subtitle: Text(L10n.of(context)!
.numChats(rootSpaces[i].spaceChildren.length.toString())),
onTap: () => widget.controller.setActiveSpace(rootSpaces[i].id),
onLongPress: () => _onSpaceChildContextMenu(null, rootSpaces[i]),
trailing: const Icon(Icons.chevron_right_outlined),
),
),
);
},
);
}
return FutureBuilder<GetSpaceHierarchyResponse>(
@ -218,7 +228,9 @@ class _SpaceViewState extends State<SpaceView> {
),
title: Text(parentSpace == null
? L10n.of(context)!.allSpaces
: parentSpace.displayname),
: parentSpace.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
)),
trailing: IconButton(
icon: snapshot.connectionState != ConnectionState.done
? const CircularProgressIndicator.adaptive()

View File

@ -30,6 +30,7 @@ import 'package:matrix/matrix.dart';
import 'package:vibration/vibration.dart';
import 'package:wakelock/wakelock.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:fluffychat/widgets/avatar.dart';
import 'pip/pip_view.dart';
@ -129,7 +130,9 @@ class Calling extends StatefulWidget {
class MyCallingPage extends State<Calling> {
Room? get room => call.room;
String get displayName => call.displayName ?? '';
String get displayName => call.room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
);
String get callId => widget.callId;
@ -464,7 +467,9 @@ class MyCallingPage extends State<Calling> {
if (call.localHold || call.remoteOnHold) {
var title = '';
if (call.localHold) {
title = '${call.displayName} held the call.';
title = '${call.room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
)} held the call.';
} else if (call.remoteOnHold) {
title = 'You held the call.';
}

View File

@ -9,6 +9,7 @@ import 'package:matrix/matrix.dart';
import 'package:vrouter/vrouter.dart';
import 'package:fluffychat/pages/invitation_selection/invitation_selection_view.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/widgets/matrix.dart';
import '../../utils/localized_exception_extension.dart';
@ -55,7 +56,11 @@ class InvitationSelectionController extends State<InvitationSelection> {
if (OkCancelResult.ok !=
await showOkCancelAlertDialog(
context: context,
title: L10n.of(context)!.inviteContactToGroup(room.displayname),
title: L10n.of(context)!.inviteContactToGroup(
room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
),
okLabel: L10n.of(context)!.yes,
cancelLabel: L10n.of(context)!.cancel,
)) {

View File

@ -1,8 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
extension ClientStoriesExtension on Client {
static const String storiesRoomType = 'msc3588.stories.stories-room';
static const String storiesBlockListType = 'msc3588.stories.block-list';
@ -85,7 +88,11 @@ extension ClientStoriesExtension on Client {
context: context,
actions: candidates
.map(
(room) => SheetAction(label: room.displayname, key: room),
(room) => SheetAction(
label: room.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
key: room),
)
.toList());
}

View File

@ -200,7 +200,9 @@ Future<void> _tryPushHelper(
styleInformation: messagingStyleInformation ??
MessagingStyleInformation(
Person(name: event.room.client.userID),
conversationTitle: event.room.displayname,
conversationTitle: event.room.getLocalizedDisplayname(
MatrixLocals(l10n),
),
groupConversation: !event.room.isDirectChat,
messages: [newMessage],
),
@ -217,7 +219,9 @@ Future<void> _tryPushHelper(
await flutterLocalNotificationsPlugin.show(
id,
event.room.displayname,
event.room.getLocalizedDisplayname(
MatrixLocals(l10n),
),
body,
platformChannelSpecifics,
payload: event.roomId,

View File

@ -222,8 +222,9 @@ class CallKeepManager {
addCall(call.callId, callKeeper);
await _callKeep.displayIncomingCall(
call.callId,
'${call.displayName!} (FluffyChat)',
localizedCallerName: '${call.displayName!} (FluffyChat)',
'${call.room.getLocalizedDisplayname()} (FluffyChat)',
localizedCallerName:
'${call.room.getLocalizedDisplayname()} (FluffyChat)',
handleType: 'number',
hasVideo: call.type == CallType.kVideo,
);

View File

@ -944,7 +944,7 @@ packages:
name: matrix
url: "https://pub.dartlang.org"
source: hosted
version: "0.15.11"
version: "0.15.12"
matrix_api_lite:
dependency: transitive
description:

View File

@ -58,7 +58,7 @@ dependencies:
just_audio_mpv: ^0.1.6
keyboard_shortcuts: ^0.1.4
latlong2: ^0.8.1
matrix: ^0.15.11
matrix: ^0.15.12
matrix_homeserver_recommendations: ^0.3.0
matrix_link_text: ^1.0.2
native_imaging: ^0.1.0