Phase 3 scaffold: chat engine (WebSocket, FCM, pricing, timer, extension, history)
- Backend: WebSocket plugin, chat/pricing/timer/extension/closure/notification services - Client app: ChatBloc, pricing dialog, chat screen with message status, extension/goodbye flow, history - Mitra app: MitraChatBloc, ExtensionBloc, chat screen, extension accept/reject, history - Control center: free trial, extension timeout, early end config toggles - DB migration: chat_messages, session_closures, session_extensions, customer_transactions tables Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:firebase_core/firebase_core.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
@@ -6,12 +7,18 @@ import 'core/api/api_client.dart';
|
||||
import 'core/auth/auth_bloc.dart';
|
||||
import 'core/status/status_bloc.dart';
|
||||
import 'core/chat/chat_request_bloc.dart';
|
||||
import 'core/chat/mitra_chat_bloc.dart';
|
||||
import 'core/chat/extension_bloc.dart';
|
||||
import 'firebase_options.dart';
|
||||
import 'router.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||
|
||||
final messaging = FirebaseMessaging.instance;
|
||||
await messaging.requestPermission();
|
||||
|
||||
runApp(const App());
|
||||
}
|
||||
|
||||
@@ -38,6 +45,18 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
_router = buildRouter(_authBloc);
|
||||
_statusBloc = StatusBloc(apiClient: _apiClient);
|
||||
_chatRequestBloc = ChatRequestBloc(apiClient: _apiClient);
|
||||
_registerFcmToken();
|
||||
}
|
||||
|
||||
Future<void> _registerFcmToken() {
|
||||
return _authBloc.stream.where((s) => s is AuthAuthenticated).first.then((_) async {
|
||||
try {
|
||||
final token = await FirebaseMessaging.instance.getToken();
|
||||
if (token != null) {
|
||||
await _apiClient.post('/api/shared/device-token', data: {'token': token});
|
||||
}
|
||||
} catch (_) {}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -66,6 +85,8 @@ class _AppState extends State<App> with WidgetsBindingObserver {
|
||||
BlocProvider.value(value: _authBloc),
|
||||
BlocProvider.value(value: _statusBloc),
|
||||
BlocProvider.value(value: _chatRequestBloc),
|
||||
BlocProvider(create: (_) => MitraChatBloc(apiClient: _apiClient)),
|
||||
BlocProvider(create: (_) => ExtensionBloc(apiClient: _apiClient)),
|
||||
RepositoryProvider.value(value: _apiClient),
|
||||
],
|
||||
child: BlocListener<AuthBloc, AuthState>(
|
||||
|
||||
Reference in New Issue
Block a user