From 88c99b746732241bfddf7efdec71fd2945885fac Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 9 Jun 2024 23:00:11 +0800 Subject: [PATCH] :bug: Bug fixes and optimization --- ios/Podfile.lock | 7 +++++++ lib/providers/account.dart | 4 ++-- lib/providers/chat.dart | 2 +- lib/screens/channel/channel_chat.dart | 1 + lib/screens/channel/channel_detail.dart | 15 +++++++++------ lib/screens/channel/channel_organize.dart | 2 +- lib/screens/realms/realm_detail.dart | 9 ++------- lib/widgets/attachments/attachment_list.dart | 1 - lib/widgets/chat/chat_message.dart | 13 ++++++++++++- lib/widgets/chat/chat_message_input.dart | 3 ++- macos/Podfile.lock | 7 +++++++ macos/Runner/DebugProfile.entitlements | 10 ++++++++++ macos/Runner/Info.plist | 9 +++------ macos/Runner/Release.entitlements | 6 ++++++ 14 files changed, 63 insertions(+), 26 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 9fea52b..1028e17 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -133,6 +133,9 @@ PODS: - Flutter - FlutterMacOS - Sentry/HybridSDK (= 8.25.2) + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS - sqflite (0.0.3): - Flutter - FlutterMacOS @@ -162,6 +165,7 @@ DEPENDENCIES: - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `.symlinks/plugins/sqflite/darwin`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/darwin`) @@ -216,6 +220,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/permission_handler_apple/ios" sentry_flutter: :path: ".symlinks/plugins/sentry_flutter/ios" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/darwin" sqflite: :path: ".symlinks/plugins/sqflite/darwin" url_launcher_ios: @@ -254,6 +260,7 @@ SPEC CHECKSUMS: SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a Sentry: 51b056d96914a741f63eca774d118678b1eb05a1 sentry_flutter: e8397d13e297a5d4b6be8a752e33140b21c5cc97 + shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec SwiftyGif: 706c60cf65fa2bc5ee0313beece843c8eb8194d4 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe diff --git a/lib/providers/account.dart b/lib/providers/account.dart index ea62352..c66c61b 100644 --- a/lib/providers/account.dart +++ b/lib/providers/account.dart @@ -54,7 +54,7 @@ class AccountProvider extends GetxController { } final AuthProvider auth = Get.find(); - auth.ensureCredentials(); + await auth.ensureCredentials(); if (auth.credentials == null) await auth.loadCredentials(); @@ -185,7 +185,7 @@ class AccountProvider extends GetxController { late final String provider; final deviceUuid = await _getDeviceUuid(); - if (deviceUuid == null) { + if (deviceUuid == null || deviceUuid.isEmpty) { log("Unable to active push notifications, couldn't get device uuid"); } diff --git a/lib/providers/chat.dart b/lib/providers/chat.dart index 8239fa6..9924084 100644 --- a/lib/providers/chat.dart +++ b/lib/providers/chat.dart @@ -24,7 +24,7 @@ class ChatProvider extends GetxController { } final AuthProvider auth = Get.find(); - auth.ensureCredentials(); + await auth.ensureCredentials(); final uri = Uri.parse( '${ServiceFinder.services['messaging']}/api/ws?tk=${auth.credentials!.accessToken}' diff --git a/lib/screens/channel/channel_chat.dart b/lib/screens/channel/channel_chat.dart index cdc24dc..ee1e55c 100644 --- a/lib/screens/channel/channel_chat.dart +++ b/lib/screens/channel/channel_chat.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:developer'; import 'dart:ui'; import 'package:flutter/material.dart'; diff --git a/lib/screens/channel/channel_detail.dart b/lib/screens/channel/channel_detail.dart index 0268396..c93fb67 100644 --- a/lib/screens/channel/channel_detail.dart +++ b/lib/screens/channel/channel_detail.dart @@ -81,8 +81,8 @@ class _ChannelDetailScreenState extends State { final client = auth.configureClient(service: 'messaging'); - final resp = await client - .put('/api/channels/${widget.realm}/${widget.channel.alias}/members/me', { + final resp = await client.put( + '/api/channels/${widget.realm}/${widget.channel.alias}/members/me', { 'nick': null, 'notify_level': _notifyLevel, }); @@ -112,14 +112,17 @@ class _ChannelDetailScreenState extends State { final ownerActions = [ ListTile( - leading: const Icon(Icons.edit), + leading: const Icon(Icons.settings), trailing: const Icon(Icons.chevron_right), - title: Text('channelAdjust'.tr.capitalize!), + title: Text('channelSettings'.tr.capitalize!), onTap: () async { AppRouter.instance .pushNamed( 'channelOrganizing', - extra: ChannelOrganizeArguments(edit: widget.channel), + extra: ChannelOrganizeArguments( + edit: widget.channel, + realm: widget.channel.realm, + ), ) .then((resp) { if (resp != null) { @@ -176,7 +179,7 @@ class _ChannelDetailScreenState extends State { isExpanded: true, items: notifyTypes.entries .map((item) => DropdownMenuItem( - enabled: !_isBusy, + enabled: !_isBusy, value: item.key, child: Text( item.value, diff --git a/lib/screens/channel/channel_organize.dart b/lib/screens/channel/channel_organize.dart index cd7e873..5c7a4a7 100644 --- a/lib/screens/channel/channel_organize.dart +++ b/lib/screens/channel/channel_organize.dart @@ -132,7 +132,7 @@ class _ChannelOrganizeScreenState extends State { ), actions: notifyBannerActions, ).paddingOnly(bottom: 6), - if (widget.realm != null) + if (widget.realm != null && widget.edit == null) MaterialBanner( leading: const Icon(Icons.group), leadingPadding: const EdgeInsets.only(left: 10, right: 20), diff --git a/lib/screens/realms/realm_detail.dart b/lib/screens/realms/realm_detail.dart index 72b1cee..9ba7a70 100644 --- a/lib/screens/realms/realm_detail.dart +++ b/lib/screens/realms/realm_detail.dart @@ -67,9 +67,9 @@ class _RealmDetailScreenState extends State { Widget build(BuildContext context) { final ownerActions = [ ListTile( - leading: const Icon(Icons.edit), + leading: const Icon(Icons.settings), trailing: const Icon(Icons.chevron_right), - title: Text('realmAdjust'.tr.capitalize!), + title: Text('realmSettings'.tr.capitalize!), onTap: () async { AppRouter.instance .pushNamed( @@ -119,11 +119,6 @@ class _RealmDetailScreenState extends State { Expanded( child: ListView( children: [ - ListTile( - leading: const Icon(Icons.settings), - trailing: const Icon(Icons.chevron_right), - title: Text('realmSettings'.tr.capitalize!), - ), ListTile( leading: const Icon(Icons.supervisor_account), trailing: const Icon(Icons.chevron_right), diff --git a/lib/widgets/attachments/attachment_list.dart b/lib/widgets/attachments/attachment_list.dart index 002a4d5..520533c 100644 --- a/lib/widgets/attachments/attachment_list.dart +++ b/lib/widgets/attachments/attachment_list.dart @@ -94,7 +94,6 @@ class _AttachmentListState extends State { @override void initState() { super.initState(); - getMetadataList(); } diff --git a/lib/widgets/chat/chat_message.dart b/lib/widgets/chat/chat_message.dart index fc61d5b..4ed005f 100644 --- a/lib/widgets/chat/chat_message.dart +++ b/lib/widgets/chat/chat_message.dart @@ -100,7 +100,17 @@ class ChatMessage extends StatelessWidget { if (isContentPreviewing) { widget = buildContent(); } else if (isMerged) { - widget = buildContent().paddingOnly(left: 52); + widget = Column( + children: [ + buildContent().paddingOnly(left: 52), + if (item.attachments?.isNotEmpty ?? false) + AttachmentList( + key: Key('m${item.uuid}attachments'), + parentId: item.uuid, + attachmentsId: item.attachments ?? List.empty(), + ).paddingSymmetric(vertical: 4), + ], + ); } else if (isReply) { widget = Row( mainAxisAlignment: MainAxisAlignment.center, @@ -149,6 +159,7 @@ class ChatMessage extends StatelessWidget { ).paddingSymmetric(horizontal: 12), if (item.attachments?.isNotEmpty ?? false) AttachmentList( + key: Key('m${item.uuid}attachments'), parentId: item.uuid, attachmentsId: item.attachments ?? List.empty(), ).paddingSymmetric(vertical: 4), diff --git a/lib/widgets/chat/chat_message_input.dart b/lib/widgets/chat/chat_message_input.dart index 4b8efc5..57cad53 100644 --- a/lib/widgets/chat/chat_message_input.dart +++ b/lib/widgets/chat/chat_message_input.dart @@ -75,7 +75,7 @@ class _ChatMessageInputState extends State { 'uuid': const Uuid().v4(), 'type': 'm.text', 'content': encodeMessage(_textController.value.text), - 'attachments': _attachments, + 'attachments': List.from(_attachments), 'reply_to': _replyTo?.id, }; @@ -96,6 +96,7 @@ class _ChatMessageInputState extends State { updatedAt: DateTime.now(), content: payload['content'] as Map, type: payload['type'] as String, + attachments: _attachments, sender: sender, replyId: _replyTo?.id, replyTo: _replyTo, diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 77662ee..d4c118a 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -95,6 +95,9 @@ PODS: - Flutter - FlutterMacOS - Sentry/HybridSDK (= 8.25.2) + - shared_preferences_foundation (0.0.1): + - Flutter + - FlutterMacOS - sqflite (0.0.3): - Flutter - FlutterMacOS @@ -121,6 +124,7 @@ DEPENDENCIES: - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) - sentry_flutter (from `Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos`) + - shared_preferences_foundation (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - video_player_avfoundation (from `Flutter/ephemeral/.symlinks/plugins/video_player_avfoundation/darwin`) @@ -167,6 +171,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin sentry_flutter: :path: Flutter/ephemeral/.symlinks/plugins/sentry_flutter/macos + shared_preferences_foundation: + :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_foundation/darwin sqflite: :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin url_launcher_macos: @@ -200,6 +206,7 @@ SPEC CHECKSUMS: PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 Sentry: 51b056d96914a741f63eca774d118678b1eb05a1 sentry_flutter: e8397d13e297a5d4b6be8a752e33140b21c5cc97 + shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78 sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec url_launcher_macos: 5f437abeda8c85500ceb03f5c1938a8c5a705399 video_player_avfoundation: 7c6c11d8470e1675df7397027218274b6d2360b3 diff --git a/macos/Runner/DebugProfile.entitlements b/macos/Runner/DebugProfile.entitlements index 3ba6c12..d1a57ab 100644 --- a/macos/Runner/DebugProfile.entitlements +++ b/macos/Runner/DebugProfile.entitlements @@ -2,10 +2,20 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox com.apple.security.cs.allow-jit + com.apple.security.device.audio-input + + com.apple.security.device.bluetooth + + com.apple.security.device.camera + + com.apple.security.files.user-selected.read-only + com.apple.security.network.client com.apple.security.network.server diff --git a/macos/Runner/Info.plist b/macos/Runner/Info.plist index bb569f4..e4547bb 100644 --- a/macos/Runner/Info.plist +++ b/macos/Runner/Info.plist @@ -2,8 +2,6 @@ - LSApplicationCategoryType - public.app-category.social-networking CFBundleDevelopmentRegion $(DEVELOPMENT_LANGUAGE) CFBundleExecutable @@ -24,13 +22,12 @@ $(FLUTTER_BUILD_NUMBER) ITSAppUsesNonExemptEncryption + LSApplicationCategoryType + public.app-category.social-networking LSMinimumSystemVersion $(MACOSX_DEPLOYMENT_TARGET) NSAppTransportSecurity - - NSExceptionDomains - - + NSHumanReadableCopyright $(PRODUCT_COPYRIGHT) NSMainNibFile diff --git a/macos/Runner/Release.entitlements b/macos/Runner/Release.entitlements index b217e31..7fe6128 100644 --- a/macos/Runner/Release.entitlements +++ b/macos/Runner/Release.entitlements @@ -2,10 +2,16 @@ + com.apple.developer.aps-environment + development com.apple.security.app-sandbox + com.apple.security.device.audio-input + com.apple.security.device.bluetooth + com.apple.security.device.camera + com.apple.security.files.user-selected.read-only com.apple.security.network.client