fix: eliminate pull-to-refresh flicker by holding stale data during re-fetch
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user