Skip to content

Commit 5000e5c

Browse files
committed
Merge branch 'refactor/coderabbit-suggestions' of https://github.com/parres-hq/whitenoise_flutter into refactor/coderabbit-suggestions
2 parents 6c00715 + a4bab43 commit 5000e5c

File tree

2 files changed

+40
-37
lines changed

2 files changed

+40
-37
lines changed

ios/Podfile.lock

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,21 @@ EXTERNAL SOURCES:
8484
:path: ".symlinks/plugins/sqflite_darwin/darwin"
8585

8686
SPEC CHECKSUMS:
87-
audio_session: 9bb7f6c970f21241b19f5a3658097ae459681ba0
88-
emoji_picker_flutter: ece213fc274bdddefb77d502d33080dc54e616cc
87+
audio_session: 19e9480dbdd4e5f6c4543826b2e8b0e4ab6145fe
88+
emoji_picker_flutter: 8e50ec5caac456a23a78637e02c6293ea0ac8771
8989
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
90-
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
91-
flutter_secure_storage: 1ed9476fba7e7a782b22888f956cce43e2c62f13
92-
image_picker_ios: 7fe1ff8e34c1790d6fff70a32484959f563a928a
93-
integration_test: 4a889634ef21a45d28d50d622cf412dc6d9f586e
94-
just_audio: 4e391f57b79cad2b0674030a00453ca5ce817eed
95-
mobile_scanner: 9157936403f5a0644ca3779a38ff8404c5434a93
96-
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
97-
path_provider_foundation: 080d55be775b7414fd5a5ef3ac137b97b097e564
98-
rust_lib_whitenoise: 22de658398f8e36a1a396d35b6b6547a0732e6bb
99-
share_plus: 50da8cb520a8f0f65671c6c6a99b3617ed10a58a
100-
shared_preferences_foundation: 9e1978ff2562383bd5676f64ec4e9aa8fa06a6f7
101-
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0
90+
flutter_native_splash: df59bb2e1421aa0282cb2e95618af4dcb0c56c29
91+
flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
92+
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
93+
integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573
94+
just_audio: a42c63806f16995daf5b219ae1d679deb76e6a79
95+
mobile_scanner: 77265f3dc8d580810e91849d4a0811a90467ed5e
96+
package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4
97+
path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
98+
rust_lib_whitenoise: 69ef24b69b2aba78a7ebabc09a504b5a39177d21
99+
share_plus: 8b6f8b3447e494cca5317c8c3073de39b3600d1f
100+
shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
101+
sqflite_darwin: 5a7236e3b501866c1c9befc6771dfd73ffb8702d
102102

103103
PODFILE CHECKSUM: 251cb053df7158f337c0712f2ab29f4e0fa474ce
104104

lib/ui/chat/chat_screen.dart

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
9191

9292
void _handleScrollToBottom({bool hasAnimation = true}) {
9393
WidgetsBinding.instance.addPostFrameCallback((_) {
94-
final double max = _scrollController.position.maxScrollExtent;
9594
if (!_scrollController.hasClients || !mounted) return;
95+
final double max = _scrollController.position.maxScrollExtent;
9696
if (hasAnimation) {
9797
_scrollController.animateTo(
9898
max,
@@ -160,6 +160,31 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
160160
final searchNotifier = ref.read(chatSearchProvider(widget.groupId).notifier);
161161
final isInviteMode = widget.inviteId != null;
162162

163+
// Watch messages first so they're available for listeners
164+
final messages = ref.watch(
165+
chatProvider.select((state) => state.groupMessages[widget.groupId] ?? []),
166+
);
167+
168+
// Move ref.listen calls to the main build method
169+
ref.listen(chatSearchProvider(widget.groupId), (previous, next) {
170+
if (next.query.isNotEmpty && next.query != previous?.query) {
171+
searchNotifier.performSearchWithMessages(next.query, messages);
172+
}
173+
});
174+
175+
ref.listen(chatSearchProvider(widget.groupId).select((state) => state.currentMatchIndex), (
176+
previous,
177+
next,
178+
) {
179+
final currentMatch = searchNotifier.currentMatch;
180+
if (currentMatch != null) {
181+
WidgetsBinding.instance.addPostFrameCallback((_) {
182+
if (!mounted) return;
183+
_scrollToMessage(currentMatch.messageId);
184+
});
185+
}
186+
});
187+
163188
if (isInviteMode) {
164189
return ChatInviteScreen(
165190
groupId: widget.groupId,
@@ -190,28 +215,6 @@ class _ChatScreenState extends ConsumerState<ChatScreen> {
190215

191216
final groupType = groupTypeSnapshot.data!;
192217

193-
final messages = ref.watch(
194-
chatProvider.select((state) => state.groupMessages[widget.groupId] ?? []),
195-
);
196-
197-
ref.listen(chatSearchProvider(widget.groupId), (previous, next) {
198-
if (next.query.isNotEmpty && next.query != previous?.query) {
199-
searchNotifier.performSearchWithMessages(next.query, messages);
200-
}
201-
});
202-
203-
ref.listen(chatSearchProvider(widget.groupId).select((state) => state.currentMatchIndex), (
204-
previous,
205-
next,
206-
) {
207-
final currentMatch = searchNotifier.currentMatch;
208-
if (currentMatch != null) {
209-
WidgetsBinding.instance.addPostFrameCallback((_) {
210-
_scrollToMessage(currentMatch.messageId);
211-
});
212-
}
213-
});
214-
215218
return PopScope(
216219
onPopInvokedWithResult: (_, _) {
217220
if (searchState.isSearchActive) {

0 commit comments

Comments
 (0)