e722fe2ce1
Extends ContentRepository with optional cacheDir: cached packs in <cacheDir>/seasons/*/pack.json merge with bundled ones (cached wins for same id), corrupt/future-schema packs silently ignored, refresh() fires ContentDownloader.sync() once per session. main() wires the real cache+downloader instance; default constructor stays bundled-only for tests. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
49 lines
1.4 KiB
Dart
49 lines
1.4 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:path_provider/path_provider.dart';
|
|
|
|
import 'app.dart';
|
|
import 'data/content_repository.dart';
|
|
import 'data/remote/content_downloader.dart';
|
|
import 'data/save_repository.dart';
|
|
import 'state/providers.dart';
|
|
|
|
/// Remote content origin. Swap per environment with
|
|
/// --dart-define=CONTENT_BASE_URL=...; the default points at the production
|
|
/// Firebase Hosting site (owner setup pending).
|
|
const contentBaseUrl = String.fromEnvironment(
|
|
'CONTENT_BASE_URL',
|
|
defaultValue: 'https://block-seasons.web.app/content',
|
|
);
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final saveRepository = await SaveRepository.open();
|
|
|
|
ContentRepository contentRepository;
|
|
try {
|
|
final support = await getApplicationSupportDirectory();
|
|
final cacheDir = Directory('${support.path}/content');
|
|
contentRepository = ContentRepository(
|
|
cacheDir: cacheDir,
|
|
downloader: ContentDownloader(
|
|
baseUrl: contentBaseUrl,
|
|
cacheDir: cacheDir,
|
|
),
|
|
);
|
|
} catch (e) {
|
|
debugPrint('content cache unavailable, bundled only: $e');
|
|
contentRepository = ContentRepository();
|
|
}
|
|
|
|
runApp(ProviderScope(
|
|
overrides: [
|
|
saveRepositoryProvider.overrideWithValue(saveRepository),
|
|
contentRepositoryProvider.overrideWithValue(contentRepository),
|
|
],
|
|
child: const BlockSeasonsApp(),
|
|
));
|
|
}
|