Messages were in-memory only — gone on leaving the conversation. - MessageStore: keystore-backed (no plaintext), a capped per-peer JSON list (last 200). Simple; the encrypted Drift DB is the eventual home at scale. - MessagesCubit: loads saved history on start (subscribes FIRST, then loads, so a message arriving during the load isn't dropped) and persists every sent and received message. Wired via DI + TaneApp(messageStore). Tests (plain 'test', no hang risk): MessageStore round-trip/per-peer/cap, and a cubit test that reopens a fresh cubit and sees the saved conversation. Analyzer clean; run 'flutter test' locally to confirm.
39 lines
1.2 KiB
Dart
39 lines
1.2 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
import 'app.dart';
|
|
import 'data/species_repository.dart';
|
|
import 'data/variety_repository.dart';
|
|
import 'di/injector.dart';
|
|
import 'i18n/strings.g.dart';
|
|
import 'services/auto_backup_service.dart';
|
|
import 'services/coarse_location.dart';
|
|
import 'services/message_store.dart';
|
|
import 'services/offer_outbox.dart';
|
|
import 'services/onboarding_store.dart';
|
|
import 'services/social_service.dart';
|
|
import 'services/social_settings.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
LocaleSettings.useDeviceLocaleSync();
|
|
await configureDependencies();
|
|
final onboarding = getIt<OnboardingStore>();
|
|
runApp(
|
|
TranslationProvider(
|
|
child: TaneApp(
|
|
repository: getIt<VarietyRepository>(),
|
|
species: getIt<SpeciesRepository>(),
|
|
onboarding: onboarding,
|
|
social: getIt<SocialService>(),
|
|
socialSettings: getIt<SocialSettings>(),
|
|
location: const GeolocatorCoarseLocation(),
|
|
outbox: getIt<OfferOutbox>(),
|
|
messageStore: getIt<MessageStore>(),
|
|
showIntro: !await onboarding.introSeen(),
|
|
autoBackup: getIt.isRegistered<AutoBackupService>()
|
|
? getIt<AutoBackupService>()
|
|
: null,
|
|
),
|
|
),
|
|
);
|
|
}
|