refactor: update providers to use keepAlive for enhanced state management

- Changed multiple provider annotations to `@Riverpod(keepAlive: true)` to improve state retention and management across the application.
- This update aligns with recent enhancements in state management practices, ensuring better performance and user experience throughout the app.
This commit is contained in:
cogwheel0
2025-10-01 18:32:16 +05:30
parent 28dc16a6e3
commit 8a8ba76298
8 changed files with 23 additions and 60 deletions

View File

@@ -33,7 +33,7 @@ final chatMessagesProvider =
);
// Loading state for conversation (used to show chat skeletons during fetch)
@riverpod
@Riverpod(keepAlive: true)
class IsLoadingConversation extends _$IsLoadingConversation {
@override
bool build() => false;
@@ -42,7 +42,7 @@ class IsLoadingConversation extends _$IsLoadingConversation {
}
// Prefilled input text (e.g., when sharing text from other apps)
@riverpod
@Riverpod(keepAlive: true)
class PrefilledInputText extends _$PrefilledInputText {
@override
String? build() => null;
@@ -53,7 +53,7 @@ class PrefilledInputText extends _$PrefilledInputText {
}
// Trigger to request focus on the chat input (increment to signal)
@riverpod
@Riverpod(keepAlive: true)
class InputFocusTrigger extends _$InputFocusTrigger {
@override
int build() => 0;
@@ -68,7 +68,7 @@ class InputFocusTrigger extends _$InputFocusTrigger {
}
// Whether the chat composer currently has focus
@riverpod
@Riverpod(keepAlive: true)
class ComposerHasFocus extends _$ComposerHasFocus {
@override
bool build() => false;

View File

@@ -534,7 +534,7 @@ final selectedMessagesProvider =
);
/// Provider for batch operation mode
@riverpod
@Riverpod(keepAlive: true)
class BatchMode extends _$BatchMode {
@override
bool build() => false;

View File

@@ -326,7 +326,7 @@ final voiceInputServiceProvider = Provider<VoiceInputService>((ref) {
return VoiceInputService();
});
@riverpod
@Riverpod(keepAlive: true)
Future<bool> voiceInputAvailable(Ref ref) async {
final service = ref.watch(voiceInputServiceProvider);
if (!service.isSupportedPlatform) return false;