mirror of
https://github.com/block/buzz.git
synced 2026-11-24 10:12:19 +00:00
The screen table moves out of shared/diagnostics to lib/diagnostic_screens.dart and reaches the observers through diagnosticScreenClassifierProvider, which the root scope overrides. The shared conversation pane no longer imports every feature page. A route hosting a navigator with a page open past its first, such as a phone conversation over the channel list, is named by that page, so closing a cover over an open channel records the channel. A screen equal to the last one is skipped, which removes the doubled crumbs from pane hosts and wide section changes while keeping the pane placeholder's crumb after sign-in. Adding a community is named addCommunity, the hosted setup route is named onboarding, and the Duo channel sheet route leaves no crumb. Co-authored-by: studio <dc2fc481343672df31a689840c09299972e704dac592e0da6f18486646a7ee3e@localhost> Signed-off-by: Tom Brow <tomb@block.xyz>
95 lines
3.3 KiB
Dart
95 lines
3.3 KiB
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:package_info_plus/package_info_plus.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'app.dart';
|
|
import 'diagnostic_screens.dart';
|
|
import 'features/age_gate/age_signal_push_bootstrap.dart';
|
|
import 'features/agents/agents_page.dart';
|
|
import 'features/invites/invite_join_provider.dart';
|
|
import 'shared/agents/agents_surface.dart';
|
|
import 'shared/diagnostics/diagnostic_member_binding.dart';
|
|
import 'shared/diagnostics/diagnostic_navigation_observer.dart';
|
|
import 'shared/diagnostics/diagnostic_reporter.dart';
|
|
import 'shared/diagnostics/diagnostic_startup.dart';
|
|
import 'shared/push/push_bridge.dart';
|
|
import 'shared/relay/media_disk_cache.dart';
|
|
import 'shared/relay/relay_closed_policy.dart';
|
|
import 'shared/relay/relay_websocket.dart';
|
|
import 'shared/theme/theme_provider.dart';
|
|
|
|
void main() => runBuzzApp(const App());
|
|
|
|
Future<void> runBuzzApp(Widget app) async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
await runWithDiagnostics(
|
|
destination: reportingDestination,
|
|
app: (reporter) => _startApp(app, reporter),
|
|
);
|
|
}
|
|
|
|
Future<void> _startApp(Widget app, DiagnosticReporter reporter) async {
|
|
installBuzzPushMethodHandler();
|
|
// Relay upgrades name the app version, so learn it before any socket opens.
|
|
final userAgent = loadRelayUserAgent(
|
|
() async => (await PackageInfo.fromPlatform()).version,
|
|
);
|
|
|
|
// Pre-load preferences so the first frame uses the saved theme/accent.
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await userAgent;
|
|
|
|
runApp(
|
|
buildRootProviderScope(
|
|
prefs: prefs,
|
|
mediaCacheRoot: _mediaCacheRoot,
|
|
reporter: reporter,
|
|
child: app,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Without a caches directory images still load, just not from disk.
|
|
Future<Directory?> _mediaCacheRoot() async {
|
|
try {
|
|
return await resolveMediaCacheRoot();
|
|
} catch (error) {
|
|
debugPrint('[MediaDiskCache] no caches directory: $error');
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// The app's root scope, shared with tests so its production wiring is
|
|
/// asserted rather than re-declared.
|
|
ProviderScope buildRootProviderScope({
|
|
required SharedPreferences prefs,
|
|
required Widget child,
|
|
Future<Directory?> Function()? mediaCacheRoot,
|
|
DiagnosticReporter reporter = const NoopDiagnosticReporter(),
|
|
}) => ProviderScope(
|
|
// A relay statement deadline cannot resolve on retry — the same expensive
|
|
// query would re-run and hit the same limit. Return null (no retry) for
|
|
// deadline errors and fall through to the default exponential backoff for
|
|
// everything else.
|
|
retry: relayProviderRetry,
|
|
overrides: [
|
|
agentCreationSurfaceProvider.overrideWithValue(
|
|
(context, link) async => unawaited(showAgents(context, draft: link)),
|
|
),
|
|
diagnosticReporterProvider.overrideWithValue(reporter),
|
|
diagnosticScreenClassifierProvider.overrideWithValue(diagnosticScreenOf),
|
|
savedPrefsProvider.overrideWithValue(prefs),
|
|
if (mediaCacheRoot != null)
|
|
mediaCacheRootProvider.overrideWith((ref) => mediaCacheRoot()),
|
|
inviteJoinRecoveryProvider.overrideWith(
|
|
(ref) =>
|
|
(scope) => buildMobileInviteJoinRecovery(ref, scope),
|
|
),
|
|
],
|
|
child: DiagnosticMemberBinding(child: AgeSignalPushBootstrap(child: child)),
|
|
);
|