refactor: 重构聊天数据层至core并简化首页UI
This commit is contained in:
@@ -18,7 +18,9 @@ import '../../features/auth/data/repositories/auth_repository_impl.dart';
|
||||
import '../../features/auth/presentation/bloc/auth_bloc.dart';
|
||||
import '../../features/auth/presentation/bloc/auth_event.dart';
|
||||
import '../../features/chat/presentation/bloc/chat_bloc.dart';
|
||||
import '../../features/chat/data/repositories/chat_history_repository.dart';
|
||||
import '../../core/chat/chat_api.dart';
|
||||
import '../../core/chat/chat_history_repository.dart';
|
||||
import '../../features/chat/data/apis/chat_api_impl.dart';
|
||||
import '../../features/calendar/data/apis/calendar_api.dart';
|
||||
import '../../features/calendar/data/services/calendar_service.dart';
|
||||
import '../../shared/state/calendar_state_manager.dart';
|
||||
@@ -127,8 +129,11 @@ Future<void> configureDependencies() async {
|
||||
InboxRepositoryImpl(apiClient: apiClient, store: hybridCacheStore),
|
||||
);
|
||||
|
||||
final chatApi = ChatApiImpl(apiClient);
|
||||
sl.registerSingleton<ChatApi>(chatApi);
|
||||
|
||||
final chatHistoryRepository = ChatHistoryRepository(
|
||||
apiClient: apiClient,
|
||||
chatApi: chatApi,
|
||||
store: hybridCacheStore,
|
||||
);
|
||||
sl.registerSingleton<ChatHistoryRepository>(chatHistoryRepository);
|
||||
@@ -167,7 +172,7 @@ Future<void> configureDependencies() async {
|
||||
sl.registerSingleton<AuthBloc>(authBloc);
|
||||
sl.registerSingleton<SessionController>(AuthSessionController(authBloc));
|
||||
sl.registerSingleton<ChatBloc>(
|
||||
ChatBloc(apiClient: apiClient, historyRepository: chatHistoryRepository),
|
||||
ChatBloc(chatApi: chatApi, historyRepository: chatHistoryRepository),
|
||||
);
|
||||
|
||||
apiClient.setRefreshCallback((token) async {
|
||||
|
||||
@@ -73,21 +73,12 @@ String? resolveAuthRedirect({
|
||||
final isProtected =
|
||||
isHomeRoute ||
|
||||
_protectedRoutes.any((route) => matchedLocation.startsWith(route));
|
||||
final prewarmStatus = prewarm?.status ?? AppPrewarmStatus.completed;
|
||||
final shouldBlockForPrewarm =
|
||||
isAuthenticated && prewarmStatus == AppPrewarmStatus.running;
|
||||
|
||||
if (shouldBlockForPrewarm && !isBootRoute) {
|
||||
return AppRoutes.authBoot;
|
||||
}
|
||||
final _ = prewarm;
|
||||
|
||||
if (isAuthChecking && !isBootRoute) {
|
||||
return AppRoutes.authBoot;
|
||||
}
|
||||
if (!isAuthChecking && isBootRoute) {
|
||||
if (shouldBlockForPrewarm) {
|
||||
return null;
|
||||
}
|
||||
return isAuthenticated ? AppRoutes.homeMain : AppRoutes.authLogin;
|
||||
}
|
||||
if (!isAuthenticated && isProtected) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../features/calendar/data/repositories/calendar_repository.dart';
|
||||
import '../../features/messages/data/repositories/inbox_repository.dart';
|
||||
import '../../features/chat/data/repositories/chat_history_repository.dart';
|
||||
import '../../core/chat/chat_history_repository.dart';
|
||||
|
||||
enum AppPrewarmStatus { idle, running, completed, timedOut, failed }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user