refactor: optimize codebase

This commit is contained in:
cogwheel0
2025-09-23 00:58:58 +05:30
parent 7ab1ec3acf
commit 41216ea432
10 changed files with 80 additions and 494 deletions

View File

@@ -126,10 +126,13 @@ final activeServerProvider = FutureProvider<ServerConfig?>((ref) async {
if (activeId == null || configs.isEmpty) return null;
return configs.firstWhere(
(config) => config.id == activeId,
orElse: () => configs.first,
);
for (final config in configs) {
if (config.id == activeId) {
return config;
}
}
return null;
});
final serverConnectionStateProvider = Provider<bool>((ref) {

View File

@@ -8,6 +8,7 @@ import '../../features/auth/providers/unified_auth_providers.dart';
import '../services/navigation_service.dart';
import '../models/conversation.dart';
import '../services/background_streaming_handler.dart';
import '../services/persistent_streaming_service.dart';
import '../../features/onboarding/views/onboarding_sheet.dart';
import '../../shared/theme/theme_extensions.dart';
import '../services/connectivity_service.dart';
@@ -124,6 +125,10 @@ final appStartupFlowProvider = Provider<void>((ref) {
// Keep Socket.IO connection alive in background within platform limits
ref.watch(socketPersistenceProvider);
// Ensure persistent streaming uses the shared connectivity service
final connectivityService = ref.watch(connectivityServiceProvider);
PersistentStreamingService().attachConnectivityService(connectivityService);
// Warm the conversations list in the background as soon as possible
Future.microtask(() => _scheduleConversationWarmup(ref));