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, context: context,
future: () async { future: () async {
while (archive.isNotEmpty) { while (archive.isNotEmpty) {
Logs().v('Forget room ${archive.last.displayname}'); Logs().v('Forget room ${archive.last.getLocalizedDisplayname()}');
await archive.last.forget(); await archive.last.forget();
archive.removeLast(); archive.removeLast();
} }

View File

@ -134,15 +134,6 @@ class ChatController extends State<Chat> {
bool showEmojiPicker = false; 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 { void recreateChat() async {
final room = this.room; final room = this.room;
final userId = room?.directChatMatrixID; final userId = room?.directChatMatrixID;

View File

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

View File

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

View File

@ -196,7 +196,7 @@ class InputBar extends StatelessWidget {
ret.add({ ret.add({
'type': 'room', 'type': 'room',
'mxid': (r.canonicalAlias.isNotEmpty) ? r.canonicalAlias : r.id, 'mxid': (r.canonicalAlias.isNotEmpty) ? r.canonicalAlias : r.id,
'displayname': r.displayname, 'displayname': r.getLocalizedDisplayname(),
'avatar_url': r.avatar?.toString(), '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/famedlysdk_store.dart';
import 'package:fluffychat/utils/localized_exception_extension.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/client_stories_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/platform_infos.dart'; import 'package:fluffychat/utils/platform_infos.dart';
import '../../../utils/account_bundles.dart'; import '../../../utils/account_bundles.dart';
import '../../utils/matrix_sdk_extensions/matrix_file_extension.dart'; import '../../utils/matrix_sdk_extensions/matrix_file_extension.dart';
@ -508,7 +509,8 @@ class ChatListController extends State<ChatList>
.map( .map(
(space) => AlertDialogAction( (space) => AlertDialogAction(
key: space.id, key: space.id,
label: space.displayname, label: space
.getLocalizedDisplayname(MatrixLocals(L10n.of(context)!)),
), ),
) )
.toList()); .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/pages/chat_list/stories_header.dart';
import 'package:fluffychat/utils/adaptive_bottom_sheet.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/client_stories_extension.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions/matrix_locals.dart';
import 'package:fluffychat/utils/stream_extension.dart'; import 'package:fluffychat/utils/stream_extension.dart';
import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/profile_bottom_sheet.dart'; import 'package:fluffychat/widgets/profile_bottom_sheet.dart';
@ -205,8 +206,11 @@ class ChatListViewBody extends StatelessWidget {
); );
} }
i--; i--;
if (!rooms[i].displayname.toLowerCase().contains( if (!rooms[i]
controller.searchController.text.toLowerCase())) { .getLocalizedDisplayname(MatrixLocals(L10n.of(context)!))
.toLowerCase()
.contains(
controller.searchController.text.toLowerCase())) {
return Container(); return Container();
} }
return ChatListItem( return ChatListItem(

View File

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

View File

@ -10,6 +10,7 @@ import 'package:fluffychat/config/app_config.dart';
import 'package:fluffychat/config/themes.dart'; import 'package:fluffychat/config/themes.dart';
import 'package:fluffychat/pages/chat_list/chat_list.dart'; import 'package:fluffychat/pages/chat_list/chat_list.dart';
import 'package:fluffychat/pages/chat_list/navi_rail_item.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/avatar.dart';
import 'package:fluffychat/widgets/unread_rooms_badge.dart'; import 'package:fluffychat/widgets/unread_rooms_badge.dart';
import '../../widgets/matrix.dart'; import '../../widgets/matrix.dart';
@ -140,13 +141,16 @@ class ChatListView extends StatelessWidget {
controller.activeFilter == ActiveFilter.spaces && controller.activeFilter == ActiveFilter.spaces &&
rootSpaces[i].id == controller.activeSpaceId; rootSpaces[i].id == controller.activeSpaceId;
return NaviRailItem( return NaviRailItem(
toolTip: rootSpaces[i].displayname, toolTip: rootSpaces[i].getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!)),
isSelected: isSelected, isSelected: isSelected,
onTap: () => onTap: () =>
controller.setActiveSpace(rootSpaces[i].id), controller.setActiveSpace(rootSpaces[i].id),
icon: Avatar( icon: Avatar(
mxContent: rootSpaces[i].avatar, mxContent: rootSpaces[i].avatar,
name: rootSpaces[i].displayname, name: rootSpaces[i].getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
size: 32, size: 32,
fontSize: 12, 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.dart';
import 'package:fluffychat/pages/chat_list/chat_list_item.dart'; import 'package:fluffychat/pages/chat_list/chat_list_item.dart';
import 'package:fluffychat/pages/chat_list/search_title.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 'package:fluffychat/widgets/avatar.dart';
import '../../utils/localized_exception_extension.dart'; import '../../utils/localized_exception_extension.dart';
import '../../widgets/matrix.dart'; import '../../widgets/matrix.dart';
@ -85,7 +86,10 @@ class _SpaceViewState extends State<SpaceView> {
activeSpaceId == null ? null : client.getRoomById(activeSpaceId); activeSpaceId == null ? null : client.getRoomById(activeSpaceId);
final action = await showModalActionSheet<SpaceChildContextAction>( final action = await showModalActionSheet<SpaceChildContextAction>(
context: context, context: context,
title: spaceChild?.name ?? room?.displayname, title: spaceChild?.name ??
room?.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
),
message: spaceChild?.topic ?? room?.topic, message: spaceChild?.topic ?? room?.topic,
actions: [ actions: [
if (room == null) if (room == null)
@ -148,25 +152,31 @@ class _SpaceViewState extends State<SpaceView> {
return ListView.builder( return ListView.builder(
itemCount: rootSpaces.length, itemCount: rootSpaces.length,
controller: widget.scrollController, controller: widget.scrollController,
itemBuilder: (context, i) => Material( itemBuilder: (context, i) {
color: Theme.of(context).backgroundColor, final rootSpace = rootSpaces[i];
child: ListTile( final displayname = rootSpace.getLocalizedDisplayname(
leading: Avatar( MatrixLocals(L10n.of(context)!),
mxContent: rootSpaces[i].avatar, );
name: rootSpaces[i].displayname, 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>( return FutureBuilder<GetSpaceHierarchyResponse>(
@ -218,7 +228,9 @@ class _SpaceViewState extends State<SpaceView> {
), ),
title: Text(parentSpace == null title: Text(parentSpace == null
? L10n.of(context)!.allSpaces ? L10n.of(context)!.allSpaces
: parentSpace.displayname), : parentSpace.getLocalizedDisplayname(
MatrixLocals(L10n.of(context)!),
)),
trailing: IconButton( trailing: IconButton(
icon: snapshot.connectionState != ConnectionState.done icon: snapshot.connectionState != ConnectionState.done
? const CircularProgressIndicator.adaptive() ? const CircularProgressIndicator.adaptive()

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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