Skip to content

Commit 0a508c1

Browse files
committed
Fix DM composer send state
1 parent ab01279 commit 0a508c1

2 files changed

Lines changed: 80 additions & 53 deletions

File tree

apps/mobile/lib/features/me/presentation/me_screen.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import '../../../core/theme/theme_mode_controller.dart';
88
import '../../account/data/account_edge_functions.dart';
99
import '../../auth/application/auth_bootstrap_provider.dart';
1010
import '../../auth/domain/auth_bootstrap_state.dart';
11+
import '../../communities/data/community_edge_functions.dart';
1112
import '../../feed/application/feed_controllers.dart';
1213
import '../../home/presentation/home_scaffold.dart';
1314
import '../../notifications/application/notification_providers.dart';
@@ -233,10 +234,6 @@ class _DangerZoneCardState extends ConsumerState<_DangerZoneCard> {
233234
return;
234235
}
235236

236-
showUserMessage(
237-
context,
238-
'Anonymous account deleted. Starting a fresh session.',
239-
);
240237
context.go('/splash');
241238
} catch (error) {
242239
if (!mounted) {
@@ -262,9 +259,14 @@ class _DangerZoneCardState extends ConsumerState<_DangerZoneCard> {
262259
ref.invalidate(premiumSnapshotProvider);
263260
ref.invalidate(myPostsProvider);
264261
ref.invalidate(myRepliesProvider);
262+
ref.invalidate(myCommunitiesProvider);
263+
ref.invalidate(globalCommunitiesProvider);
264+
ref.invalidate(trendingPublicCommunitiesProvider);
265265
ref.invalidate(myPrivateRoomsProvider);
266+
ref.invalidate(joinPrivateChatProvider);
266267
ref.invalidate(notificationFeedProvider);
267268
ref.invalidate(globalFeedControllerProvider);
269+
ref.invalidate(communityFeedControllerProvider);
268270
ref.read(likedPostIdsProvider.notifier).state = <String>{};
269271
}
270272
}

apps/mobile/lib/features/private_chats/presentation/private_chat_screen.dart

Lines changed: 74 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,6 @@ class _PrivateChatRoomState extends ConsumerState<_PrivateChatRoom> {
768768
final currentUserId = api?.currentUserId;
769769
final timeline = _buildTimeline();
770770
final typingLabel = _typingLabel();
771-
final canSend = !_isSending &&
772-
(_messageController.text.trim().isNotEmpty ||
773-
_selectedAttachment != null);
774771

775772
return SafeArea(
776773
child: Column(
@@ -857,56 +854,84 @@ class _PrivateChatRoomState extends ConsumerState<_PrivateChatRoom> {
857854
),
858855
Padding(
859856
padding: const EdgeInsets.fromLTRB(12, 8, 12, 12),
860-
child: Row(
861-
crossAxisAlignment: CrossAxisAlignment.end,
862-
children: <Widget>[
863-
Column(
864-
mainAxisSize: MainAxisSize.min,
857+
child: ValueListenableBuilder<TextEditingValue>(
858+
valueListenable: _messageController,
859+
builder: (
860+
BuildContext context,
861+
TextEditingValue value,
862+
Widget? child,
863+
) {
864+
final canSend = !_isSending &&
865+
(value.text.trim().isNotEmpty ||
866+
_selectedAttachment != null);
867+
868+
return Row(
869+
crossAxisAlignment: CrossAxisAlignment.end,
865870
children: <Widget>[
866-
IconButton(
867-
tooltip: 'Send photo',
868-
onPressed: _isSending
869-
? null
870-
: () => _pickAttachment(PrivateChatMessageType.image),
871-
icon: const Icon(Icons.photo_outlined),
871+
Column(
872+
mainAxisSize: MainAxisSize.min,
873+
children: <Widget>[
874+
IconButton(
875+
tooltip: 'Send photo',
876+
onPressed: _isSending
877+
? null
878+
: () => _pickAttachment(
879+
PrivateChatMessageType.image,
880+
),
881+
icon: const Icon(Icons.photo_outlined),
882+
),
883+
const SizedBox(height: 2),
884+
IconButton(
885+
tooltip: 'Send video',
886+
onPressed: _isSending
887+
? null
888+
: () => _pickAttachment(
889+
PrivateChatMessageType.video,
890+
),
891+
icon: const Icon(Icons.videocam_outlined),
892+
),
893+
],
872894
),
873-
const SizedBox(height: 2),
874-
IconButton(
875-
tooltip: 'Send video',
876-
onPressed: _isSending
877-
? null
878-
: () => _pickAttachment(PrivateChatMessageType.video),
879-
icon: const Icon(Icons.videocam_outlined),
895+
const SizedBox(width: 8),
896+
Expanded(
897+
child: TextField(
898+
controller: _messageController,
899+
maxLines: 4,
900+
minLines: 1,
901+
maxLength: 2000,
902+
enabled: !_isSending,
903+
decoration: const InputDecoration(
904+
hintText: 'Write a message...',
905+
counterText: '',
906+
),
907+
textInputAction: TextInputAction.send,
908+
onSubmitted: (_) {
909+
if (canSend) {
910+
_sendMessage();
911+
}
912+
},
913+
),
880914
),
881-
],
882-
),
883-
const SizedBox(width: 8),
884-
Expanded(
885-
child: TextField(
886-
controller: _messageController,
887-
maxLines: 4,
888-
minLines: 1,
889-
maxLength: 2000,
890-
decoration: const InputDecoration(
891-
hintText: 'Write a message...',
892-
counterText: '',
915+
const SizedBox(width: 8),
916+
AnimatedScale(
917+
duration: const Duration(milliseconds: 160),
918+
scale: canSend ? 1 : 0.94,
919+
child: IconButton.filled(
920+
onPressed: canSend ? _sendMessage : null,
921+
icon: _isSending
922+
? const SizedBox(
923+
width: 18,
924+
height: 18,
925+
child: CircularProgressIndicator(
926+
strokeWidth: 2,
927+
),
928+
)
929+
: const Icon(Icons.send_rounded),
930+
),
893931
),
894-
textInputAction: TextInputAction.send,
895-
onSubmitted: (_) => _sendMessage(),
896-
),
897-
),
898-
const SizedBox(width: 8),
899-
IconButton.filled(
900-
onPressed: canSend ? _sendMessage : null,
901-
icon: _isSending
902-
? const SizedBox(
903-
width: 18,
904-
height: 18,
905-
child: CircularProgressIndicator(strokeWidth: 2),
906-
)
907-
: const Icon(Icons.send_rounded),
908-
),
909-
],
932+
],
933+
);
934+
},
910935
),
911936
),
912937
],

0 commit comments

Comments
 (0)