fix: eliminate pull-to-refresh flicker by holding stale data during re-fetch

This commit is contained in:
2026-04-08 14:39:50 -04:00
parent 6c29b685e8
commit 3e888b6458
12 changed files with 70 additions and 14 deletions
+13
View File
@@ -58,6 +58,12 @@ class ConversationsNotifier extends AsyncNotifier<List<Conversation>> {
]);
}
/// Re-fetch conversations without clearing the current list (no flicker).
Future<void> refresh() async {
final fresh = await ref.read(chatRepositoryProvider).getConversations();
state = AsyncData(fresh);
}
// Called after a message is sent to patch the server-generated title
// in-place without triggering a full reload or loading state.
void patchConversation(Conversation updated) {
@@ -86,6 +92,13 @@ class MessagesNotifier extends AsyncNotifier<List<Message>> {
return messages;
}
/// Re-fetch messages without clearing the current list (no flicker).
Future<void> refresh() async {
final (_, messages) =
await ref.read(chatRepositoryProvider).getMessages(_convId);
state = AsyncData(messages);
}
Future<void> sendMessage(String content) async {
final convId = _convId;
final repo = ref.read(chatRepositoryProvider);