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?>(
|
@riverpod
|
||||||
SelectedModelNotifier.new,
|
class SelectedModel extends _$SelectedModel {
|
||||||
);
|
|
||||||
|
|
||||||
// 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?> {
|
|
||||||
@override
|
@override
|
||||||
Model? build() => null;
|
Model? build() => null;
|
||||||
|
|
||||||
@@ -634,7 +625,9 @@ class SelectedModelNotifier extends Notifier<Model?> {
|
|||||||
void clear() => state = null;
|
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
|
@override
|
||||||
bool build() => false;
|
bool build() => false;
|
||||||
|
|
||||||
@@ -1409,11 +1402,8 @@ final archivedConversationsProvider = Provider<List<Conversation>>((ref) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Reviewer mode provider (persisted)
|
// Reviewer mode provider (persisted)
|
||||||
final reviewerModeProvider = NotifierProvider<ReviewerModeNotifier, bool>(
|
@riverpod
|
||||||
ReviewerModeNotifier.new,
|
class ReviewerMode extends _$ReviewerMode {
|
||||||
);
|
|
||||||
|
|
||||||
class ReviewerModeNotifier extends Notifier<bool> {
|
|
||||||
late final OptimizedStorageService _storage;
|
late final OptimizedStorageService _storage;
|
||||||
bool _initialized = false;
|
bool _initialized = false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
import '../../shared/theme/theme_extensions.dart';
|
import '../../shared/theme/theme_extensions.dart';
|
||||||
|
|
||||||
|
part 'animation_service.g.dart';
|
||||||
|
|
||||||
/// Service for managing animations with performance optimization and accessibility
|
/// Service for managing animations with performance optimization and accessibility
|
||||||
class AnimationService {
|
class AnimationService {
|
||||||
/// Get optimized animation duration based on context and settings
|
/// Get optimized animation duration based on context and settings
|
||||||
@@ -208,9 +212,13 @@ class AnimationService {
|
|||||||
enum PageTransitionType { fade, slide, scale }
|
enum PageTransitionType { fade, slide, scale }
|
||||||
|
|
||||||
/// Provider for reduced motion preference
|
/// Provider for reduced motion preference
|
||||||
final reducedMotionProvider = NotifierProvider<ReducedMotionNotifier, bool>(
|
@riverpod
|
||||||
ReducedMotionNotifier.new,
|
class ReducedMotion extends _$ReducedMotion {
|
||||||
);
|
@override
|
||||||
|
bool build() => false;
|
||||||
|
|
||||||
|
void set(bool value) => state = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// Provider for animation performance settings
|
/// Provider for animation performance settings
|
||||||
final animationPerformanceProvider =
|
final animationPerformanceProvider =
|
||||||
@@ -218,13 +226,6 @@ final animationPerformanceProvider =
|
|||||||
AnimationPerformanceNotifier.new,
|
AnimationPerformanceNotifier.new,
|
||||||
);
|
);
|
||||||
|
|
||||||
class ReducedMotionNotifier extends Notifier<bool> {
|
|
||||||
@override
|
|
||||||
bool build() => false;
|
|
||||||
|
|
||||||
void set(bool value) => state = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
class AnimationPerformanceNotifier extends Notifier<AnimationPerformance> {
|
class AnimationPerformanceNotifier extends Notifier<AnimationPerformance> {
|
||||||
@override
|
@override
|
||||||
AnimationPerformance build() => AnimationPerformance.adaptive;
|
AnimationPerformance build() => AnimationPerformance.adaptive;
|
||||||
|
|||||||
@@ -1,22 +1,26 @@
|
|||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'package:yaml/yaml.dart' as yaml;
|
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
import '../../../core/utils/tool_calls_parser.dart';
|
import 'package:yaml/yaml.dart' as yaml;
|
||||||
import '../../../core/services/streaming_helper.dart';
|
|
||||||
|
import '../../../core/auth/auth_state_manager.dart';
|
||||||
import '../../../core/models/chat_message.dart';
|
import '../../../core/models/chat_message.dart';
|
||||||
import '../../../core/models/conversation.dart';
|
import '../../../core/models/conversation.dart';
|
||||||
import '../../../core/providers/app_providers.dart';
|
|
||||||
import '../../../core/models/socket_event.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 '../../../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 '../../../shared/services/tasks/task_queue.dart';
|
||||||
import '../../tools/providers/tools_providers.dart';
|
import '../../tools/providers/tools_providers.dart';
|
||||||
import 'dart:async';
|
import '../services/reviewer_mode_service.dart';
|
||||||
import '../../../core/utils/debug_logger.dart';
|
|
||||||
|
part 'chat_providers.g.dart';
|
||||||
|
|
||||||
const bool kSocketVerboseLogging = false;
|
const bool kSocketVerboseLogging = false;
|
||||||
|
|
||||||
@@ -27,36 +31,17 @@ final chatMessagesProvider =
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Loading state for conversation (used to show chat skeletons during fetch)
|
// Loading state for conversation (used to show chat skeletons during fetch)
|
||||||
final isLoadingConversationProvider =
|
@riverpod
|
||||||
NotifierProvider<IsLoadingConversationNotifier, bool>(
|
class IsLoadingConversation extends _$IsLoadingConversation {
|
||||||
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> {
|
|
||||||
@override
|
@override
|
||||||
bool build() => false;
|
bool build() => false;
|
||||||
|
|
||||||
void set(bool value) => state = value;
|
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
|
@override
|
||||||
String? build() => null;
|
String? build() => null;
|
||||||
|
|
||||||
@@ -65,7 +50,9 @@ class PrefilledInputTextNotifier extends Notifier<String?> {
|
|||||||
void clear() => state = null;
|
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
|
@override
|
||||||
int build() => 0;
|
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
|
@override
|
||||||
bool build() => false;
|
bool build() => false;
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,15 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
|
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||||
|
|
||||||
import '../../../core/models/chat_message.dart';
|
import '../../../core/models/chat_message.dart';
|
||||||
import '../../../core/models/conversation.dart';
|
import '../../../core/models/conversation.dart';
|
||||||
|
|
||||||
|
part 'message_batch_service.g.dart';
|
||||||
|
|
||||||
/// Service for managing batch operations on messages
|
/// Service for managing batch operations on messages
|
||||||
class MessageBatchService {
|
class MessageBatchService {
|
||||||
/// Export messages to various formats
|
/// Export messages to various formats
|
||||||
@@ -529,9 +534,13 @@ final selectedMessagesProvider =
|
|||||||
);
|
);
|
||||||
|
|
||||||
/// Provider for batch operation mode
|
/// Provider for batch operation mode
|
||||||
final batchModeProvider = NotifierProvider<BatchModeNotifier, bool>(
|
@riverpod
|
||||||
BatchModeNotifier.new,
|
class BatchMode extends _$BatchMode {
|
||||||
);
|
@override
|
||||||
|
bool build() => false;
|
||||||
|
|
||||||
|
void set(bool value) => state = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// Provider for message filter
|
/// Provider for message filter
|
||||||
final messageFilterProvider =
|
final messageFilterProvider =
|
||||||
@@ -548,13 +557,6 @@ class SelectedMessagesNotifier extends Notifier<Set<String>> {
|
|||||||
void clear() => state = <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?> {
|
class MessageFilterNotifier extends Notifier<MessageFilter?> {
|
||||||
@override
|
@override
|
||||||
MessageFilter? build() => null;
|
MessageFilter? build() => null;
|
||||||
|
|||||||
Reference in New Issue
Block a user