refactor(apps): 重构数据层目录结构并新增启动预热编排器
This commit is contained in:
+27
-1
@@ -14,6 +14,29 @@ This file governs `apps/**` (Flutter). Keep rules strict, short, and reusable.
|
||||
- `apps/lib/main.dart` is the only allowed root entry file.
|
||||
- Do not add new second-level directories under `apps/lib` without explicit approval.
|
||||
|
||||
## Module Responsibilities (Must)
|
||||
|
||||
- `app/`: app bootstrap, DI wiring, global lifecycle orchestration, router composition.
|
||||
- `core/`: cross-feature business primitives/protocols/orchestrators (no feature-specific page logic).
|
||||
- `data/`: shared infrastructure only (cache/network/storage/adapters), not feature business repositories/models.
|
||||
- `features/`: user-facing bounded feature modules with clear product ownership.
|
||||
- `shared/`: reusable UI widgets and presentation helpers without feature business orchestration.
|
||||
- Cross-cutting capabilities (e.g. notification orchestration, UI schema protocol) must live in `core/` + `shared/`, not under `features/`.
|
||||
|
||||
## Placement Rules (Must)
|
||||
|
||||
- Put code in `features/` only when it belongs to one bounded product capability/screen flow.
|
||||
- Put code in `core/` when it is cross-feature protocol, policy, or orchestration that does not belong to one feature.
|
||||
- Put reusable UI renderers in `shared/widgets/`; they must not contain feature-only business orchestration.
|
||||
- In feature data layers, use semantic subfolders: `data/apis/`, `data/repositories/`, `data/services/`, `data/models/`.
|
||||
- Avoid deep redundant nesting like `models/<same_name>/...`; prefer flat by concern.
|
||||
|
||||
## Shared Data Layer Boundary (Must)
|
||||
|
||||
- Do not place feature business repositories/models under `apps/lib/data/`.
|
||||
- Feature business repositories/models must live under each feature's `data/` tree.
|
||||
- `apps/lib/data/` is only for infrastructure abstractions and implementations (cache/network/storage), reusable by features.
|
||||
|
||||
## UI Design System (Must)
|
||||
|
||||
- **Semantic colors**: always use `Theme.of(context).colorScheme.*` (primary, surface, error, etc.). Never hardcode hex or `Colors.*`.
|
||||
@@ -66,7 +89,10 @@ This file governs `apps/**` (Flutter). Keep rules strict, short, and reusable.
|
||||
- Reads/writes that affect consistency must go through repository layer.
|
||||
- Cache keys and invalidation policy belong to repository, not UI/Bloc.
|
||||
- Shared cache infrastructure must live under `apps/lib/data/cache/`; feature modules must not duplicate low-level cache store logic.
|
||||
- Cross-feature data access must go through `apps/lib/data/repositories/`; do not import another feature's data implementation directly from UI/Bloc.
|
||||
- Shared cache infrastructure (`apps/lib/data/cache/`) must remain domain-agnostic: do not import `features/**` or business model DTOs there.
|
||||
- Domain object serialization/deserialization belongs to repository/feature layer via local mappers/codecs; do not centralize feature-specific codecs in shared cache layer.
|
||||
- Shared cache layer may only encode/decode primitives, collections, and cache metadata wrappers.
|
||||
- Cross-feature data access must go through app-level facade/usecase boundaries; do not import another feature's data implementation directly from UI/Bloc.
|
||||
- Repository instances should be resolved from DI singletons to reuse cache and avoid per-feature re-creation.
|
||||
|
||||
## Testing Policy
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>灵可析</string>
|
||||
<string>林小夕</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
@@ -15,7 +15,7 @@
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>灵可析</string>
|
||||
<string>林小夕</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
|
||||
+6
-65
@@ -1,21 +1,15 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'di/injection.dart';
|
||||
import '../data/models/reminder_payload.dart';
|
||||
import '../data/services/calendar_service.dart';
|
||||
import '../data/services/local_notification_service.dart';
|
||||
import '../data/services/reminder_notification_callbacks.dart';
|
||||
import '../core/l10n/l10n.dart';
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../features/auth/presentation/bloc/auth_bloc.dart';
|
||||
import '../features/auth/presentation/bloc/auth_event.dart';
|
||||
import '../features/auth/presentation/bloc/auth_state.dart';
|
||||
import '../features/notification/domain/models/reminder_action.dart';
|
||||
import '../features/notification/domain/services/reminder_action_executor.dart';
|
||||
import 'services/app_prewarm_orchestrator.dart';
|
||||
import 'router/app_router.dart';
|
||||
import '../core/theme/app_theme.dart';
|
||||
|
||||
@@ -29,7 +23,6 @@ class LinksyApp extends StatefulWidget {
|
||||
class _LinksyAppState extends State<LinksyApp> {
|
||||
late final AuthBloc _authBloc;
|
||||
late final GoRouter _router;
|
||||
String? _reminderBootstrapUserId;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -37,7 +30,6 @@ class _LinksyAppState extends State<LinksyApp> {
|
||||
_authBloc = sl<AuthBloc>();
|
||||
_authBloc.add(AuthStarted());
|
||||
_router = createAppRouter(_authBloc);
|
||||
unawaited(_bindNotificationResponseHandler());
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -52,13 +44,13 @@ class _LinksyAppState extends State<LinksyApp> {
|
||||
value: _authBloc,
|
||||
child: BlocListener<AuthBloc, AuthState>(
|
||||
listener: (context, state) {
|
||||
if (state is AuthAuthenticated &&
|
||||
state.user.id != _reminderBootstrapUserId) {
|
||||
_reminderBootstrapUserId = state.user.id;
|
||||
unawaited(_rebuildUpcomingReminders());
|
||||
if (state is AuthAuthenticated) {
|
||||
unawaited(
|
||||
sl<AppPrewarmOrchestrator>().ensureStartedFor(state.user.id),
|
||||
);
|
||||
}
|
||||
if (state is AuthUnauthenticated) {
|
||||
_reminderBootstrapUserId = null;
|
||||
sl<AppPrewarmOrchestrator>().reset();
|
||||
}
|
||||
},
|
||||
child: MaterialApp.router(
|
||||
@@ -79,55 +71,4 @@ class _LinksyAppState extends State<LinksyApp> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _rebuildUpcomingReminders() async {
|
||||
final now = DateTime.now();
|
||||
final start = now.subtract(const Duration(days: 90));
|
||||
final end = now.add(const Duration(days: 90));
|
||||
try {
|
||||
final events = await sl<CalendarService>().getEventsForRange(start, end);
|
||||
await sl<LocalNotificationService>().rebuildUpcomingReminders(events);
|
||||
} catch (error) {
|
||||
debugPrint('reminder bootstrap skipped: $error');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _bindNotificationResponseHandler() async {
|
||||
await ReminderNotificationCallbacks.bindResponseHandler((response) async {
|
||||
final payloadRaw = response.payload;
|
||||
if (payloadRaw == null || payloadRaw.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReminderPayload payload;
|
||||
try {
|
||||
payload = ReminderPayload.fromJson(
|
||||
Map<String, dynamic>.from(jsonDecode(payloadRaw) as Map),
|
||||
);
|
||||
} catch (_) {
|
||||
return;
|
||||
}
|
||||
|
||||
final actionId = response.actionId;
|
||||
ReminderAction? action;
|
||||
if (actionId != null) {
|
||||
try {
|
||||
action = ReminderAction.fromValue(actionId);
|
||||
} catch (_) {
|
||||
action = null;
|
||||
}
|
||||
}
|
||||
if (action == null) {
|
||||
ReminderNotificationCallbacks.onNotificationPayloadReceived?.call(
|
||||
payload,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await sl<ReminderActionExecutor>().handleAction(
|
||||
action: action,
|
||||
payload: payload,
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,42 +2,37 @@ import 'package:dio/dio.dart';
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import '../../data/cache/cache_invalidator.dart';
|
||||
import '../../data/cache/hybrid_cache_store.dart';
|
||||
import '../../data/cache/memory_cache_store.dart';
|
||||
import '../../data/cache/persistent_cache_store.dart';
|
||||
import '../../data/repositories/calendar_event_repository.dart';
|
||||
import '../../data/repositories/calendar_repository.dart';
|
||||
import '../../data/repositories/friend_repository.dart';
|
||||
import '../../data/repositories/inbox_repository.dart';
|
||||
import '../../data/repositories/user_repository.dart';
|
||||
import '../../data/cache/cache_store.dart';
|
||||
import '../../features/calendar/data/repositories/calendar_repository.dart';
|
||||
import '../../features/contacts/data/repositories/friend_repository.dart';
|
||||
import '../../features/messages/data/repositories/inbox_repository.dart';
|
||||
import '../../features/contacts/data/repositories/user_repository.dart';
|
||||
import '../../core/auth/session_controller.dart';
|
||||
import '../../core/network/api_client.dart';
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import '../../core/storage/app_preferences.dart';
|
||||
import '../../core/storage/token_storage.dart';
|
||||
import '../../data/network/api_client.dart';
|
||||
import '../../data/network/i_api_client.dart';
|
||||
import '../../data/storage/token_storage.dart';
|
||||
import '../../core/config/env.dart';
|
||||
import '../../data/services/local_notification_service.dart';
|
||||
import '../../features/auth/data/auth_api.dart';
|
||||
import '../../features/auth/data/auth_repository.dart';
|
||||
import '../../features/auth/data/auth_repository_impl.dart';
|
||||
import '../../features/auth/data/apis/auth_api.dart';
|
||||
import '../../features/auth/data/repositories/auth_repository.dart';
|
||||
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/calendar/data/calendar_api.dart';
|
||||
import '../../data/services/calendar_service.dart';
|
||||
import '../../features/notification/domain/services/reminder_action_executor.dart';
|
||||
import '../../features/chat/data/repositories/chat_history_repository.dart';
|
||||
import '../../features/calendar/data/apis/calendar_api.dart';
|
||||
import '../../features/calendar/data/services/calendar_service.dart';
|
||||
import '../../shared/state/calendar_state_manager.dart';
|
||||
import '../../features/contacts/data/friends_api.dart';
|
||||
import '../../features/messages/data/inbox_api.dart';
|
||||
import '../../features/settings/data/settings_api.dart';
|
||||
import '../../features/settings/data/services/automation_jobs_api.dart';
|
||||
import '../../features/settings/data/services/user_profile_cache_repository.dart';
|
||||
import '../../features/contacts/data/apis/friends_api.dart';
|
||||
import '../../features/messages/data/apis/inbox_api.dart';
|
||||
import '../../features/settings/data/apis/settings_api.dart';
|
||||
import '../../features/settings/data/apis/automation_jobs_api.dart';
|
||||
import '../../features/settings/data/repositories/user_profile_cache_repository.dart';
|
||||
import '../../features/settings/data/services/user_profile_service.dart';
|
||||
import '../../features/settings/data/services/memory_service.dart';
|
||||
import '../../features/contacts/data/users/users_api.dart';
|
||||
import '../../features/todo/data/todo_api.dart';
|
||||
import '../../features/todo/data/todo_repository.dart';
|
||||
import '../../features/contacts/data/apis/users_api.dart';
|
||||
import '../../features/todo/data/apis/todo_api.dart';
|
||||
import '../../features/todo/data/repositories/todo_repository.dart';
|
||||
import '../services/app_prewarm_orchestrator.dart';
|
||||
import '../services/auth_session_controller.dart';
|
||||
|
||||
final sl = GetIt.instance;
|
||||
@@ -71,10 +66,9 @@ Future<void> configureDependencies() async {
|
||||
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
sl.registerSingleton<SharedPreferences>(sharedPreferences);
|
||||
sl.registerSingleton<AppPreferences>(AppPreferences(sharedPreferences));
|
||||
|
||||
final memoryCacheStore = MemoryCacheStore();
|
||||
final persistentCacheStore = PersistentCacheStore();
|
||||
final persistentCacheStore = PersistentCacheStore(prefs: sharedPreferences);
|
||||
final hybridCacheStore = HybridCacheStore(
|
||||
memory: memoryCacheStore,
|
||||
persistent: persistentCacheStore,
|
||||
@@ -100,10 +94,6 @@ Future<void> configureDependencies() async {
|
||||
|
||||
final calendarApi = CalendarApi(apiClient);
|
||||
sl.registerSingleton<CalendarApi>(calendarApi);
|
||||
sl.registerSingleton<CalendarEventRepository>(
|
||||
CalendarEventRepositoryImpl(apiClient),
|
||||
);
|
||||
|
||||
final calendarService = CalendarService(
|
||||
apiClient: apiClient,
|
||||
invalidator: sl<CacheInvalidator>(),
|
||||
@@ -116,17 +106,11 @@ Future<void> configureDependencies() async {
|
||||
);
|
||||
sl.registerSingleton<CalendarRepository>(calendarRepository);
|
||||
|
||||
sl.registerSingleton<LocalNotificationService>(LocalNotificationService());
|
||||
|
||||
final reminderActionExecutor = ReminderActionExecutor(
|
||||
calendarService: calendarService,
|
||||
notificationService: sl<LocalNotificationService>(),
|
||||
);
|
||||
sl.registerSingleton<ReminderActionExecutor>(reminderActionExecutor);
|
||||
|
||||
final friendsApi = FriendsApi(apiClient);
|
||||
sl.registerSingleton<FriendsApi>(friendsApi);
|
||||
sl.registerSingleton<FriendRepository>(FriendRepositoryImpl(apiClient));
|
||||
sl.registerSingleton<FriendRepository>(
|
||||
FriendRepositoryImpl(apiClient: apiClient, store: hybridCacheStore),
|
||||
);
|
||||
|
||||
final settingsApi = SettingsApi(apiClient);
|
||||
sl.registerSingleton<SettingsApi>(settingsApi);
|
||||
@@ -139,7 +123,15 @@ Future<void> configureDependencies() async {
|
||||
|
||||
final inboxApi = InboxApi(apiClient);
|
||||
sl.registerSingleton<InboxApi>(inboxApi);
|
||||
sl.registerSingleton<InboxRepository>(InboxRepositoryImpl(apiClient));
|
||||
sl.registerSingleton<InboxRepository>(
|
||||
InboxRepositoryImpl(apiClient: apiClient, store: hybridCacheStore),
|
||||
);
|
||||
|
||||
final chatHistoryRepository = ChatHistoryRepository(
|
||||
apiClient: apiClient,
|
||||
store: hybridCacheStore,
|
||||
);
|
||||
sl.registerSingleton<ChatHistoryRepository>(chatHistoryRepository);
|
||||
|
||||
final todoApi = TodoApi(apiClient);
|
||||
sl.registerSingleton<TodoApi>(todoApi);
|
||||
@@ -163,10 +155,20 @@ Future<void> configureDependencies() async {
|
||||
);
|
||||
sl.registerSingleton<AuthRepository>(authRepository);
|
||||
|
||||
sl.registerSingleton<AppPrewarmOrchestrator>(
|
||||
AppPrewarmOrchestrator(
|
||||
calendarRepository: calendarRepository,
|
||||
inboxRepository: sl<InboxRepository>(),
|
||||
chatHistoryRepository: chatHistoryRepository,
|
||||
),
|
||||
);
|
||||
|
||||
final authBloc = AuthBloc(authRepository);
|
||||
sl.registerSingleton<AuthBloc>(authBloc);
|
||||
sl.registerSingleton<SessionController>(AuthSessionController(authBloc));
|
||||
sl.registerSingleton<ChatBloc>(ChatBloc(apiClient: apiClient));
|
||||
sl.registerSingleton<ChatBloc>(
|
||||
ChatBloc(apiClient: apiClient, historyRepository: chatHistoryRepository),
|
||||
);
|
||||
|
||||
apiClient.setRefreshCallback((token) async {
|
||||
try {
|
||||
|
||||
@@ -34,6 +34,7 @@ import '../../../features/settings/presentation/screens/work_memory_view_screen.
|
||||
import '../../../features/settings/presentation/screens/user_memory_detail_screen.dart';
|
||||
import '../../../features/settings/presentation/screens/work_memory_detail_screen.dart';
|
||||
import '../../../features/settings/presentation/screens/edit_profile_screen.dart';
|
||||
import '../services/app_prewarm_orchestrator.dart';
|
||||
|
||||
final _homeSecondLevelRoutes = [
|
||||
AppRoutes.shellCalendarBranch,
|
||||
@@ -60,6 +61,7 @@ final _protectedRoutes = [
|
||||
String? resolveAuthRedirect({
|
||||
required AuthState authState,
|
||||
required String matchedLocation,
|
||||
AppPrewarmOrchestrator? prewarm,
|
||||
}) {
|
||||
final isAuthenticated = authState is AuthAuthenticated;
|
||||
final isAuthChecking = authState is AuthInitial || authState is AuthLoading;
|
||||
@@ -71,11 +73,21 @@ 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;
|
||||
}
|
||||
|
||||
if (isAuthChecking && !isBootRoute) {
|
||||
return AppRoutes.authBoot;
|
||||
}
|
||||
if (!isAuthChecking && isBootRoute) {
|
||||
if (shouldBlockForPrewarm) {
|
||||
return null;
|
||||
}
|
||||
return isAuthenticated ? AppRoutes.homeMain : AppRoutes.authLogin;
|
||||
}
|
||||
if (!isAuthenticated && isProtected) {
|
||||
@@ -95,14 +107,17 @@ Widget buildHomeRouteScreen() {
|
||||
}
|
||||
|
||||
GoRouter createAppRouter(AuthBloc authBloc) {
|
||||
final authRefresh = GoRouterRefreshStream(authBloc.stream);
|
||||
final prewarm = sl<AppPrewarmOrchestrator>();
|
||||
return GoRouter(
|
||||
initialLocation: AppRoutes.authBoot,
|
||||
observers: [appRouteObserver],
|
||||
refreshListenable: GoRouterRefreshStream(authBloc.stream),
|
||||
refreshListenable: Listenable.merge([authRefresh, prewarm]),
|
||||
redirect: (context, state) {
|
||||
return resolveAuthRedirect(
|
||||
authState: authBloc.state,
|
||||
matchedLocation: state.matchedLocation,
|
||||
prewarm: prewarm,
|
||||
);
|
||||
},
|
||||
routes: [
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
import 'dart:async';
|
||||
|
||||
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';
|
||||
|
||||
enum AppPrewarmStatus { idle, running, completed, timedOut, failed }
|
||||
|
||||
class AppPrewarmOrchestrator extends ChangeNotifier {
|
||||
AppPrewarmOrchestrator({
|
||||
required CalendarRepository calendarRepository,
|
||||
required InboxRepository inboxRepository,
|
||||
required ChatHistoryRepository chatHistoryRepository,
|
||||
this.bootBudget = const Duration(milliseconds: 1200),
|
||||
Future<void> Function()? prewarmChatHistory,
|
||||
Future<void> Function()? prewarmCalendarToday,
|
||||
Future<void> Function()? prewarmUnreadInbox,
|
||||
}) : _calendarRepository = calendarRepository,
|
||||
_inboxRepository = inboxRepository,
|
||||
_chatHistoryRepository = chatHistoryRepository,
|
||||
_prewarmChatHistory = prewarmChatHistory,
|
||||
_prewarmCalendarToday = prewarmCalendarToday,
|
||||
_prewarmUnreadInbox = prewarmUnreadInbox;
|
||||
|
||||
final CalendarRepository _calendarRepository;
|
||||
final InboxRepository _inboxRepository;
|
||||
final ChatHistoryRepository _chatHistoryRepository;
|
||||
final Duration bootBudget;
|
||||
final Future<void> Function()? _prewarmChatHistory;
|
||||
final Future<void> Function()? _prewarmCalendarToday;
|
||||
final Future<void> Function()? _prewarmUnreadInbox;
|
||||
|
||||
AppPrewarmStatus _status = AppPrewarmStatus.idle;
|
||||
AppPrewarmStatus get status => _status;
|
||||
|
||||
String? _userId;
|
||||
Future<void>? _running;
|
||||
|
||||
bool get isBootBlocking => _status == AppPrewarmStatus.running;
|
||||
|
||||
Future<void> ensureStartedFor(String userId) {
|
||||
if (_userId == userId &&
|
||||
(_status == AppPrewarmStatus.completed ||
|
||||
_status == AppPrewarmStatus.timedOut)) {
|
||||
return Future<void>.value();
|
||||
}
|
||||
if (_userId == userId && _running != null) {
|
||||
return _running!;
|
||||
}
|
||||
|
||||
_userId = userId;
|
||||
_status = AppPrewarmStatus.running;
|
||||
notifyListeners();
|
||||
|
||||
final tasks = Future.wait<void>([
|
||||
_runPrewarmChatHistory(),
|
||||
_runPrewarmCalendarToday(),
|
||||
_runPrewarmUnreadInbox(),
|
||||
]);
|
||||
|
||||
final running = _runWithBudget(tasks);
|
||||
_running = running;
|
||||
return running.whenComplete(() {
|
||||
if (identical(_running, running)) {
|
||||
_running = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _runPrewarmChatHistory() {
|
||||
final override = _prewarmChatHistory;
|
||||
if (override != null) {
|
||||
return override();
|
||||
}
|
||||
return _chatHistoryRepository.loadHistory();
|
||||
}
|
||||
|
||||
Future<void> _runPrewarmCalendarToday() {
|
||||
final override = _prewarmCalendarToday;
|
||||
if (override != null) {
|
||||
return override();
|
||||
}
|
||||
return _calendarRepository.getDayEvents(DateTime.now());
|
||||
}
|
||||
|
||||
Future<void> _runPrewarmUnreadInbox() {
|
||||
final override = _prewarmUnreadInbox;
|
||||
if (override != null) {
|
||||
return override();
|
||||
}
|
||||
return _inboxRepository.getMessages(isRead: false);
|
||||
}
|
||||
|
||||
Future<void> _runWithBudget(Future<void> tasks) async {
|
||||
try {
|
||||
await tasks.timeout(bootBudget);
|
||||
_status = AppPrewarmStatus.completed;
|
||||
notifyListeners();
|
||||
} on TimeoutException {
|
||||
_status = AppPrewarmStatus.timedOut;
|
||||
notifyListeners();
|
||||
} catch (_) {
|
||||
_status = AppPrewarmStatus.failed;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
void reset() {
|
||||
_userId = null;
|
||||
_running = null;
|
||||
if (_status != AppPrewarmStatus.idle) {
|
||||
_status = AppPrewarmStatus.idle;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import '../../../../data/models/reminder_payload.dart';
|
||||
import '../models/reminder_payload.dart';
|
||||
|
||||
class ReminderQueueManager {
|
||||
ReminderPayload? _currentPayload;
|
||||
@@ -1,97 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../data/models/reminder_payload.dart';
|
||||
|
||||
class AppPreferences {
|
||||
static const String _pendingNotificationsKey =
|
||||
'calendar_reminder_pending_notification_responses_v1';
|
||||
static const String _pendingNotificationPayloadKey =
|
||||
'pending_notification_payload';
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
AppPreferences(this._prefs);
|
||||
|
||||
List<PendingNotificationResponse> get pendingNotifications {
|
||||
final list = _prefs.getStringList(_pendingNotificationsKey) ?? [];
|
||||
return list
|
||||
.map(_decodePendingNotification)
|
||||
.whereType<PendingNotificationResponse>()
|
||||
.toList();
|
||||
}
|
||||
|
||||
Future<void> setPendingNotifications(
|
||||
List<PendingNotificationResponse> value,
|
||||
) {
|
||||
return _prefs.setStringList(
|
||||
_pendingNotificationsKey,
|
||||
value.map(_encodePendingNotification).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> clearPendingNotifications() {
|
||||
return _prefs.remove(_pendingNotificationsKey);
|
||||
}
|
||||
|
||||
ReminderPayload? get pendingNotificationPayload {
|
||||
final raw = _prefs.getString(_pendingNotificationPayloadKey);
|
||||
if (raw == null || raw.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
final json = Map<String, dynamic>.from(jsonDecode(raw) as Map);
|
||||
return ReminderPayload.fromJson(json);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setPendingNotificationPayload(ReminderPayload payload) {
|
||||
return _prefs.setString(
|
||||
_pendingNotificationPayloadKey,
|
||||
jsonEncode(payload.toJson()),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> clearPendingNotificationPayload() {
|
||||
return _prefs.remove(_pendingNotificationPayloadKey);
|
||||
}
|
||||
|
||||
static String _encodePendingNotification(
|
||||
PendingNotificationResponse response,
|
||||
) {
|
||||
return jsonEncode({
|
||||
'id': response.id,
|
||||
'actionId': response.actionId,
|
||||
'payload': response.payload,
|
||||
'type': response.notificationResponseType.index,
|
||||
'input': response.input,
|
||||
});
|
||||
}
|
||||
|
||||
static PendingNotificationResponse? _decodePendingNotification(String raw) {
|
||||
try {
|
||||
final parsed = Map<String, dynamic>.from(jsonDecode(raw) as Map);
|
||||
final id = parsed['id'] as int?;
|
||||
final actionId = parsed['actionId'] as String?;
|
||||
final payload = parsed['payload'] as String?;
|
||||
final typeIndex = (parsed['type'] as int?) ?? 0;
|
||||
final input = parsed['input'] as String?;
|
||||
final type = NotificationResponseType.values[typeIndex.clamp(0, 1)];
|
||||
return NotificationResponse(
|
||||
id: id,
|
||||
actionId: actionId,
|
||||
payload: payload,
|
||||
input: input,
|
||||
notificationResponseType: type,
|
||||
);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
typedef PendingNotificationResponse = NotificationResponse;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
part of '../ui_schema.dart';
|
||||
part of 'ui_schema.dart';
|
||||
|
||||
abstract class ActionSpec {
|
||||
String get type;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
part of '../ui_schema.dart';
|
||||
part of 'ui_schema.dart';
|
||||
|
||||
UiSchemaDocument buildSuccessDocument(
|
||||
List<UiNode> nodes, {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
part of '../ui_schema.dart';
|
||||
part of 'ui_schema.dart';
|
||||
|
||||
class UiIcon {
|
||||
final IconSource source;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
part of '../ui_schema.dart';
|
||||
part of 'ui_schema.dart';
|
||||
|
||||
class RendererConfig {
|
||||
final String? renderer;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
part of '../ui_schema.dart';
|
||||
part of 'ui_schema.dart';
|
||||
|
||||
enum SchemaType {
|
||||
toolResult('tool_result'),
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
part of '../ui_schema.dart';
|
||||
part of 'ui_schema.dart';
|
||||
|
||||
abstract class UiNode {
|
||||
String get type;
|
||||
+6
-6
@@ -6,9 +6,9 @@
|
||||
/// Version: 1.0
|
||||
library;
|
||||
|
||||
part 'ui_schema/enums.dart';
|
||||
part 'ui_schema/common_types.dart';
|
||||
part 'ui_schema/actions.dart';
|
||||
part 'ui_schema/nodes.dart';
|
||||
part 'ui_schema/document.dart';
|
||||
part 'ui_schema/builders.dart';
|
||||
part 'enums.dart';
|
||||
part 'common_types.dart';
|
||||
part 'actions.dart';
|
||||
part 'nodes.dart';
|
||||
part 'document.dart';
|
||||
part 'builders.dart';
|
||||
Vendored
-6
@@ -1,6 +0,0 @@
|
||||
class CacheEntry<T> {
|
||||
final T value;
|
||||
final DateTime fetchedAt;
|
||||
|
||||
const CacheEntry({required this.value, required this.fetchedAt});
|
||||
}
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'hybrid_cache_store.dart';
|
||||
|
||||
class CacheInvalidator {
|
||||
final HybridCacheStore? _store;
|
||||
final Set<String> _invalidated = <String>{};
|
||||
|
||||
CacheInvalidator({HybridCacheStore? store}) : _store = store;
|
||||
|
||||
void invalidate(String key) {
|
||||
_invalidated.add(key);
|
||||
final store = _store;
|
||||
if (store != null) {
|
||||
unawaited(store.remove(key));
|
||||
}
|
||||
}
|
||||
|
||||
void invalidateCalendarDay(DateTime date) {
|
||||
final month = '${date.year}-${date.month.toString().padLeft(2, '0')}';
|
||||
final day = '$month-${date.day.toString().padLeft(2, '0')}';
|
||||
invalidate('calendar:day:$day');
|
||||
invalidate('calendar:month:$month');
|
||||
}
|
||||
|
||||
bool wasInvalidated(String key) => _invalidated.contains(key);
|
||||
}
|
||||
Vendored
+337
@@ -1,5 +1,342 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class CacheEntry<T> {
|
||||
const CacheEntry({required this.value, required this.fetchedAt});
|
||||
|
||||
final T value;
|
||||
final DateTime fetchedAt;
|
||||
}
|
||||
|
||||
abstract class CacheStore {
|
||||
Future<T?> read<T>(String key);
|
||||
Future<void> write<T>(String key, T value);
|
||||
Future<void> remove(String key);
|
||||
}
|
||||
|
||||
class MemoryCacheStore implements CacheStore {
|
||||
final Map<String, Object?> _values = <String, Object?>{};
|
||||
|
||||
@override
|
||||
Future<T?> read<T>(String key) async {
|
||||
final value = _values[key];
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
_values[key] = value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String key) async {
|
||||
_values.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
class SharedPrefsCacheStore implements CacheStore {
|
||||
SharedPrefsCacheStore({required SharedPreferences prefs}) : _prefs = prefs;
|
||||
|
||||
final SharedPreferences _prefs;
|
||||
|
||||
@override
|
||||
Future<T?> read<T>(String key) async {
|
||||
final raw = _prefs.getString(key);
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return CacheCodec.decode<T>(raw);
|
||||
} catch (_) {
|
||||
await _prefs.remove(key);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
final encoded = CacheCodec.encode<T>(value);
|
||||
await _prefs.setString(key, encoded);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String key) {
|
||||
return _prefs.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
class PersistentCacheStore implements CacheStore {
|
||||
SharedPreferences? _prefs;
|
||||
Future<SharedPreferences>? _prefsFuture;
|
||||
final Map<String, Object?> _fallbackValues = <String, Object?>{};
|
||||
|
||||
PersistentCacheStore({SharedPreferences? prefs}) : _prefs = prefs;
|
||||
|
||||
Future<SharedPreferences?> _getPrefs() {
|
||||
if (_prefs != null) {
|
||||
return Future<SharedPreferences?>.value(_prefs);
|
||||
}
|
||||
final inFlight = _prefsFuture;
|
||||
if (inFlight != null) {
|
||||
return inFlight.then<SharedPreferences?>((prefs) => prefs);
|
||||
}
|
||||
final created = SharedPreferences.getInstance();
|
||||
_prefsFuture = created;
|
||||
return created
|
||||
.then<SharedPreferences?>((prefs) {
|
||||
_prefs = prefs;
|
||||
return prefs;
|
||||
})
|
||||
.catchError((_) {
|
||||
_prefsFuture = null;
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<T?> read<T>(String key) async {
|
||||
final prefs = await _getPrefs();
|
||||
if (prefs == null) {
|
||||
final value = _fallbackValues[key];
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
final store = SharedPrefsCacheStore(prefs: prefs);
|
||||
return store.read<T>(key);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
final prefs = await _getPrefs();
|
||||
if (prefs == null) {
|
||||
_fallbackValues[key] = value;
|
||||
return;
|
||||
}
|
||||
final store = SharedPrefsCacheStore(prefs: prefs);
|
||||
await store.write<T>(key, value);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String key) async {
|
||||
final prefs = await _getPrefs();
|
||||
if (prefs == null) {
|
||||
_fallbackValues.remove(key);
|
||||
return;
|
||||
}
|
||||
final store = SharedPrefsCacheStore(prefs: prefs);
|
||||
await store.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
class HybridCacheStore {
|
||||
final CacheStore memory;
|
||||
final CacheStore persistent;
|
||||
final Map<String, Future<dynamic>> _inflight = <String, Future<dynamic>>{};
|
||||
|
||||
HybridCacheStore({required this.memory, required this.persistent});
|
||||
|
||||
Future<T?> read<T>(String key) async {
|
||||
final memoryValue = await memory.read<T>(key);
|
||||
if (memoryValue != null) {
|
||||
return memoryValue;
|
||||
}
|
||||
final persistentValue = await persistent.read<T>(key);
|
||||
if (persistentValue != null) {
|
||||
await memory.write(key, persistentValue);
|
||||
}
|
||||
return persistentValue;
|
||||
}
|
||||
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
await memory.write<T>(key, value);
|
||||
await persistent.write<T>(key, value);
|
||||
}
|
||||
|
||||
Future<void> remove(String key) async {
|
||||
await memory.remove(key);
|
||||
await persistent.remove(key);
|
||||
}
|
||||
|
||||
Future<T> getOrLoad<T>(String key, {required Future<T> Function() loader}) {
|
||||
final running = _inflight[key];
|
||||
if (running != null) {
|
||||
return running.then((value) => value as T);
|
||||
}
|
||||
|
||||
final future = () async {
|
||||
final cached = await read<T>(key);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
final loaded = await loader();
|
||||
await write<T>(key, loaded);
|
||||
return loaded;
|
||||
}();
|
||||
|
||||
_inflight[key] = future;
|
||||
return future.whenComplete(() {
|
||||
_inflight.remove(key);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class CacheInvalidator {
|
||||
final HybridCacheStore? _store;
|
||||
|
||||
CacheInvalidator({HybridCacheStore? store}) : _store = store;
|
||||
|
||||
void invalidate(String key) {
|
||||
final store = _store;
|
||||
if (store != null) {
|
||||
unawaited(store.remove(key));
|
||||
}
|
||||
}
|
||||
|
||||
void invalidateCalendarDay(DateTime date) {
|
||||
final month = '${date.year}-${date.month.toString().padLeft(2, '0')}';
|
||||
final day = '$month-${date.day.toString().padLeft(2, '0')}';
|
||||
invalidate('calendar:day:$day');
|
||||
invalidate('calendar:month:$month');
|
||||
}
|
||||
}
|
||||
|
||||
class CacheCodec {
|
||||
static String encode<T>(T value) {
|
||||
final payload = <String, Object?>{'type': '$T'};
|
||||
if (value is CacheEntry) {
|
||||
payload['entryType'] = '${value.value.runtimeType}';
|
||||
payload['fetchedAt'] = value.fetchedAt.toIso8601String();
|
||||
payload['value'] = _encodeValue(value.value);
|
||||
} else {
|
||||
payload['value'] = _encodeValue(value);
|
||||
}
|
||||
return jsonEncode(payload);
|
||||
}
|
||||
|
||||
static T decode<T>(String raw) {
|
||||
final decoded = jsonDecode(raw);
|
||||
if (decoded is! Map<String, dynamic>) {
|
||||
throw const FormatException('Invalid cache payload');
|
||||
}
|
||||
|
||||
final value = decoded['value'];
|
||||
|
||||
if (T.toString().startsWith('CacheEntry<')) {
|
||||
final fetchedAtRaw = decoded['fetchedAt'];
|
||||
final fetchedAt = DateTime.parse(fetchedAtRaw as String);
|
||||
final entryType = (decoded['entryType'] as String?) ?? 'Object?';
|
||||
final decodedValue = _decodeValue(entryType, value);
|
||||
|
||||
switch (entryType) {
|
||||
case 'String':
|
||||
return CacheEntry<String>(
|
||||
value: decodedValue as String,
|
||||
fetchedAt: fetchedAt,
|
||||
)
|
||||
as T;
|
||||
case 'int':
|
||||
return CacheEntry<int>(
|
||||
value: decodedValue as int,
|
||||
fetchedAt: fetchedAt,
|
||||
)
|
||||
as T;
|
||||
case 'double':
|
||||
return CacheEntry<double>(
|
||||
value: decodedValue as double,
|
||||
fetchedAt: fetchedAt,
|
||||
)
|
||||
as T;
|
||||
case 'bool':
|
||||
return CacheEntry<bool>(
|
||||
value: decodedValue as bool,
|
||||
fetchedAt: fetchedAt,
|
||||
)
|
||||
as T;
|
||||
default:
|
||||
return CacheEntry<Object?>(value: decodedValue, fetchedAt: fetchedAt)
|
||||
as T;
|
||||
}
|
||||
}
|
||||
|
||||
final type = (decoded['type'] as String?) ?? '$T';
|
||||
return _decodeValue(type, value) as T;
|
||||
}
|
||||
|
||||
static Object? _encodeValue(Object? value) {
|
||||
if (value == null || value is String || value is num || value is bool) {
|
||||
return value;
|
||||
}
|
||||
if (value is DateTime) {
|
||||
return value.toIso8601String();
|
||||
}
|
||||
if (value is List) {
|
||||
return value.map(_encodeValue).toList();
|
||||
}
|
||||
if (value is Map) {
|
||||
return value.map((k, v) => MapEntry(k.toString(), _encodeValue(v)));
|
||||
}
|
||||
|
||||
throw StateError('Unsupported cached value type: ${value.runtimeType}');
|
||||
}
|
||||
|
||||
static Object? _decodeValue(String type, Object? raw) {
|
||||
switch (type) {
|
||||
case 'String':
|
||||
return raw as String? ?? '';
|
||||
case 'int':
|
||||
if (raw is int) {
|
||||
return raw;
|
||||
}
|
||||
if (raw is num) {
|
||||
return raw.toInt();
|
||||
}
|
||||
throw const FormatException('Invalid int cache payload');
|
||||
case 'double':
|
||||
if (raw is double) {
|
||||
return raw;
|
||||
}
|
||||
if (raw is num) {
|
||||
return raw.toDouble();
|
||||
}
|
||||
throw const FormatException('Invalid double cache payload');
|
||||
case 'bool':
|
||||
return raw as bool? ?? false;
|
||||
case 'DateTime':
|
||||
return DateTime.parse(raw as String);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
final listType = _extractListType(type);
|
||||
if (listType != null) {
|
||||
if (raw is! List) {
|
||||
throw FormatException('Invalid list cache payload for type $type');
|
||||
}
|
||||
return raw
|
||||
.map((item) => _decodeValue(listType, item))
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
if (raw is Map) {
|
||||
return Map<String, dynamic>.from(raw);
|
||||
}
|
||||
|
||||
return raw;
|
||||
}
|
||||
|
||||
static String? _extractListType(String type) {
|
||||
final listMatch = RegExp(r'^List<(.+)>$').firstMatch(type);
|
||||
if (listMatch == null) {
|
||||
return null;
|
||||
}
|
||||
return listMatch.group(1);
|
||||
}
|
||||
}
|
||||
|
||||
+31
-6
@@ -1,20 +1,29 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'cache_entry.dart';
|
||||
import 'cache_policy.dart';
|
||||
import 'hybrid_cache_store.dart';
|
||||
import 'cache_store.dart';
|
||||
|
||||
abstract class CachedRepository<T> {
|
||||
final HybridCacheStore store;
|
||||
final CachePolicy policy;
|
||||
final DateTime Function() now;
|
||||
final Object? Function(T value) encodeValue;
|
||||
final T Function(Object? raw) decodeValue;
|
||||
final Map<String, Future<void>> _refreshInFlight = <String, Future<void>>{};
|
||||
|
||||
CachedRepository({
|
||||
required this.store,
|
||||
required this.policy,
|
||||
DateTime Function()? now,
|
||||
}) : now = now ?? DateTime.now;
|
||||
Object? Function(T value)? encodeValue,
|
||||
T Function(Object? raw)? decodeValue,
|
||||
}) : now = now ?? DateTime.now,
|
||||
encodeValue = encodeValue ?? _defaultEncode,
|
||||
decodeValue = decodeValue ?? _defaultDecode;
|
||||
|
||||
static Object? _defaultEncode<T>(T value) => value;
|
||||
|
||||
static T _defaultDecode<T>(Object? raw) => raw as T;
|
||||
|
||||
Future<T> getOrLoad({
|
||||
required String key,
|
||||
@@ -58,16 +67,32 @@ abstract class CachedRepository<T> {
|
||||
}
|
||||
|
||||
Future<CacheEntry<T>?> readCacheEntry(String key) {
|
||||
return store.read<CacheEntry<T>>(key);
|
||||
return _readDecodedEntry(key);
|
||||
}
|
||||
|
||||
Future<void> writeCacheEntry(String key, T value) {
|
||||
return store.write<CacheEntry<T>>(
|
||||
return store.write<CacheEntry<Object?>>(
|
||||
key,
|
||||
CacheEntry<T>(value: value, fetchedAt: now()),
|
||||
CacheEntry<Object?>(value: encodeValue(value), fetchedAt: now()),
|
||||
);
|
||||
}
|
||||
|
||||
Future<CacheEntry<T>?> _readDecodedEntry(String key) async {
|
||||
final entry = await store.read<CacheEntry<Object?>>(key);
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return CacheEntry<T>(
|
||||
value: decodeValue(entry.value),
|
||||
fetchedAt: entry.fetchedAt,
|
||||
);
|
||||
} catch (_) {
|
||||
await store.remove(key);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> removeCacheKey(String key) {
|
||||
return store.remove(key);
|
||||
}
|
||||
|
||||
-55
@@ -1,55 +0,0 @@
|
||||
import 'memory_cache_store.dart';
|
||||
import 'persistent_cache_store.dart';
|
||||
|
||||
class HybridCacheStore {
|
||||
final MemoryCacheStore memory;
|
||||
final PersistentCacheStore persistent;
|
||||
final Map<String, Future<dynamic>> _inflight = <String, Future<dynamic>>{};
|
||||
|
||||
HybridCacheStore({required this.memory, required this.persistent});
|
||||
|
||||
Future<T?> read<T>(String key) async {
|
||||
final memoryValue = await memory.read<T>(key);
|
||||
if (memoryValue != null) {
|
||||
return memoryValue;
|
||||
}
|
||||
final persistentValue = await persistent.read<T>(key);
|
||||
if (persistentValue != null) {
|
||||
await memory.write(key, persistentValue);
|
||||
}
|
||||
return persistentValue;
|
||||
}
|
||||
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
await memory.write<T>(key, value);
|
||||
await persistent.write<T>(key, value);
|
||||
}
|
||||
|
||||
Future<void> remove(String key) async {
|
||||
await memory.remove(key);
|
||||
await persistent.remove(key);
|
||||
}
|
||||
|
||||
Future<T> getOrLoad<T>(String key, {required Future<T> Function() loader}) {
|
||||
final running = _inflight[key];
|
||||
if (running != null) {
|
||||
return running.then((value) => value as T);
|
||||
}
|
||||
|
||||
final future = () async {
|
||||
final cached = await read<T>(key);
|
||||
if (cached != null) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
final loaded = await loader();
|
||||
await write<T>(key, loaded);
|
||||
return loaded;
|
||||
}();
|
||||
|
||||
_inflight[key] = future;
|
||||
return future.whenComplete(() {
|
||||
_inflight.remove(key);
|
||||
});
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
import 'cache_store.dart';
|
||||
|
||||
class MemoryCacheStore implements CacheStore {
|
||||
final Map<String, Object?> _values = <String, Object?>{};
|
||||
|
||||
@override
|
||||
Future<T?> read<T>(String key) async {
|
||||
final value = _values[key];
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
_values[key] = value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String key) async {
|
||||
_values.remove(key);
|
||||
}
|
||||
}
|
||||
-24
@@ -1,24 +0,0 @@
|
||||
import 'cache_store.dart';
|
||||
|
||||
class PersistentCacheStore implements CacheStore {
|
||||
final Map<String, Object?> _values = <String, Object?>{};
|
||||
|
||||
@override
|
||||
Future<T?> read<T>(String key) async {
|
||||
final value = _values[key];
|
||||
if (value is T) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> write<T>(String key, T value) async {
|
||||
_values[key] = value;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> remove(String key) async {
|
||||
_values.remove(key);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import '../l10n/l10n.dart';
|
||||
import '../../core/l10n/l10n.dart';
|
||||
import 'error_code_mapper.dart';
|
||||
|
||||
abstract class ApiException implements Exception {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import '../l10n/l10n.dart';
|
||||
import '../../core/l10n/l10n.dart';
|
||||
|
||||
String? mapErrorCodeToL10nKey(
|
||||
String? errorCode, {
|
||||
@@ -1,60 +0,0 @@
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import 'models/calendar_event.dart';
|
||||
|
||||
abstract class CalendarEventRepository {
|
||||
Future<List<CalendarEvent>> listByRange({
|
||||
required DateTime startAt,
|
||||
required DateTime endAt,
|
||||
});
|
||||
|
||||
Future<CalendarEvent> getById(String id);
|
||||
Future<void> acceptSubscription(String itemId);
|
||||
Future<void> rejectSubscription(String itemId);
|
||||
}
|
||||
|
||||
class CalendarEventRepositoryImpl implements CalendarEventRepository {
|
||||
final IApiClient _apiClient;
|
||||
static const _prefix = '/api/v1/schedule-items';
|
||||
|
||||
CalendarEventRepositoryImpl(this._apiClient);
|
||||
|
||||
@override
|
||||
Future<List<CalendarEvent>> listByRange({
|
||||
required DateTime startAt,
|
||||
required DateTime endAt,
|
||||
}) async {
|
||||
final start = Uri.encodeQueryComponent(startAt.toUtc().toIso8601String());
|
||||
final end = Uri.encodeQueryComponent(endAt.toUtc().toIso8601String());
|
||||
final response = await _apiClient.get<List<dynamic>>(
|
||||
'$_prefix?start_at=$start&end_at=$end',
|
||||
);
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
throw StateError('Invalid listByRange response: empty payload');
|
||||
}
|
||||
return data
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(CalendarEvent.fromJson)
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<CalendarEvent> getById(String id) async {
|
||||
final response = await _apiClient.get<Map<String, dynamic>>('$_prefix/$id');
|
||||
final event = response.data;
|
||||
if (event == null) {
|
||||
throw StateError('Invalid getById response: empty payload');
|
||||
}
|
||||
return CalendarEvent.fromJson(event);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> acceptSubscription(String itemId) {
|
||||
return _apiClient.post<void>('$_prefix/$itemId/accept');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> rejectSubscription(String itemId) {
|
||||
return _apiClient.post<void>('$_prefix/$itemId/reject');
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import 'models/inbox_message.dart';
|
||||
|
||||
abstract class InboxRepository {
|
||||
Future<List<InboxMessage>> getMessages({bool? isRead});
|
||||
Future<InboxMessage> markAsRead(String messageId);
|
||||
}
|
||||
|
||||
class InboxRepositoryImpl implements InboxRepository {
|
||||
final IApiClient _apiClient;
|
||||
static const _prefix = '/api/v1/inbox/messages';
|
||||
|
||||
InboxRepositoryImpl(this._apiClient);
|
||||
|
||||
@override
|
||||
Future<List<InboxMessage>> getMessages({bool? isRead}) async {
|
||||
final queryParams = isRead != null ? '?is_read=$isRead' : '';
|
||||
final response = await _apiClient.get<List<dynamic>>(
|
||||
'$_prefix$queryParams',
|
||||
);
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
throw StateError('Invalid getMessages response: empty payload');
|
||||
}
|
||||
return data
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(InboxMessage.fromJson)
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InboxMessage> markAsRead(String messageId) async {
|
||||
final response = await _apiClient.patch<Map<String, dynamic>>(
|
||||
'$_prefix/$messageId/read',
|
||||
);
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
throw StateError('Invalid markAsRead response: empty payload');
|
||||
}
|
||||
return InboxMessage.fromJson(data);
|
||||
}
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
enum CalendarEventStatus { active, archived }
|
||||
|
||||
class CalendarEvent {
|
||||
final String id;
|
||||
final String title;
|
||||
final DateTime startAt;
|
||||
final DateTime? endAt;
|
||||
final CalendarEventStatus status;
|
||||
|
||||
const CalendarEvent({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.startAt,
|
||||
required this.endAt,
|
||||
required this.status,
|
||||
});
|
||||
|
||||
factory CalendarEvent.fromJson(Map<String, dynamic> json) {
|
||||
return CalendarEvent(
|
||||
id: json['id'] as String,
|
||||
title: json['title'] as String,
|
||||
startAt: DateTime.parse(json['start_at'] as String).toLocal(),
|
||||
endAt: json['end_at'] == null
|
||||
? null
|
||||
: DateTime.parse(json['end_at'] as String).toLocal(),
|
||||
status: _calendarEventStatusFromApi(json['status'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
CalendarEventStatus _calendarEventStatusFromApi(String raw) {
|
||||
switch (raw) {
|
||||
case 'active':
|
||||
return CalendarEventStatus.active;
|
||||
case 'archived':
|
||||
return CalendarEventStatus.archived;
|
||||
default:
|
||||
throw StateError('Unsupported calendar event status: $raw');
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import '../../core/storage/app_preferences.dart';
|
||||
import '../models/reminder_payload.dart';
|
||||
|
||||
class IOSNotificationPayloadBridge {
|
||||
final AppPreferences _prefs;
|
||||
|
||||
IOSNotificationPayloadBridge(this._prefs);
|
||||
|
||||
ReminderPayload? getPendingPayload() {
|
||||
return _prefs.pendingNotificationPayload;
|
||||
}
|
||||
|
||||
Future<void> setPendingPayload(ReminderPayload payload) {
|
||||
return _prefs.setPendingNotificationPayload(payload);
|
||||
}
|
||||
|
||||
Future<void> clearPendingPayload() {
|
||||
return _prefs.clearPendingNotificationPayload();
|
||||
}
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:timezone/data/latest.dart' as tz_data;
|
||||
import 'package:timezone/timezone.dart' as tz;
|
||||
|
||||
import '../../core/l10n/l10n.dart';
|
||||
import '../models/reminder_payload.dart';
|
||||
import '../repositories/models/schedule_item_model.dart';
|
||||
import 'reminder_notification_callbacks.dart';
|
||||
|
||||
class LocalNotificationService {
|
||||
final FlutterLocalNotificationsPlugin _plugin;
|
||||
bool _initialized = false;
|
||||
|
||||
LocalNotificationService({FlutterLocalNotificationsPlugin? plugin})
|
||||
: _plugin = plugin ?? FlutterLocalNotificationsPlugin();
|
||||
|
||||
Future<void> initialize() async {
|
||||
if (_initialized) {
|
||||
return;
|
||||
}
|
||||
tz_data.initializeTimeZones();
|
||||
|
||||
const android = AndroidInitializationSettings('@mipmap/ic_launcher');
|
||||
const ios = DarwinInitializationSettings(
|
||||
requestAlertPermission: false,
|
||||
requestBadgePermission: false,
|
||||
requestSoundPermission: false,
|
||||
);
|
||||
final settings = InitializationSettings(android: android, iOS: ios);
|
||||
|
||||
await _plugin.initialize(
|
||||
settings,
|
||||
onDidReceiveNotificationResponse:
|
||||
ReminderNotificationCallbacks.onForegroundResponse,
|
||||
onDidReceiveBackgroundNotificationResponse:
|
||||
reminderNotificationTapBackground,
|
||||
);
|
||||
|
||||
final androidImpl = _plugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
AndroidFlutterLocalNotificationsPlugin
|
||||
>();
|
||||
await androidImpl?.requestNotificationsPermission();
|
||||
await androidImpl?.requestExactAlarmsPermission();
|
||||
await androidImpl?.requestFullScreenIntentPermission();
|
||||
|
||||
final iosImpl = _plugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
IOSFlutterLocalNotificationsPlugin
|
||||
>();
|
||||
await iosImpl?.requestPermissions(alert: true, badge: true, sound: true);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
Future<void> upsertEventReminder(ScheduleItemModel event) async {
|
||||
await initialize();
|
||||
if (event.status != ScheduleStatus.active ||
|
||||
event.metadata?.reminderMinutes == null) {
|
||||
await cancelEventReminder(event.id);
|
||||
return;
|
||||
}
|
||||
|
||||
final now = DateTime.now();
|
||||
final reminderMinutes = event.metadata?.reminderMinutes ?? 0;
|
||||
final fireAt = event.startAt.subtract(Duration(minutes: reminderMinutes));
|
||||
if (fireAt.isBefore(now)) {
|
||||
await cancelEventReminder(event.id);
|
||||
return;
|
||||
}
|
||||
|
||||
await cancelEventReminder(event.id);
|
||||
await _scheduleRemindersFrom(event: event, firstFireAt: fireAt);
|
||||
}
|
||||
|
||||
Future<void> scheduleReminderAt(
|
||||
ScheduleItemModel event,
|
||||
DateTime fireAt,
|
||||
) async {
|
||||
await initialize();
|
||||
await cancelEventReminder(event.id);
|
||||
await _scheduleRemindersFrom(event: event, firstFireAt: fireAt);
|
||||
}
|
||||
|
||||
Future<void> cancelEventReminder(String eventId) async {
|
||||
await initialize();
|
||||
|
||||
final pending = await _plugin.pendingNotificationRequests();
|
||||
for (final request in pending) {
|
||||
final payload = _decodePayload(request.payload);
|
||||
if (payload == null) {
|
||||
continue;
|
||||
}
|
||||
if (payload.eventId == eventId ||
|
||||
payload.aggregateIds.contains(eventId)) {
|
||||
await _plugin.cancel(request.id);
|
||||
}
|
||||
}
|
||||
|
||||
await _plugin.cancel(_notificationIdForEvent(eventId));
|
||||
}
|
||||
|
||||
Future<void> rebuildUpcomingReminders(
|
||||
Iterable<ScheduleItemModel> events,
|
||||
) async {
|
||||
await initialize();
|
||||
for (final event in events) {
|
||||
await upsertEventReminder(event);
|
||||
}
|
||||
}
|
||||
|
||||
int _notificationIdForEvent(String eventId) {
|
||||
return eventId.hashCode & 0x7fffffff;
|
||||
}
|
||||
|
||||
int _notificationIdForEventCycle(
|
||||
String eventId,
|
||||
DateTime fireAt,
|
||||
ReminderPayloadMode mode,
|
||||
) {
|
||||
final cycleMinute =
|
||||
fireAt.millisecondsSinceEpoch ~/
|
||||
const Duration(minutes: 1).inMilliseconds;
|
||||
return '$eventId|$cycleMinute|${mode.value}'.hashCode & 0x7fffffff;
|
||||
}
|
||||
|
||||
Future<AndroidScheduleMode> _resolveAndroidScheduleMode() async {
|
||||
final androidImpl = _plugin
|
||||
.resolvePlatformSpecificImplementation<
|
||||
AndroidFlutterLocalNotificationsPlugin
|
||||
>();
|
||||
if (androidImpl == null) {
|
||||
return AndroidScheduleMode.exactAllowWhileIdle;
|
||||
}
|
||||
|
||||
final canScheduleExact =
|
||||
await androidImpl.canScheduleExactNotifications() ?? false;
|
||||
return canScheduleExact
|
||||
? AndroidScheduleMode.exactAllowWhileIdle
|
||||
: AndroidScheduleMode.inexactAllowWhileIdle;
|
||||
}
|
||||
|
||||
NotificationDetails _buildNotificationDetails(DateTime fireAt) {
|
||||
return NotificationDetails(
|
||||
android: AndroidNotificationDetails(
|
||||
'calendar_alarm_channel_v2',
|
||||
L10n.current.notificationChannelName,
|
||||
channelDescription: L10n.current.notificationChannelDescription,
|
||||
importance: Importance.max,
|
||||
priority: Priority.max,
|
||||
category: AndroidNotificationCategory.alarm,
|
||||
audioAttributesUsage: AudioAttributesUsage.alarm,
|
||||
fullScreenIntent: true,
|
||||
playSound: true,
|
||||
enableVibration: true,
|
||||
vibrationPattern: Int64List.fromList([0, 1000, 500, 1200]),
|
||||
timeoutAfter: 30000,
|
||||
autoCancel: true,
|
||||
groupKey: _getGroupKey(fireAt),
|
||||
),
|
||||
iOS: DarwinNotificationDetails(
|
||||
presentAlert: true,
|
||||
presentSound: true,
|
||||
presentBadge: true,
|
||||
threadIdentifier: _getThreadIdentifier(fireAt),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
String _getThreadIdentifier(DateTime fireAt) {
|
||||
final bucket =
|
||||
fireAt.millisecondsSinceEpoch ~/
|
||||
const Duration(minutes: 1).inMilliseconds;
|
||||
return 'calendar_reminder_$bucket';
|
||||
}
|
||||
|
||||
String _getGroupKey(DateTime fireAt) {
|
||||
final bucket =
|
||||
fireAt.millisecondsSinceEpoch ~/
|
||||
const Duration(minutes: 1).inMilliseconds;
|
||||
return 'com.socialapp.calendar.$bucket';
|
||||
}
|
||||
|
||||
Future<void> _scheduleSingleReminder({
|
||||
required ScheduleItemModel event,
|
||||
required DateTime fireAt,
|
||||
}) async {
|
||||
final notificationId = _notificationIdForEventCycle(
|
||||
event.id,
|
||||
fireAt,
|
||||
ReminderPayloadMode.single,
|
||||
);
|
||||
final payload = ReminderPayload(
|
||||
eventId: event.id,
|
||||
title: event.title,
|
||||
startAt: event.startAt,
|
||||
endAt: event.endAt,
|
||||
timezone: event.timezone,
|
||||
location: event.metadata?.location,
|
||||
notes: event.metadata?.notes,
|
||||
color: event.metadata?.color,
|
||||
mode: ReminderPayloadMode.single,
|
||||
fireTimeBucket:
|
||||
fireAt.millisecondsSinceEpoch ~/
|
||||
const Duration(minutes: 1).inMilliseconds,
|
||||
version: 1,
|
||||
);
|
||||
|
||||
final details = _buildNotificationDetails(fireAt);
|
||||
final scheduledAt = tz.TZDateTime.from(fireAt, tz.local);
|
||||
final mode = await _resolveAndroidScheduleMode();
|
||||
|
||||
try {
|
||||
await _plugin.zonedSchedule(
|
||||
notificationId,
|
||||
event.title,
|
||||
_buildReminderBody(event, event.metadata?.reminderMinutes ?? 0),
|
||||
scheduledAt,
|
||||
details,
|
||||
payload: jsonEncode(payload.toJson()),
|
||||
androidScheduleMode: mode,
|
||||
uiLocalNotificationDateInterpretation:
|
||||
UILocalNotificationDateInterpretation.absoluteTime,
|
||||
);
|
||||
} catch (_) {
|
||||
await _plugin.zonedSchedule(
|
||||
notificationId,
|
||||
event.title,
|
||||
_buildReminderBody(event, event.metadata?.reminderMinutes ?? 0),
|
||||
scheduledAt,
|
||||
details,
|
||||
payload: jsonEncode(payload.toJson()),
|
||||
androidScheduleMode: AndroidScheduleMode.inexactAllowWhileIdle,
|
||||
uiLocalNotificationDateInterpretation:
|
||||
UILocalNotificationDateInterpretation.absoluteTime,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _scheduleRemindersFrom({
|
||||
required ScheduleItemModel event,
|
||||
required DateTime firstFireAt,
|
||||
}) async {
|
||||
final endAt = event.endAt;
|
||||
var cursor = firstFireAt;
|
||||
if (endAt == null) {
|
||||
await _scheduleSingleReminder(event: event, fireAt: cursor);
|
||||
return;
|
||||
}
|
||||
|
||||
while (cursor.isBefore(endAt)) {
|
||||
await _scheduleSingleReminder(event: event, fireAt: cursor);
|
||||
cursor = cursor.add(const Duration(minutes: 10));
|
||||
}
|
||||
}
|
||||
|
||||
ReminderPayload? _decodePayload(String? raw) {
|
||||
if (raw == null || raw.isEmpty) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return ReminderPayload.fromJson(jsonDecode(raw) as Map<String, dynamic>);
|
||||
} catch (_) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
String _buildReminderBody(ScheduleItemModel event, int reminderMinutes) {
|
||||
final when = reminderMinutes == 0
|
||||
? L10n.current.notificationStartsNow
|
||||
: L10n.current.notificationStartsInMinutes(reminderMinutes);
|
||||
final location = event.metadata?.location;
|
||||
final notes = event.metadata?.notes;
|
||||
final buffer = StringBuffer(when);
|
||||
if (location != null && location.isNotEmpty) {
|
||||
buffer.write('\n${L10n.current.notificationLocation(location)}');
|
||||
}
|
||||
if (notes != null && notes.isNotEmpty) {
|
||||
final preview = notes.length > 30
|
||||
? '${notes.substring(0, 30)}...'
|
||||
: notes;
|
||||
buffer.write('\n${L10n.current.notificationNotes(preview)}');
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
Future<void> handleNotificationResponse(NotificationResponse response) async {
|
||||
final payloadRaw = response.payload;
|
||||
if (payloadRaw == null || payloadRaw.isEmpty) {
|
||||
return;
|
||||
}
|
||||
ReminderPayload payload;
|
||||
try {
|
||||
payload = ReminderPayload.fromJson(
|
||||
Map<String, dynamic>.from(jsonDecode(payloadRaw) as Map),
|
||||
);
|
||||
} catch (_) {
|
||||
debugPrint('failed to handle reminder notification response');
|
||||
return;
|
||||
}
|
||||
|
||||
ReminderNotificationCallbacks.onNotificationPayloadReceived?.call(payload);
|
||||
}
|
||||
}
|
||||
@@ -1,146 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../core/storage/app_preferences.dart';
|
||||
import '../models/reminder_payload.dart';
|
||||
|
||||
typedef ReminderNotificationResponseHandler =
|
||||
Future<void> Function(NotificationResponse response);
|
||||
|
||||
class ReminderNotificationCallbacks {
|
||||
static ReminderNotificationResponseHandler? _responseHandler;
|
||||
static Future<void> _pendingStorageLock = Future<void>.value();
|
||||
static void Function(ReminderPayload)? onNotificationPayloadReceived;
|
||||
static AppPreferences? _appPreferences;
|
||||
|
||||
static Future<AppPreferences> _resolvePrefs() async {
|
||||
final prefs = _appPreferences;
|
||||
if (prefs != null) {
|
||||
return prefs;
|
||||
}
|
||||
final sharedPreferences = await SharedPreferences.getInstance();
|
||||
final fallback = AppPreferences(sharedPreferences);
|
||||
_appPreferences = fallback;
|
||||
return fallback;
|
||||
}
|
||||
|
||||
static void setAppPreferences(AppPreferences prefs) {
|
||||
_appPreferences = prefs;
|
||||
}
|
||||
|
||||
@visibleForTesting
|
||||
static Future<void> resetForTest() async {
|
||||
_responseHandler = null;
|
||||
_pendingStorageLock = Future<void>.value();
|
||||
final prefs = await _resolvePrefs();
|
||||
await prefs.clearPendingNotifications();
|
||||
}
|
||||
|
||||
static Future<void> bindResponseHandler(
|
||||
ReminderNotificationResponseHandler handler,
|
||||
) async {
|
||||
_responseHandler = handler;
|
||||
await _drainPendingResponses();
|
||||
}
|
||||
|
||||
static Future<void> onForegroundResponse(
|
||||
NotificationResponse response,
|
||||
) async {
|
||||
final handler = _responseHandler;
|
||||
if (handler == null) {
|
||||
await _enqueuePendingResponse(response);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await handler(response);
|
||||
} catch (_) {
|
||||
await _enqueuePendingResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> onBackgroundResponse(
|
||||
NotificationResponse response,
|
||||
) async {
|
||||
final handler = _responseHandler;
|
||||
if (handler == null) {
|
||||
await _enqueuePendingResponse(response);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await handler(response);
|
||||
} catch (_) {
|
||||
await _enqueuePendingResponse(response);
|
||||
}
|
||||
}
|
||||
|
||||
static Future<T> _withPendingStorageLock<T>(Future<T> Function() operation) {
|
||||
final completer = Completer<void>();
|
||||
final waitForTurn = _pendingStorageLock;
|
||||
_pendingStorageLock = waitForTurn.then((_) => completer.future);
|
||||
|
||||
return waitForTurn.then((_) => operation()).whenComplete(() {
|
||||
if (!completer.isCompleted) {
|
||||
completer.complete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static Future<void> _enqueuePendingResponse(
|
||||
NotificationResponse response,
|
||||
) async {
|
||||
final prefs = await _resolvePrefs();
|
||||
await _withPendingStorageLock(() async {
|
||||
final current = prefs.pendingNotifications;
|
||||
await prefs.setPendingNotifications([
|
||||
...current,
|
||||
NotificationResponse(
|
||||
id: response.id,
|
||||
actionId: response.actionId,
|
||||
payload: response.payload,
|
||||
input: response.input,
|
||||
notificationResponseType: response.notificationResponseType,
|
||||
),
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
static Future<void> _drainPendingResponses() async {
|
||||
final handler = _responseHandler;
|
||||
if (handler == null) {
|
||||
return;
|
||||
}
|
||||
final prefs = await _resolvePrefs();
|
||||
await _withPendingStorageLock(() async {
|
||||
final pending = prefs.pendingNotifications;
|
||||
if (pending.isEmpty) {
|
||||
return;
|
||||
}
|
||||
|
||||
final remaining = <NotificationResponse>[];
|
||||
for (final response in pending) {
|
||||
try {
|
||||
await handler(response);
|
||||
} catch (_) {
|
||||
remaining.add(response);
|
||||
}
|
||||
}
|
||||
|
||||
if (remaining.isEmpty) {
|
||||
await prefs.clearPendingNotifications();
|
||||
return;
|
||||
}
|
||||
|
||||
await prefs.setPendingNotifications(remaining);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
Future<void> reminderNotificationTapBackground(
|
||||
NotificationResponse response,
|
||||
) async {
|
||||
await ReminderNotificationCallbacks.onBackgroundResponse(response);
|
||||
}
|
||||
+4
-4
@@ -1,7 +1,7 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'models/signup_request.dart';
|
||||
import 'models/login_request.dart';
|
||||
import 'models/auth_response.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import '../models/signup_request.dart';
|
||||
import '../models/login_request.dart';
|
||||
import '../models/auth_response.dart';
|
||||
|
||||
class AuthApi {
|
||||
final IApiClient _client;
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/features/auth/data/models/auth_response.dart';
|
||||
import '../models/auth_response.dart';
|
||||
|
||||
abstract class AuthRepository {
|
||||
Future<void> sendOtp(String phone);
|
||||
+5
-5
@@ -1,9 +1,9 @@
|
||||
import 'package:social_app/core/storage/token_storage.dart';
|
||||
import 'auth_api.dart';
|
||||
import 'package:social_app/data/storage/token_storage.dart';
|
||||
import '../apis/auth_api.dart';
|
||||
import 'auth_repository.dart';
|
||||
import 'models/signup_request.dart';
|
||||
import 'models/login_request.dart';
|
||||
import 'models/auth_response.dart';
|
||||
import '../models/signup_request.dart';
|
||||
import '../models/login_request.dart';
|
||||
import '../models/auth_response.dart';
|
||||
|
||||
class AuthRepositoryImpl implements AuthRepository {
|
||||
final AuthApi _api;
|
||||
@@ -1,5 +1,5 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/auth_repository.dart';
|
||||
import '../../data/repositories/auth_repository.dart';
|
||||
import 'auth_event.dart';
|
||||
import 'auth_state.dart';
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ import 'dart:async';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:formz/formz.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import '../../../../core/network/api_exception.dart';
|
||||
import '../../../../data/network/api_exception.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../data/auth_repository.dart';
|
||||
import '../../data/repositories/auth_repository.dart';
|
||||
import '../../data/models/auth_response.dart';
|
||||
import '../../../../shared/forms/inputs.dart';
|
||||
|
||||
|
||||
@@ -1,12 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
class AuthBootScreen extends StatelessWidget {
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../app/services/app_prewarm_orchestrator.dart';
|
||||
import '../bloc/auth_bloc.dart';
|
||||
import '../bloc/auth_state.dart';
|
||||
|
||||
class AuthBootScreen extends StatefulWidget {
|
||||
const AuthBootScreen({super.key});
|
||||
|
||||
@override
|
||||
State<AuthBootScreen> createState() => _AuthBootScreenState();
|
||||
}
|
||||
|
||||
class _AuthBootScreenState extends State<AuthBootScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_triggerPrewarmIfAuthenticated(context.read<AuthBloc>().state);
|
||||
}
|
||||
|
||||
void _triggerPrewarmIfAuthenticated(AuthState state) {
|
||||
if (state is! AuthAuthenticated) {
|
||||
return;
|
||||
}
|
||||
sl<AppPrewarmOrchestrator>().ensureStartedFor(state.user.id);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final colorScheme = Theme.of(context).colorScheme;
|
||||
return Scaffold(
|
||||
return BlocListener<AuthBloc, AuthState>(
|
||||
listener: (context, state) => _triggerPrewarmIfAuthenticated(state),
|
||||
child: Scaffold(
|
||||
backgroundColor: colorScheme.surface,
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
@@ -16,6 +42,7 @@ class AuthBootScreen extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import '../../../../shared/widgets/confirm_sheet.dart';
|
||||
import '../../../../shared/widgets/link_button.dart';
|
||||
import '../../../../shared/widgets/phone_prefix_selector.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../data/auth_repository.dart';
|
||||
import '../../data/repositories/auth_repository.dart';
|
||||
import '../../presentation/bloc/auth_bloc.dart';
|
||||
import '../../presentation/bloc/auth_event.dart';
|
||||
import '../../presentation/cubits/login_cubit.dart';
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/repositories/models/schedule_item_model.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import 'package:social_app/features/calendar/data/models/schedule_item_model.dart';
|
||||
|
||||
class CalendarApi {
|
||||
final IApiClient _client;
|
||||
+83
-7
@@ -1,7 +1,7 @@
|
||||
import '../cache/cache_policy.dart';
|
||||
import '../cache/cached_repository.dart';
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import 'models/schedule_item_model.dart';
|
||||
import '../../../../data/cache/cache_policy.dart';
|
||||
import '../../../../data/cache/cached_repository.dart';
|
||||
import '../../../../data/network/i_api_client.dart';
|
||||
import '../models/schedule_item_model.dart';
|
||||
|
||||
class CalendarRepository extends CachedRepository<List<ScheduleItemModel>> {
|
||||
final IApiClient _apiClient;
|
||||
@@ -17,10 +17,12 @@ class CalendarRepository extends CachedRepository<List<ScheduleItemModel>> {
|
||||
policy:
|
||||
policy ??
|
||||
const CachePolicy(
|
||||
softTtl: Duration(minutes: 2),
|
||||
hardTtl: Duration(minutes: 30),
|
||||
minRefreshInterval: Duration(minutes: 1),
|
||||
softTtl: Duration(minutes: 1),
|
||||
hardTtl: Duration(minutes: 10),
|
||||
minRefreshInterval: Duration(seconds: 30),
|
||||
),
|
||||
encodeValue: _encodeEventList,
|
||||
decodeValue: _decodeEventList,
|
||||
);
|
||||
|
||||
static String dayKey(DateTime date) {
|
||||
@@ -70,6 +72,10 @@ class CalendarRepository extends CachedRepository<List<ScheduleItemModel>> {
|
||||
return ScheduleItemModel.fromJson(data);
|
||||
}
|
||||
|
||||
Future<ScheduleItemModel> getById(String id) {
|
||||
return getEventById(id);
|
||||
}
|
||||
|
||||
Future<List<ScheduleItemModel>> listEventsByRange({
|
||||
required DateTime start,
|
||||
required DateTime end,
|
||||
@@ -77,6 +83,21 @@ class CalendarRepository extends CachedRepository<List<ScheduleItemModel>> {
|
||||
return _listByRange(startAt: start, endAt: end);
|
||||
}
|
||||
|
||||
Future<List<ScheduleItemModel>> listByRange({
|
||||
required DateTime startAt,
|
||||
required DateTime endAt,
|
||||
}) {
|
||||
return _listByRange(startAt: startAt, endAt: endAt);
|
||||
}
|
||||
|
||||
Future<void> acceptSubscription(String itemId) {
|
||||
return _apiClient.post<void>('$_prefix/$itemId/accept');
|
||||
}
|
||||
|
||||
Future<void> rejectSubscription(String itemId) {
|
||||
return _apiClient.post<void>('$_prefix/$itemId/reject');
|
||||
}
|
||||
|
||||
Future<List<ScheduleItemModel>> _listByRange({
|
||||
required DateTime startAt,
|
||||
required DateTime endAt,
|
||||
@@ -95,4 +116,59 @@ class CalendarRepository extends CachedRepository<List<ScheduleItemModel>> {
|
||||
.map(ScheduleItemModel.fromJson)
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
static Object? _encodeEventList(List<ScheduleItemModel> events) {
|
||||
return events.map(_encodeEvent).toList(growable: false);
|
||||
}
|
||||
|
||||
static List<ScheduleItemModel> _decodeEventList(Object? raw) {
|
||||
if (raw is! List) {
|
||||
throw const FormatException('Invalid cached calendar event list payload');
|
||||
}
|
||||
return raw
|
||||
.whereType<Map>()
|
||||
.map(
|
||||
(item) => ScheduleItemModel.fromJson(Map<String, dynamic>.from(item)),
|
||||
)
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
static Map<String, Object?> _encodeEvent(ScheduleItemModel item) {
|
||||
return <String, Object?>{
|
||||
'id': item.id,
|
||||
'owner_id': item.ownerId,
|
||||
'permission': item.permission,
|
||||
'is_owner': item.isOwner,
|
||||
'title': item.title,
|
||||
'description': item.description,
|
||||
'start_at': item.startAt.toIso8601String(),
|
||||
'end_at': item.endAt?.toIso8601String(),
|
||||
'timezone': item.timezone,
|
||||
'metadata': item.metadata?.toJson(),
|
||||
'source_type': _sourceTypeToApi(item.sourceType),
|
||||
'status': _statusToApi(item.status),
|
||||
'created_at': item.createdAt.toIso8601String(),
|
||||
'updated_at': item.updatedAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
static String _sourceTypeToApi(ScheduleSourceType sourceType) {
|
||||
switch (sourceType) {
|
||||
case ScheduleSourceType.manual:
|
||||
return 'manual';
|
||||
case ScheduleSourceType.imported:
|
||||
return 'imported';
|
||||
case ScheduleSourceType.agentGenerated:
|
||||
return 'agent_generated';
|
||||
}
|
||||
}
|
||||
|
||||
static String _statusToApi(ScheduleStatus status) {
|
||||
switch (status) {
|
||||
case ScheduleStatus.active:
|
||||
return 'active';
|
||||
case ScheduleStatus.archived:
|
||||
return 'archived';
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import '../cache/cache_invalidator.dart';
|
||||
import '../repositories/models/schedule_item_model.dart';
|
||||
import '../../../../data/network/i_api_client.dart';
|
||||
import '../../../../data/cache/cache_store.dart';
|
||||
import '../models/schedule_item_model.dart';
|
||||
|
||||
class CalendarService {
|
||||
static const _prefix = '/api/v1/schedule-items';
|
||||
@@ -1,4 +1,4 @@
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
import 'day_timeline_metrics.dart';
|
||||
import 'day_view_scale.dart';
|
||||
|
||||
|
||||
@@ -7,11 +7,11 @@ import '../../../../app/router/home_return_policy.dart';
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../data/repositories/calendar_repository.dart';
|
||||
import '../../../../features/calendar/data/repositories/calendar_repository.dart';
|
||||
import '../../../../shared/widgets/app_pressable.dart';
|
||||
import '../../../../shared/widgets/bottom_dock.dart';
|
||||
import '../../../../shared/state/calendar_state_manager.dart';
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
import '../calendar_time_utils.dart';
|
||||
import '../utils/event_color_resolver.dart';
|
||||
import '../dayweek/day_event_layout_engine.dart';
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:social_app/core/l10n/l10n.dart';
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../app/router/app_routes.dart';
|
||||
import '../../../../data/services/local_notification_service.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../../shared/widgets/back_title_page_header.dart';
|
||||
@@ -12,8 +11,8 @@ import '../../../../shared/widgets/detail_header_action_menu.dart';
|
||||
import '../../../../shared/widgets/destructive_action_sheet.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../../../data/services/calendar_service.dart';
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/services/calendar_service.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
import '../utils/event_color_resolver.dart';
|
||||
|
||||
enum _CalendarHeaderAction { edit, delete, share, archive }
|
||||
@@ -505,9 +504,6 @@ class _CalendarEventDetailScreenState extends State<CalendarEventDetailScreen> {
|
||||
return;
|
||||
}
|
||||
await sl<CalendarService>().deleteEvent(widget.eventId);
|
||||
try {
|
||||
await sl<LocalNotificationService>().cancelEventReminder(widget.eventId);
|
||||
} catch (_) {}
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,8 @@ import '../../../../app/di/injection.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../widgets/create_event_sheet.dart';
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../data/services/calendar_service.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/services/calendar_service.dart';
|
||||
|
||||
class CalendarEventEditScreen extends StatefulWidget {
|
||||
final String eventId;
|
||||
|
||||
@@ -4,8 +4,8 @@ import '../../../../app/di/injection.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../../shared/widgets/back_title_page_header.dart';
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../data/services/calendar_service.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/services/calendar_service.dart';
|
||||
import '../widgets/calendar_share_dialog.dart';
|
||||
|
||||
class CalendarEventShareScreen extends StatefulWidget {
|
||||
|
||||
@@ -6,14 +6,14 @@ import 'package:social_app/core/l10n/l10n.dart';
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../app/router/app_routes.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../data/repositories/calendar_repository.dart';
|
||||
import '../../../../features/calendar/data/repositories/calendar_repository.dart';
|
||||
import '../../../../shared/widgets/app_pressable.dart';
|
||||
import '../../../../shared/widgets/bottom_dock.dart';
|
||||
import '../../../../shared/state/calendar_state_manager.dart';
|
||||
import '../../../../app/router/home_return_policy.dart';
|
||||
import '../calendar_time_utils.dart';
|
||||
import '../utils/event_color_resolver.dart';
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
|
||||
class CalendarMonthScreen extends StatefulWidget {
|
||||
final bool resetToToday;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
|
||||
Color resolveEventColor({
|
||||
required ScheduleStatus status,
|
||||
|
||||
@@ -6,7 +6,7 @@ import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_button.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../data/calendar_api.dart';
|
||||
import '../../data/apis/calendar_api.dart';
|
||||
|
||||
class CalendarShareDialog extends StatefulWidget {
|
||||
final String eventId;
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:lucide_icons/lucide_icons.dart';
|
||||
import 'package:social_app/core/l10n/l10n.dart';
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../data/services/local_notification_service.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../../shared/widgets/app_selection_sheet.dart';
|
||||
@@ -11,8 +10,8 @@ import '../../../../shared/widgets/back_title_page_header.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import 'date_time_picker_sheet.dart';
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../data/services/calendar_service.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
import '../../../../features/calendar/data/services/calendar_service.dart';
|
||||
|
||||
final _defaultColors = AppColorPalette.light.eventPresetColors;
|
||||
|
||||
@@ -786,25 +785,11 @@ class _CreateEventSheetState extends State<CreateEventSheet>
|
||||
|
||||
try {
|
||||
final service = sl<CalendarService>();
|
||||
late final ScheduleItemModel saved;
|
||||
|
||||
if (_isEditing) {
|
||||
saved = await service.updateEvent(event);
|
||||
await service.updateEvent(event);
|
||||
} else {
|
||||
saved = await service.addEvent(event);
|
||||
}
|
||||
|
||||
try {
|
||||
final notificationService = sl<LocalNotificationService>();
|
||||
await notificationService.upsertEventReminder(saved);
|
||||
} catch (_) {
|
||||
if (mounted) {
|
||||
Toast.show(
|
||||
context,
|
||||
context.l10n.calendarCreateReminderPermissionFailed,
|
||||
type: ToastType.warning,
|
||||
);
|
||||
}
|
||||
await service.addEvent(event);
|
||||
}
|
||||
|
||||
widget.onSaved?.call();
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import 'package:social_app/data/cache/cache_policy.dart';
|
||||
import 'package:social_app/data/cache/cached_repository.dart';
|
||||
|
||||
import '../models/ag_ui_event.dart';
|
||||
|
||||
class ChatHistoryRepository extends CachedRepository<HistorySnapshot> {
|
||||
ChatHistoryRepository({required IApiClient apiClient, required super.store})
|
||||
: _apiClient = apiClient,
|
||||
super(
|
||||
policy: const CachePolicy(
|
||||
softTtl: Duration(seconds: 30),
|
||||
hardTtl: Duration(minutes: 5),
|
||||
minRefreshInterval: Duration(seconds: 15),
|
||||
),
|
||||
encodeValue: _encodeSnapshot,
|
||||
decodeValue: _decodeSnapshot,
|
||||
);
|
||||
|
||||
final IApiClient _apiClient;
|
||||
|
||||
Future<HistorySnapshot> loadHistory({
|
||||
String? threadId,
|
||||
DateTime? beforeDate,
|
||||
bool forceRefresh = false,
|
||||
}) {
|
||||
final key = _keyFor(threadId: threadId, beforeDate: beforeDate);
|
||||
return getOrLoad(
|
||||
key: key,
|
||||
forceRefresh: forceRefresh,
|
||||
loadFromRemote: () =>
|
||||
_loadHistoryRemote(threadId: threadId, beforeDate: beforeDate),
|
||||
);
|
||||
}
|
||||
|
||||
Future<HistorySnapshot> _loadHistoryRemote({
|
||||
String? threadId,
|
||||
DateTime? beforeDate,
|
||||
}) async {
|
||||
final path = _buildHistoryPath(threadId: threadId, beforeDate: beforeDate);
|
||||
final response = await _apiClient.get<Map<String, dynamic>>(path);
|
||||
final payload = response.data;
|
||||
if (payload is! Map<String, dynamic>) {
|
||||
throw StateError('Invalid /agent/history response');
|
||||
}
|
||||
return HistorySnapshot.fromJson(payload);
|
||||
}
|
||||
|
||||
static String _buildHistoryPath({String? threadId, DateTime? beforeDate}) {
|
||||
final query = <String>[];
|
||||
if (threadId != null && threadId.isNotEmpty) {
|
||||
query.add('threadId=$threadId');
|
||||
}
|
||||
if (beforeDate != null) {
|
||||
final day = DateTime(beforeDate.year, beforeDate.month, beforeDate.day);
|
||||
query.add('before=${day.toIso8601String().substring(0, 10)}');
|
||||
}
|
||||
if (query.isEmpty) {
|
||||
return '/api/v1/agent/history';
|
||||
}
|
||||
return '/api/v1/agent/history?${query.join('&')}';
|
||||
}
|
||||
|
||||
static String _keyFor({String? threadId, DateTime? beforeDate}) {
|
||||
final threadPart = (threadId == null || threadId.isEmpty)
|
||||
? 'default'
|
||||
: threadId;
|
||||
if (beforeDate == null) {
|
||||
return 'chat:history:first:$threadPart';
|
||||
}
|
||||
final day = DateTime(
|
||||
beforeDate.year,
|
||||
beforeDate.month,
|
||||
beforeDate.day,
|
||||
).toIso8601String().substring(0, 10);
|
||||
return 'chat:history:before:$threadPart:$day';
|
||||
}
|
||||
|
||||
static Object? _encodeSnapshot(HistorySnapshot snapshot) {
|
||||
return <String, Object?>{
|
||||
'scope': snapshot.scope,
|
||||
'threadId': snapshot.threadId,
|
||||
'day': snapshot.day,
|
||||
'hasMore': snapshot.hasMore,
|
||||
'messages': snapshot.messages.map(_encodeMessage).toList(growable: false),
|
||||
};
|
||||
}
|
||||
|
||||
static HistorySnapshot _decodeSnapshot(Object? raw) {
|
||||
if (raw is! Map) {
|
||||
throw const FormatException('Invalid cached history snapshot payload');
|
||||
}
|
||||
return HistorySnapshot.fromJson(Map<String, dynamic>.from(raw));
|
||||
}
|
||||
|
||||
static Map<String, Object?> _encodeMessage(HistoryMessage message) {
|
||||
return <String, Object?>{
|
||||
'id': message.id,
|
||||
'seq': message.seq,
|
||||
'role': message.role,
|
||||
'content': message.content,
|
||||
'timestamp': message.timestamp.toIso8601String(),
|
||||
'attachments': message.attachments
|
||||
.map(
|
||||
(attachment) => <String, Object?>{
|
||||
'url': attachment.url,
|
||||
'mimeType': attachment.mimeType,
|
||||
},
|
||||
)
|
||||
.toList(growable: false),
|
||||
'ui_schema': message.uiSchema,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,10 @@ import 'dart:typed_data';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
|
||||
import '../models/ag_ui_event.dart';
|
||||
import '../repositories/chat_history_repository.dart';
|
||||
|
||||
typedef EventCallback = void Function(AgUiEvent event);
|
||||
|
||||
@@ -43,6 +44,7 @@ class _RunInputPayload {
|
||||
|
||||
class AgUiService {
|
||||
final IApiClient _apiClient;
|
||||
final ChatHistoryRepository? _historyRepository;
|
||||
EventCallback onEvent;
|
||||
final Map<String, String> _lastEventIdByThread = {};
|
||||
int _activeStreamToken = 0;
|
||||
@@ -54,9 +56,13 @@ class AgUiService {
|
||||
String? _activeRunId;
|
||||
bool _hasMoreHistory = false;
|
||||
|
||||
AgUiService({EventCallback? onEvent, required IApiClient apiClient})
|
||||
: onEvent = onEvent ?? ((_) {}),
|
||||
_apiClient = apiClient;
|
||||
AgUiService({
|
||||
EventCallback? onEvent,
|
||||
required IApiClient apiClient,
|
||||
ChatHistoryRepository? historyRepository,
|
||||
}) : onEvent = onEvent ?? ((_) {}),
|
||||
_apiClient = apiClient,
|
||||
_historyRepository = historyRepository;
|
||||
|
||||
Future<SendMessageResult> sendMessage(
|
||||
String content, {
|
||||
@@ -105,18 +111,28 @@ class AgUiService {
|
||||
}
|
||||
|
||||
Future<HistorySnapshot> loadHistory({DateTime? beforeDate}) async {
|
||||
final repository = _historyRepository;
|
||||
final snapshot = repository != null
|
||||
? await repository.loadHistory(
|
||||
threadId: _threadId,
|
||||
beforeDate: beforeDate,
|
||||
)
|
||||
: await _loadHistoryFromApi(beforeDate: beforeDate);
|
||||
if (snapshot.threadId != null && snapshot.threadId!.isNotEmpty) {
|
||||
_threadId = snapshot.threadId;
|
||||
}
|
||||
_hasMoreHistory = snapshot.hasMore;
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
Future<HistorySnapshot> _loadHistoryFromApi({DateTime? beforeDate}) async {
|
||||
final path = _buildHistoryPath(beforeDate: beforeDate);
|
||||
final response = await _apiClient.get<Map<String, dynamic>>(path);
|
||||
final payload = response.data;
|
||||
if (payload is! Map<String, dynamic>) {
|
||||
throw StateError('Invalid /agent/history response');
|
||||
}
|
||||
final snapshot = HistorySnapshot.fromJson(payload);
|
||||
if (snapshot.threadId != null && snapshot.threadId!.isNotEmpty) {
|
||||
_threadId = snapshot.threadId;
|
||||
}
|
||||
_hasMoreHistory = snapshot.hasMore;
|
||||
return snapshot;
|
||||
return HistorySnapshot.fromJson(payload);
|
||||
}
|
||||
|
||||
Future<Uint8List> fetchAttachmentPreview(String previewPath) async {
|
||||
|
||||
@@ -5,10 +5,11 @@ import 'package:image_picker/image_picker.dart';
|
||||
import 'package:social_app/core/chat/agent_stage.dart';
|
||||
import 'package:social_app/core/chat/chat_list_item.dart';
|
||||
import 'package:social_app/core/chat/chat_orchestrator.dart';
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import 'package:social_app/core/l10n/l10n.dart';
|
||||
|
||||
import '../../data/models/ag_ui_event.dart';
|
||||
import '../../data/repositories/chat_history_repository.dart';
|
||||
import '../../data/services/ag_ui_service.dart';
|
||||
|
||||
class ChatState implements ChatOrchestratorState {
|
||||
@@ -95,8 +96,16 @@ class ChatState implements ChatOrchestratorState {
|
||||
}
|
||||
|
||||
class ChatBloc extends Cubit<ChatState> implements ChatOrchestrator {
|
||||
ChatBloc({AgUiService? service, required IApiClient apiClient})
|
||||
: _service = service ?? AgUiService(apiClient: apiClient),
|
||||
ChatBloc({
|
||||
AgUiService? service,
|
||||
required IApiClient apiClient,
|
||||
ChatHistoryRepository? historyRepository,
|
||||
}) : _service =
|
||||
service ??
|
||||
AgUiService(
|
||||
apiClient: apiClient,
|
||||
historyRepository: historyRepository,
|
||||
),
|
||||
super(const ChatState()) {
|
||||
_service.onEvent = _handleEvent;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
|
||||
class FriendsApi {
|
||||
final IApiClient _client;
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
import 'dart:io';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/models/user_profile.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import '../models/user_profile.dart';
|
||||
|
||||
class UserBasicInfo {
|
||||
final String id;
|
||||
+60
-6
@@ -1,5 +1,7 @@
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import 'models/friend_request.dart';
|
||||
import '../../../../data/network/i_api_client.dart';
|
||||
import '../../../../data/cache/cache_policy.dart';
|
||||
import '../../../../data/cache/cached_repository.dart';
|
||||
import '../models/friend_request.dart';
|
||||
|
||||
abstract class FriendRepository {
|
||||
Future<List<FriendUser>> getFriends();
|
||||
@@ -11,14 +13,29 @@ abstract class FriendRepository {
|
||||
Future<FriendRequest> declineRequest(String friendshipId);
|
||||
}
|
||||
|
||||
class FriendRepositoryImpl implements FriendRepository {
|
||||
class FriendRepositoryImpl extends CachedRepository<List<FriendUser>>
|
||||
implements FriendRepository {
|
||||
final IApiClient _apiClient;
|
||||
static const _prefix = '/api/v1/friends';
|
||||
|
||||
FriendRepositoryImpl(this._apiClient);
|
||||
FriendRepositoryImpl({required IApiClient apiClient, required super.store})
|
||||
: _apiClient = apiClient,
|
||||
super(
|
||||
policy: const CachePolicy(
|
||||
softTtl: Duration(seconds: 30),
|
||||
hardTtl: Duration(minutes: 5),
|
||||
minRefreshInterval: Duration(seconds: 15),
|
||||
),
|
||||
encodeValue: _encodeFriendUsers,
|
||||
decodeValue: _decodeFriendUsers,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<List<FriendUser>> getFriends() async {
|
||||
return getOrLoad(key: _friendsKey, loadFromRemote: _loadFriendsFromRemote);
|
||||
}
|
||||
|
||||
Future<List<FriendUser>> _loadFriendsFromRemote() async {
|
||||
final response = await _apiClient.get<List<dynamic>>(_prefix);
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
@@ -34,6 +51,10 @@ class FriendRepositoryImpl implements FriendRepository {
|
||||
|
||||
@override
|
||||
Future<FriendRequest> getRequestById(String friendshipId) async {
|
||||
return _loadRequestById(friendshipId);
|
||||
}
|
||||
|
||||
Future<FriendRequest> _loadRequestById(String friendshipId) async {
|
||||
final response = await _apiClient.get<Map<String, dynamic>>(
|
||||
'$_prefix/requests/$friendshipId',
|
||||
);
|
||||
@@ -71,7 +92,9 @@ class FriendRepositoryImpl implements FriendRepository {
|
||||
if (data == null) {
|
||||
throw StateError('Invalid acceptRequest response: empty payload');
|
||||
}
|
||||
return FriendRequest.fromJson(data);
|
||||
final request = FriendRequest.fromJson(data);
|
||||
await _invalidateFriendCaches(friendshipId);
|
||||
return request;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -83,6 +106,37 @@ class FriendRepositoryImpl implements FriendRepository {
|
||||
if (data == null) {
|
||||
throw StateError('Invalid declineRequest response: empty payload');
|
||||
}
|
||||
return FriendRequest.fromJson(data);
|
||||
final request = FriendRequest.fromJson(data);
|
||||
await _invalidateFriendCaches(friendshipId);
|
||||
return request;
|
||||
}
|
||||
|
||||
Future<void> _invalidateFriendCaches(String friendshipId) {
|
||||
final _ = friendshipId;
|
||||
return removeCacheKey(_friendsKey);
|
||||
}
|
||||
|
||||
static const _friendsKey = 'friends:list';
|
||||
|
||||
static Object? _encodeFriendUsers(List<FriendUser> users) {
|
||||
return users.map(_encodeFriendUser).toList(growable: false);
|
||||
}
|
||||
|
||||
static List<FriendUser> _decodeFriendUsers(Object? raw) {
|
||||
if (raw is! List) {
|
||||
throw const FormatException('Invalid cached friend list payload');
|
||||
}
|
||||
return raw
|
||||
.whereType<Map>()
|
||||
.map((item) => FriendUser.fromJson(Map<String, dynamic>.from(item)))
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
static Map<String, Object?> _encodeFriendUser(FriendUser user) {
|
||||
return <String, Object?>{
|
||||
'id': user.id,
|
||||
'username': user.username,
|
||||
'avatar_url': user.avatarUrl,
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import '../../core/network/i_api_client.dart';
|
||||
import 'models/user_summary.dart';
|
||||
import '../../../../data/network/i_api_client.dart';
|
||||
import '../models/user_summary.dart';
|
||||
|
||||
abstract class UserRepository {
|
||||
Future<UserSummary> getById(String userId);
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../models/user_profile.dart';
|
||||
|
||||
abstract class UsersRepository {
|
||||
Future<UserProfile> getMe();
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import 'users_api.dart';
|
||||
import '../apis/users_api.dart';
|
||||
import 'users_repository.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../models/user_profile.dart';
|
||||
|
||||
class UsersRepositoryImpl implements UsersRepository {
|
||||
final UsersApi _api;
|
||||
@@ -2,14 +2,14 @@ import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../../data/models/user_profile.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../../shared/widgets/toast/index.dart';
|
||||
import '../../../../shared/widgets/app_button.dart';
|
||||
import '../../../../shared/widgets/back_title_page_header.dart';
|
||||
import '../../../contacts/data/friends_api.dart';
|
||||
import '../../../contacts/data/users/users_api.dart';
|
||||
import '../../../contacts/data/apis/friends_api.dart';
|
||||
import '../../../contacts/data/apis/users_api.dart';
|
||||
|
||||
class ContactsScreen extends StatefulWidget {
|
||||
const ContactsScreen({super.key});
|
||||
|
||||
@@ -6,13 +6,13 @@ import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:social_app/core/chat/agent_stage.dart';
|
||||
import '../../../../core/network/api_exception.dart';
|
||||
import '../../../../data/network/api_exception.dart';
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../app/router/app_route_observer.dart';
|
||||
import '../../../../app/router/app_routes.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../data/repositories/inbox_repository.dart';
|
||||
import '../../../../features/messages/data/repositories/inbox_repository.dart';
|
||||
import '../../../chat/presentation/bloc/chat_bloc.dart';
|
||||
import '../../data/voice_recorder.dart';
|
||||
import '../controllers/home_keyboard_inset_calculator.dart';
|
||||
|
||||
@@ -8,7 +8,7 @@ import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../core/utils/tool_name_localizer.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../ui_schema/presentation/widgets/ui_schema_renderer.dart';
|
||||
import '../../../../shared/widgets/ui_schema/ui_schema_renderer.dart';
|
||||
|
||||
const _messagePaddingH = 13.0;
|
||||
const _messagePaddingV = 9.0;
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
|
||||
class InboxApi {
|
||||
final IApiClient _client;
|
||||
@@ -0,0 +1,130 @@
|
||||
import '../../../../data/network/i_api_client.dart';
|
||||
import '../../../../data/cache/cache_policy.dart';
|
||||
import '../../../../data/cache/cached_repository.dart';
|
||||
import '../models/inbox_message.dart';
|
||||
|
||||
abstract class InboxRepository {
|
||||
Future<List<InboxMessage>> getMessages({bool? isRead});
|
||||
Future<InboxMessage> markAsRead(String messageId);
|
||||
}
|
||||
|
||||
class InboxRepositoryImpl extends CachedRepository<List<InboxMessage>>
|
||||
implements InboxRepository {
|
||||
final IApiClient _apiClient;
|
||||
static const _prefix = '/api/v1/inbox/messages';
|
||||
|
||||
InboxRepositoryImpl({required IApiClient apiClient, required super.store})
|
||||
: _apiClient = apiClient,
|
||||
super(
|
||||
policy: const CachePolicy(
|
||||
softTtl: Duration(seconds: 15),
|
||||
hardTtl: Duration(minutes: 2),
|
||||
minRefreshInterval: Duration(seconds: 10),
|
||||
),
|
||||
encodeValue: _encodeMessages,
|
||||
decodeValue: _decodeMessages,
|
||||
);
|
||||
|
||||
@override
|
||||
Future<List<InboxMessage>> getMessages({bool? isRead}) async {
|
||||
return getOrLoad(
|
||||
key: _messagesKey(isRead),
|
||||
loadFromRemote: () => _loadMessagesFromRemote(isRead: isRead),
|
||||
);
|
||||
}
|
||||
|
||||
Future<List<InboxMessage>> _loadMessagesFromRemote({bool? isRead}) async {
|
||||
final queryParams = isRead != null ? '?is_read=$isRead' : '';
|
||||
final response = await _apiClient.get<List<dynamic>>(
|
||||
'$_prefix$queryParams',
|
||||
);
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
throw StateError('Invalid getMessages response: empty payload');
|
||||
}
|
||||
return data
|
||||
.whereType<Map<String, dynamic>>()
|
||||
.map(InboxMessage.fromJson)
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<InboxMessage> markAsRead(String messageId) async {
|
||||
final response = await _apiClient.patch<Map<String, dynamic>>(
|
||||
'$_prefix/$messageId/read',
|
||||
);
|
||||
final data = response.data;
|
||||
if (data == null) {
|
||||
throw StateError('Invalid markAsRead response: empty payload');
|
||||
}
|
||||
final message = InboxMessage.fromJson(data);
|
||||
await Future.wait([
|
||||
removeCacheKey(_messagesKey(false)),
|
||||
removeCacheKey(_messagesKey(true)),
|
||||
removeCacheKey(_messagesKey(null)),
|
||||
]);
|
||||
return message;
|
||||
}
|
||||
|
||||
static String _messagesKey(bool? isRead) {
|
||||
if (isRead == null) {
|
||||
return 'inbox:list:all';
|
||||
}
|
||||
return isRead ? 'inbox:list:read' : 'inbox:list:unread';
|
||||
}
|
||||
|
||||
static Object? _encodeMessages(List<InboxMessage> messages) {
|
||||
return messages.map(_encodeMessage).toList(growable: false);
|
||||
}
|
||||
|
||||
static List<InboxMessage> _decodeMessages(Object? raw) {
|
||||
if (raw is! List) {
|
||||
throw const FormatException('Invalid cached inbox message payload');
|
||||
}
|
||||
return raw
|
||||
.whereType<Map>()
|
||||
.map((item) => InboxMessage.fromJson(Map<String, dynamic>.from(item)))
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
static Map<String, Object?> _encodeMessage(InboxMessage message) {
|
||||
return <String, Object?>{
|
||||
'id': message.id,
|
||||
'recipient_id': message.recipientId,
|
||||
'sender_id': message.senderId,
|
||||
'message_type': _messageTypeToApi(message.messageType),
|
||||
'schedule_item_id': message.scheduleItemId,
|
||||
'friendship_id': message.friendshipId,
|
||||
'content': message.content,
|
||||
'is_read': message.isRead,
|
||||
'status': _messageStatusToApi(message.status),
|
||||
'created_at': message.createdAt.toIso8601String(),
|
||||
};
|
||||
}
|
||||
|
||||
static String _messageTypeToApi(InboxMessageType type) {
|
||||
switch (type) {
|
||||
case InboxMessageType.friendRequest:
|
||||
return 'friend_request';
|
||||
case InboxMessageType.calendar:
|
||||
return 'calendar';
|
||||
case InboxMessageType.system:
|
||||
return 'system';
|
||||
case InboxMessageType.group:
|
||||
return 'group';
|
||||
}
|
||||
}
|
||||
|
||||
static String _messageStatusToApi(InboxMessageStatus status) {
|
||||
switch (status) {
|
||||
case InboxMessageStatus.pending:
|
||||
return 'pending';
|
||||
case InboxMessageStatus.accepted:
|
||||
return 'accepted';
|
||||
case InboxMessageStatus.rejected:
|
||||
return 'rejected';
|
||||
case InboxMessageStatus.dismissed:
|
||||
return 'dismissed';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,10 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../data/repositories/calendar_event_repository.dart';
|
||||
import '../../../../data/repositories/models/inbox_message.dart';
|
||||
import '../../../../data/repositories/inbox_repository.dart';
|
||||
import '../../../../data/repositories/user_repository.dart';
|
||||
import '../../../../features/calendar/data/repositories/calendar_repository.dart';
|
||||
import '../../../../features/messages/data/models/inbox_message.dart';
|
||||
import '../../../../features/messages/data/repositories/inbox_repository.dart';
|
||||
import '../../../../features/contacts/data/repositories/user_repository.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../../shared/widgets/page_header.dart';
|
||||
@@ -25,7 +25,7 @@ class MessageInviteDetailScreen extends StatefulWidget {
|
||||
|
||||
class _MessageInviteDetailScreenState extends State<MessageInviteDetailScreen> {
|
||||
late final InboxRepository _inboxRepository;
|
||||
late final CalendarEventRepository _calendarRepository;
|
||||
late final CalendarRepository _calendarRepository;
|
||||
late final UserRepository _userRepository;
|
||||
|
||||
InboxMessage? _message;
|
||||
@@ -43,7 +43,7 @@ class _MessageInviteDetailScreenState extends State<MessageInviteDetailScreen> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_inboxRepository = sl<InboxRepository>();
|
||||
_calendarRepository = sl<CalendarEventRepository>();
|
||||
_calendarRepository = sl<CalendarRepository>();
|
||||
_userRepository = sl<UserRepository>();
|
||||
_loadDetail();
|
||||
}
|
||||
|
||||
@@ -3,10 +3,10 @@ import 'package:go_router/go_router.dart';
|
||||
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../app/router/app_routes.dart';
|
||||
import '../../../../data/repositories/friend_repository.dart';
|
||||
import '../../../../data/repositories/inbox_repository.dart';
|
||||
import '../../../../data/repositories/models/friend_request.dart';
|
||||
import '../../../../data/repositories/models/inbox_message.dart';
|
||||
import '../../../../features/contacts/data/repositories/friend_repository.dart';
|
||||
import '../../../../features/messages/data/repositories/inbox_repository.dart';
|
||||
import '../../../../features/contacts/data/models/friend_request.dart';
|
||||
import '../../../../features/messages/data/models/inbox_message.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../../shared/widgets/app_pull_refresh_feedback.dart';
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:social_app/core/l10n/l10n.dart';
|
||||
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_button.dart';
|
||||
import '../../data/inbox_api.dart';
|
||||
import '../../data/apis/inbox_api.dart';
|
||||
|
||||
class CalendarInviteCard extends StatelessWidget {
|
||||
final InboxMessageResponse message;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
enum ReminderAction {
|
||||
archive('archive'),
|
||||
snooze10m('snooze10m');
|
||||
|
||||
const ReminderAction(this.value);
|
||||
|
||||
final String value;
|
||||
|
||||
static ReminderAction fromValue(String raw) {
|
||||
switch (raw) {
|
||||
case 'archive':
|
||||
case 'cancel':
|
||||
case 'auto_archive':
|
||||
return ReminderAction.archive;
|
||||
case 'snooze10m':
|
||||
case 'snooze_10m':
|
||||
case 'timeout_30s':
|
||||
return ReminderAction.snooze10m;
|
||||
default:
|
||||
throw ArgumentError.value(raw, 'raw', 'Unsupported reminder action');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
import '../../../../data/services/calendar_service.dart';
|
||||
import '../../../../data/models/reminder_payload.dart';
|
||||
import '../../../../data/repositories/models/schedule_item_model.dart';
|
||||
import '../../../../data/services/local_notification_service.dart';
|
||||
import '../models/reminder_action.dart';
|
||||
|
||||
class ReminderActionExecutor {
|
||||
final CalendarService _calendarService;
|
||||
final LocalNotificationService _notificationService;
|
||||
|
||||
ReminderActionExecutor({
|
||||
required CalendarService calendarService,
|
||||
required LocalNotificationService notificationService,
|
||||
}) : _calendarService = calendarService,
|
||||
_notificationService = notificationService;
|
||||
|
||||
Future<void> handleAction({
|
||||
required ReminderAction action,
|
||||
required ReminderPayload payload,
|
||||
}) async {
|
||||
final ids = payload.mode == ReminderPayloadMode.aggregate
|
||||
? (payload.aggregateIds.isNotEmpty
|
||||
? payload.aggregateIds
|
||||
: <String>[payload.eventId])
|
||||
: <String>[payload.eventId];
|
||||
|
||||
if (action == ReminderAction.archive) {
|
||||
for (final id in ids) {
|
||||
await _notificationService.cancelEventReminder(id);
|
||||
await _archiveEvent(id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (action == ReminderAction.snooze10m) {
|
||||
for (final id in ids) {
|
||||
await _snoozeEvent(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _snoozeEvent(String eventId) async {
|
||||
late final ScheduleItemModel event;
|
||||
try {
|
||||
event = await _calendarService.getEventById(eventId);
|
||||
} catch (_) {
|
||||
await _notificationService.cancelEventReminder(eventId);
|
||||
return;
|
||||
}
|
||||
final now = DateTime.now();
|
||||
final endAt = event.endAt;
|
||||
if (endAt != null && !now.isBefore(endAt)) {
|
||||
await _notificationService.cancelEventReminder(eventId);
|
||||
await _archiveEvent(eventId);
|
||||
return;
|
||||
}
|
||||
|
||||
final nextAt = now.add(const Duration(minutes: 10));
|
||||
if (endAt != null && !nextAt.isBefore(endAt)) {
|
||||
await _notificationService.cancelEventReminder(eventId);
|
||||
await _archiveEvent(eventId);
|
||||
return;
|
||||
}
|
||||
|
||||
await _notificationService.scheduleReminderAt(event, nextAt);
|
||||
}
|
||||
|
||||
Future<void> _archiveEvent(String eventId) async {
|
||||
try {
|
||||
await _calendarService.archiveEvent(eventId);
|
||||
} catch (_) {
|
||||
await _notificationService.cancelEventReminder(eventId);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import '../models/automation_job_model.dart';
|
||||
|
||||
class AutomationJobsApi {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
|
||||
class AppVersionResponse {
|
||||
final bool hasUpdate;
|
||||
+20
-1
@@ -1,6 +1,6 @@
|
||||
import '../../../../data/cache/cache_policy.dart';
|
||||
import '../../../../data/cache/cached_repository.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../../../contacts/data/models/user_profile.dart';
|
||||
|
||||
class UserProfileCacheRepository extends CachedRepository<UserProfile> {
|
||||
static const String cacheKey = 'settings:user_profile';
|
||||
@@ -22,6 +22,8 @@ class UserProfileCacheRepository extends CachedRepository<UserProfile> {
|
||||
hardTtl: Duration(minutes: 30),
|
||||
minRefreshInterval: Duration(minutes: 1),
|
||||
),
|
||||
encodeValue: _encodeUserProfile,
|
||||
decodeValue: _decodeUserProfile,
|
||||
);
|
||||
|
||||
UserProfile? get cachedUser => _cachedUser;
|
||||
@@ -64,4 +66,21 @@ class UserProfileCacheRepository extends CachedRepository<UserProfile> {
|
||||
}
|
||||
return remote;
|
||||
}
|
||||
|
||||
static Object? _encodeUserProfile(UserProfile user) {
|
||||
return <String, Object?>{
|
||||
'id': user.id,
|
||||
'username': user.username,
|
||||
'phone': user.phone,
|
||||
'avatar_url': user.avatarUrl,
|
||||
'bio': user.bio,
|
||||
};
|
||||
}
|
||||
|
||||
static UserProfile _decodeUserProfile(Object? raw) {
|
||||
if (raw is! Map) {
|
||||
throw const FormatException('Invalid cached user profile payload');
|
||||
}
|
||||
return UserProfile.fromJson(Map<String, dynamic>.from(raw));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import '../models/memory_models.dart';
|
||||
|
||||
class MemoryService {
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../../../core/network/i_api_client.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../../../../data/network/i_api_client.dart';
|
||||
import '../../../contacts/data/models/user_profile.dart';
|
||||
|
||||
class UserProfileService {
|
||||
static const _prefix = '/api/v1/users';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/models/automation_job_model.dart';
|
||||
import '../../data/services/automation_jobs_api.dart';
|
||||
import '../../data/apis/automation_jobs_api.dart';
|
||||
|
||||
class AutomationJobsState extends Equatable {
|
||||
final List<AutomationJobModel> jobs;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import '../../data/models/automation_job_model.dart';
|
||||
import '../../data/services/automation_jobs_api.dart';
|
||||
import '../../data/apis/automation_jobs_api.dart';
|
||||
|
||||
class JobDetailState extends Equatable {
|
||||
final AutomationJobModel? job;
|
||||
|
||||
@@ -10,8 +10,8 @@ import '../../../../shared/widgets/app_button.dart';
|
||||
import '../../../../shared/widgets/app_loading_indicator.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../../data/services/user_profile_cache_repository.dart';
|
||||
import '../../../contacts/data/models/user_profile.dart';
|
||||
import '../../data/repositories/user_profile_cache_repository.dart';
|
||||
import '../../data/services/user_profile_service.dart';
|
||||
import '../widgets/account_section_card.dart';
|
||||
import '../widgets/settings_page_scaffold.dart';
|
||||
|
||||
@@ -12,7 +12,7 @@ import '../../../../shared/widgets/app_toggle_switch.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../data/models/automation_job_model.dart';
|
||||
import '../../data/services/automation_jobs_api.dart';
|
||||
import '../../data/apis/automation_jobs_api.dart';
|
||||
import '../../presentation/cubits/automation_jobs_cubit.dart';
|
||||
import '../widgets/settings_page_scaffold.dart';
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../../../core/utils/tool_name_localizer.dart';
|
||||
import '../../data/models/automation_job_model.dart';
|
||||
import '../../data/services/automation_jobs_api.dart';
|
||||
import '../../data/apis/automation_jobs_api.dart';
|
||||
import '../../presentation/cubits/job_detail_cubit.dart';
|
||||
import '../widgets/settings_page_scaffold.dart';
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:social_app/app/router/app_routes.dart';
|
||||
import 'package:social_app/core/l10n/l10n.dart';
|
||||
import 'package:social_app/core/theme/design_tokens.dart';
|
||||
import 'package:social_app/core/auth/session_controller.dart';
|
||||
import 'package:social_app/data/models/user_profile.dart';
|
||||
import 'package:social_app/data/repositories/friend_repository.dart';
|
||||
import 'package:social_app/features/contacts/data/models/user_profile.dart';
|
||||
import 'package:social_app/features/contacts/data/repositories/friend_repository.dart';
|
||||
import 'package:social_app/shared/widgets/app_button.dart';
|
||||
import 'package:social_app/shared/widgets/app_loading_indicator.dart';
|
||||
import 'package:social_app/shared/widgets/app_pressable.dart';
|
||||
@@ -15,9 +15,9 @@ import 'package:social_app/shared/widgets/destructive_action_sheet.dart';
|
||||
import 'package:social_app/shared/widgets/toast/toast.dart';
|
||||
import 'package:social_app/shared/widgets/toast/toast_type.dart';
|
||||
import 'package:social_app/core/utils/phone_display_formatter.dart';
|
||||
import 'package:social_app/features/settings/data/settings_api.dart';
|
||||
import 'package:social_app/features/settings/data/services/automation_jobs_api.dart';
|
||||
import 'package:social_app/features/settings/data/services/user_profile_cache_repository.dart';
|
||||
import 'package:social_app/features/settings/data/apis/settings_api.dart';
|
||||
import 'package:social_app/features/settings/data/apis/automation_jobs_api.dart';
|
||||
import 'package:social_app/features/settings/data/repositories/user_profile_cache_repository.dart';
|
||||
import 'package:social_app/app/router/home_return_policy.dart';
|
||||
import '../widgets/settings_page_scaffold.dart';
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
|
||||
class TodoApi {
|
||||
final IApiClient _client;
|
||||
@@ -0,0 +1,104 @@
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../../data/cache/cache_store.dart';
|
||||
import '../../../../data/cache/cache_policy.dart';
|
||||
import '../../../../data/cache/cached_repository.dart';
|
||||
import '../apis/todo_api.dart';
|
||||
|
||||
class TodoRepository extends CachedRepository<List<TodoResponse>> {
|
||||
static const String pendingListKey = 'todo:list:pending';
|
||||
|
||||
final TodoApi api;
|
||||
final CacheInvalidator invalidator;
|
||||
|
||||
TodoRepository({
|
||||
required this.api,
|
||||
required super.store,
|
||||
required this.invalidator,
|
||||
super.now,
|
||||
}) : super(
|
||||
policy: const CachePolicy(
|
||||
softTtl: Duration(seconds: 30),
|
||||
hardTtl: Duration(minutes: 10),
|
||||
minRefreshInterval: Duration(seconds: 15),
|
||||
),
|
||||
encodeValue: _encodeTodoList,
|
||||
decodeValue: _decodeTodoList,
|
||||
);
|
||||
|
||||
Future<List<TodoResponse>> getPendingTodos({
|
||||
bool forceRefresh = false,
|
||||
}) async {
|
||||
return getOrLoad(
|
||||
key: pendingListKey,
|
||||
forceRefresh: forceRefresh,
|
||||
loadFromRemote: api.getPendingTodos,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> completeTodo(String id) async {
|
||||
final CacheEntry<List<TodoResponse>>? cached = await readCacheEntry(
|
||||
pendingListKey,
|
||||
);
|
||||
if (cached != null) {
|
||||
final next = cached.value
|
||||
.where((todo) => todo.id != id)
|
||||
.toList(growable: false);
|
||||
await writeCacheEntry(pendingListKey, next);
|
||||
}
|
||||
|
||||
try {
|
||||
await api.completeTodo(id);
|
||||
invalidator.invalidate(pendingListKey);
|
||||
} catch (error) {
|
||||
if (cached != null) {
|
||||
await writeCacheEntry(pendingListKey, cached.value);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> invalidatePending() {
|
||||
invalidator.invalidate(pendingListKey);
|
||||
return Future<void>.value();
|
||||
}
|
||||
|
||||
static Object? _encodeTodoList(List<TodoResponse> todos) {
|
||||
return todos.map(_encodeTodo).toList(growable: false);
|
||||
}
|
||||
|
||||
static List<TodoResponse> _decodeTodoList(Object? raw) {
|
||||
if (raw is! List) {
|
||||
throw const FormatException('Invalid cached todo list payload');
|
||||
}
|
||||
return raw
|
||||
.whereType<Map>()
|
||||
.map((item) => TodoResponse.fromJson(Map<String, dynamic>.from(item)))
|
||||
.toList(growable: false);
|
||||
}
|
||||
|
||||
static Map<String, Object?> _encodeTodo(TodoResponse todo) {
|
||||
return <String, Object?>{
|
||||
'id': todo.id,
|
||||
'owner_id': todo.ownerId,
|
||||
'title': todo.title,
|
||||
'description': todo.description,
|
||||
'order': todo.order,
|
||||
'priority': todo.priority,
|
||||
'status': todo.status,
|
||||
'completed_at': todo.completedAt?.toIso8601String(),
|
||||
'created_at': todo.createdAt.toIso8601String(),
|
||||
'updated_at': todo.updatedAt.toIso8601String(),
|
||||
'schedule_items': todo.scheduleItems.map(_encodeScheduleItem).toList(),
|
||||
};
|
||||
}
|
||||
|
||||
static Map<String, Object?> _encodeScheduleItem(ScheduleItemBasic item) {
|
||||
return <String, Object?>{
|
||||
'id': item.id,
|
||||
'title': item.title,
|
||||
'start_at': item.startAt.toIso8601String(),
|
||||
'end_at': item.endAt?.toIso8601String(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
import 'dart:async';
|
||||
|
||||
import '../../../data/cache/cache_entry.dart';
|
||||
import '../../../data/cache/cache_invalidator.dart';
|
||||
import '../../../data/cache/cache_policy.dart';
|
||||
import '../../../data/cache/cached_repository.dart';
|
||||
import 'todo_api.dart';
|
||||
|
||||
class TodoRepository extends CachedRepository<List<TodoResponse>> {
|
||||
static const String pendingListKey = 'todo:list:pending';
|
||||
|
||||
final TodoApi api;
|
||||
final CacheInvalidator invalidator;
|
||||
|
||||
TodoRepository({
|
||||
required this.api,
|
||||
required super.store,
|
||||
required this.invalidator,
|
||||
super.now,
|
||||
}) : super(
|
||||
policy: const CachePolicy(
|
||||
softTtl: Duration(days: 3650),
|
||||
hardTtl: Duration(days: 3650),
|
||||
minRefreshInterval: Duration(days: 3650),
|
||||
),
|
||||
);
|
||||
|
||||
Future<List<TodoResponse>> getPendingTodos({
|
||||
bool forceRefresh = false,
|
||||
}) async {
|
||||
return getOrLoad(
|
||||
key: pendingListKey,
|
||||
forceRefresh: forceRefresh,
|
||||
loadFromRemote: api.getPendingTodos,
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> completeTodo(String id) async {
|
||||
final CacheEntry<List<TodoResponse>>? cached = await readCacheEntry(
|
||||
pendingListKey,
|
||||
);
|
||||
if (cached != null) {
|
||||
final next = cached.value
|
||||
.where((todo) => todo.id != id)
|
||||
.toList(growable: false);
|
||||
await writeCacheEntry(pendingListKey, next);
|
||||
}
|
||||
|
||||
try {
|
||||
await api.completeTodo(id);
|
||||
invalidator.invalidate(pendingListKey);
|
||||
} catch (error) {
|
||||
if (cached != null) {
|
||||
await store.write<CacheEntry<List<TodoResponse>>>(
|
||||
pendingListKey,
|
||||
cached,
|
||||
);
|
||||
}
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> invalidatePending() {
|
||||
invalidator.invalidate(pendingListKey);
|
||||
return Future<void>.value();
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import '../../../../shared/widgets/error_retry_surface.dart';
|
||||
import '../../../../shared/widgets/full_screen_loading.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../data/todo_api.dart';
|
||||
import '../../data/apis/todo_api.dart';
|
||||
|
||||
enum _TodoHeaderAction { edit, delete }
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ import 'package:go_router/go_router.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
import '../../../../app/di/injection.dart';
|
||||
import '../../../../data/repositories/calendar_event_repository.dart';
|
||||
import '../../../../data/repositories/models/calendar_event.dart';
|
||||
import '../../../../features/calendar/data/repositories/calendar_repository.dart';
|
||||
import '../../../../features/calendar/data/models/schedule_item_model.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../shared/widgets/app_button.dart';
|
||||
@@ -15,7 +15,7 @@ import '../../../../shared/widgets/error_retry_surface.dart';
|
||||
import '../../../../shared/widgets/full_screen_loading.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../data/todo_api.dart';
|
||||
import '../../data/apis/todo_api.dart';
|
||||
|
||||
class TodoEditScreen extends StatefulWidget {
|
||||
final String? todoId;
|
||||
@@ -32,8 +32,7 @@ class TodoEditScreen extends StatefulWidget {
|
||||
|
||||
class _TodoEditScreenState extends State<TodoEditScreen> {
|
||||
final TodoApi _todoApi = sl<TodoApi>();
|
||||
final CalendarEventRepository _calendarRepository =
|
||||
sl<CalendarEventRepository>();
|
||||
final CalendarRepository _calendarRepository = sl<CalendarRepository>();
|
||||
|
||||
final TextEditingController _titleController = TextEditingController();
|
||||
final TextEditingController _descriptionController = TextEditingController();
|
||||
@@ -94,7 +93,7 @@ class _TodoEditScreenState extends State<TodoEditScreen> {
|
||||
..clear()
|
||||
..addAll(todo?.scheduleItems.map((item) => item.id) ?? const []);
|
||||
_scheduleItems = scheduleItems
|
||||
.where((item) => item.status == CalendarEventStatus.active)
|
||||
.where((item) => item.status == ScheduleStatus.active)
|
||||
.map(
|
||||
(item) => _ScheduleItemSimple(
|
||||
id: item.id,
|
||||
|
||||
@@ -16,8 +16,8 @@ import '../../../../shared/widgets/bottom_dock.dart';
|
||||
import '../../../../shared/state/calendar_state_manager.dart';
|
||||
import '../../../../shared/widgets/toast/toast.dart';
|
||||
import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../data/todo_api.dart';
|
||||
import '../../data/todo_repository.dart';
|
||||
import '../../data/apis/todo_api.dart';
|
||||
import '../../data/repositories/todo_repository.dart';
|
||||
|
||||
class TodoQuadrantsScreen extends StatefulWidget {
|
||||
const TodoQuadrantsScreen({super.key});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:social_app/core/theme/design_tokens.dart';
|
||||
import 'package:social_app/features/todo/data/todo_api.dart';
|
||||
import 'package:social_app/features/todo/data/apis/todo_api.dart';
|
||||
|
||||
class TodoDragItem extends StatelessWidget {
|
||||
final TodoResponse todo;
|
||||
|
||||
+5
-5
@@ -1,10 +1,10 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../../../../core/l10n/l10n.dart';
|
||||
import '../../../../core/theme/design_tokens.dart';
|
||||
import '../../../../data/models/reminder_payload.dart';
|
||||
import '../../../../shared/widgets/app_button.dart';
|
||||
import '../../domain/services/reminder_queue_manager.dart';
|
||||
import '../../../core/l10n/l10n.dart';
|
||||
import '../../../core/theme/design_tokens.dart';
|
||||
import '../../../core/notification/models/reminder_payload.dart';
|
||||
import '../app_button.dart';
|
||||
import '../../../core/notification/services/reminder_queue_manager.dart';
|
||||
|
||||
class ReminderOverlay extends StatefulWidget {
|
||||
const ReminderOverlay({
|
||||
@@ -4,7 +4,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:social_app/app/di/injection.dart';
|
||||
import 'package:social_app/app/router/app_router.dart';
|
||||
import 'package:social_app/app/router/app_routes.dart';
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import 'package:social_app/features/chat/presentation/bloc/chat_bloc.dart';
|
||||
import 'package:social_app/features/auth/presentation/bloc/auth_state.dart';
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user