refactor: migrate Phase 1 providers (2-7/10) to @riverpod
Migrated providers: - selectedModelProvider → SelectedModel - isManualModelSelectionProvider → IsManualModelSelection - reviewerModeProvider → ReviewerMode - isLoadingConversationProvider → IsLoadingConversation - prefilledInputTextProvider → PrefilledInputText - inputFocusTriggerProvider → InputFocusTrigger - composerHasFocusProvider → ComposerHasFocus - batchModeProvider → BatchMode - reducedMotionProvider → ReducedMotion All provider names unchanged, no breaking changes. Build runner successful, analyzer passing. Only 1 WARNING (keepAlive usage) and 2 INFO items remaining.
This commit is contained in:
@@ -615,17 +615,8 @@ final modelsProvider = FutureProvider<List<Model>>((ref) async {
|
||||
}
|
||||
});
|
||||
|
||||
final selectedModelProvider = NotifierProvider<SelectedModelNotifier, Model?>(
|
||||
SelectedModelNotifier.new,
|
||||
);
|
||||
|
||||
// Track if the current model selection is manual (user-selected) or automatic (default)
|
||||
final isManualModelSelectionProvider =
|
||||
NotifierProvider<IsManualModelSelectionNotifier, bool>(
|
||||
IsManualModelSelectionNotifier.new,
|
||||
);
|
||||
|
||||
class SelectedModelNotifier extends Notifier<Model?> {
|
||||
@riverpod
|
||||
class SelectedModel extends _$SelectedModel {
|
||||
@override
|
||||
Model? build() => null;
|
||||
|
||||
@@ -634,7 +625,9 @@ class SelectedModelNotifier extends Notifier<Model?> {
|
||||
void clear() => state = null;
|
||||
}
|
||||
|
||||
class IsManualModelSelectionNotifier extends Notifier<bool> {
|
||||
// Track if the current model selection is manual (user-selected) or automatic (default)
|
||||
@riverpod
|
||||
class IsManualModelSelection extends _$IsManualModelSelection {
|
||||
@override
|
||||
bool build() => false;
|
||||
|
||||
@@ -1409,11 +1402,8 @@ final archivedConversationsProvider = Provider<List<Conversation>>((ref) {
|
||||
});
|
||||
|
||||
// Reviewer mode provider (persisted)
|
||||
final reviewerModeProvider = NotifierProvider<ReviewerModeNotifier, bool>(
|
||||
ReviewerModeNotifier.new,
|
||||
);
|
||||
|
||||
class ReviewerModeNotifier extends Notifier<bool> {
|
||||
@riverpod
|
||||
class ReviewerMode extends _$ReviewerMode {
|
||||
late final OptimizedStorageService _storage;
|
||||
bool _initialized = false;
|
||||
|
||||
|
||||
@@ -1,7 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../shared/theme/theme_extensions.dart';
|
||||
|
||||
part 'animation_service.g.dart';
|
||||
|
||||
/// Service for managing animations with performance optimization and accessibility
|
||||
class AnimationService {
|
||||
/// Get optimized animation duration based on context and settings
|
||||
@@ -208,9 +212,13 @@ class AnimationService {
|
||||
enum PageTransitionType { fade, slide, scale }
|
||||
|
||||
/// Provider for reduced motion preference
|
||||
final reducedMotionProvider = NotifierProvider<ReducedMotionNotifier, bool>(
|
||||
ReducedMotionNotifier.new,
|
||||
);
|
||||
@riverpod
|
||||
class ReducedMotion extends _$ReducedMotion {
|
||||
@override
|
||||
bool build() => false;
|
||||
|
||||
void set(bool value) => state = value;
|
||||
}
|
||||
|
||||
/// Provider for animation performance settings
|
||||
final animationPerformanceProvider =
|
||||
@@ -218,13 +226,6 @@ final animationPerformanceProvider =
|
||||
AnimationPerformanceNotifier.new,
|
||||
);
|
||||
|
||||
class ReducedMotionNotifier extends Notifier<bool> {
|
||||
@override
|
||||
bool build() => false;
|
||||
|
||||
void set(bool value) => state = value;
|
||||
}
|
||||
|
||||
class AnimationPerformanceNotifier extends Notifier<AnimationPerformance> {
|
||||
@override
|
||||
AnimationPerformance build() => AnimationPerformance.adaptive;
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'package:yaml/yaml.dart' as yaml;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:uuid/uuid.dart';
|
||||
import '../../../core/utils/tool_calls_parser.dart';
|
||||
import '../../../core/services/streaming_helper.dart';
|
||||
import 'package:yaml/yaml.dart' as yaml;
|
||||
|
||||
import '../../../core/auth/auth_state_manager.dart';
|
||||
import '../../../core/models/chat_message.dart';
|
||||
import '../../../core/models/conversation.dart';
|
||||
import '../../../core/providers/app_providers.dart';
|
||||
import '../../../core/models/socket_event.dart';
|
||||
import '../../../core/auth/auth_state_manager.dart';
|
||||
import '../../../core/providers/app_providers.dart';
|
||||
import '../../../core/services/streaming_helper.dart';
|
||||
import '../../../core/utils/debug_logger.dart';
|
||||
import '../../../core/utils/inactivity_watchdog.dart';
|
||||
import '../services/reviewer_mode_service.dart';
|
||||
import '../../../core/utils/tool_calls_parser.dart';
|
||||
import '../../../shared/services/tasks/task_queue.dart';
|
||||
import '../../tools/providers/tools_providers.dart';
|
||||
import 'dart:async';
|
||||
import '../../../core/utils/debug_logger.dart';
|
||||
import '../services/reviewer_mode_service.dart';
|
||||
|
||||
part 'chat_providers.g.dart';
|
||||
|
||||
const bool kSocketVerboseLogging = false;
|
||||
|
||||
@@ -27,36 +31,17 @@ final chatMessagesProvider =
|
||||
);
|
||||
|
||||
// Loading state for conversation (used to show chat skeletons during fetch)
|
||||
final isLoadingConversationProvider =
|
||||
NotifierProvider<IsLoadingConversationNotifier, bool>(
|
||||
IsLoadingConversationNotifier.new,
|
||||
);
|
||||
|
||||
// Prefilled input text (e.g., when sharing text from other apps)
|
||||
final prefilledInputTextProvider =
|
||||
NotifierProvider<PrefilledInputTextNotifier, String?>(
|
||||
PrefilledInputTextNotifier.new,
|
||||
);
|
||||
|
||||
// Trigger to request focus on the chat input (increment to signal)
|
||||
final inputFocusTriggerProvider =
|
||||
NotifierProvider<InputFocusTriggerNotifier, int>(
|
||||
InputFocusTriggerNotifier.new,
|
||||
);
|
||||
|
||||
// Whether the chat composer currently has focus
|
||||
final composerHasFocusProvider = NotifierProvider<ComposerFocusNotifier, bool>(
|
||||
ComposerFocusNotifier.new,
|
||||
);
|
||||
|
||||
class IsLoadingConversationNotifier extends Notifier<bool> {
|
||||
@riverpod
|
||||
class IsLoadingConversation extends _$IsLoadingConversation {
|
||||
@override
|
||||
bool build() => false;
|
||||
|
||||
void set(bool value) => state = value;
|
||||
}
|
||||
|
||||
class PrefilledInputTextNotifier extends Notifier<String?> {
|
||||
// Prefilled input text (e.g., when sharing text from other apps)
|
||||
@riverpod
|
||||
class PrefilledInputText extends _$PrefilledInputText {
|
||||
@override
|
||||
String? build() => null;
|
||||
|
||||
@@ -65,7 +50,9 @@ class PrefilledInputTextNotifier extends Notifier<String?> {
|
||||
void clear() => state = null;
|
||||
}
|
||||
|
||||
class InputFocusTriggerNotifier extends Notifier<int> {
|
||||
// Trigger to request focus on the chat input (increment to signal)
|
||||
@riverpod
|
||||
class InputFocusTrigger extends _$InputFocusTrigger {
|
||||
@override
|
||||
int build() => 0;
|
||||
|
||||
@@ -78,7 +65,9 @@ class InputFocusTriggerNotifier extends Notifier<int> {
|
||||
}
|
||||
}
|
||||
|
||||
class ComposerFocusNotifier extends Notifier<bool> {
|
||||
// Whether the chat composer currently has focus
|
||||
@riverpod
|
||||
class ComposerHasFocus extends _$ComposerHasFocus {
|
||||
@override
|
||||
bool build() => false;
|
||||
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
|
||||
import '../../../core/models/chat_message.dart';
|
||||
import '../../../core/models/conversation.dart';
|
||||
|
||||
part 'message_batch_service.g.dart';
|
||||
|
||||
/// Service for managing batch operations on messages
|
||||
class MessageBatchService {
|
||||
/// Export messages to various formats
|
||||
@@ -529,9 +534,13 @@ final selectedMessagesProvider =
|
||||
);
|
||||
|
||||
/// Provider for batch operation mode
|
||||
final batchModeProvider = NotifierProvider<BatchModeNotifier, bool>(
|
||||
BatchModeNotifier.new,
|
||||
);
|
||||
@riverpod
|
||||
class BatchMode extends _$BatchMode {
|
||||
@override
|
||||
bool build() => false;
|
||||
|
||||
void set(bool value) => state = value;
|
||||
}
|
||||
|
||||
/// Provider for message filter
|
||||
final messageFilterProvider =
|
||||
@@ -548,13 +557,6 @@ class SelectedMessagesNotifier extends Notifier<Set<String>> {
|
||||
void clear() => state = <String>{};
|
||||
}
|
||||
|
||||
class BatchModeNotifier extends Notifier<bool> {
|
||||
@override
|
||||
bool build() => false;
|
||||
|
||||
void set(bool value) => state = value;
|
||||
}
|
||||
|
||||
class MessageFilterNotifier extends Notifier<MessageFilter?> {
|
||||
@override
|
||||
MessageFilter? build() => null;
|
||||
|
||||
Reference in New Issue
Block a user