- Status: computed from connection, presence, hold, relay, player facts; no setters (health writes and HealthStatus gone); pill, strip and source line read it; transitions go to the Notifier. - Notifier: noticeFor(event, context) with self presence, alone, window activity, playing and prefs; toasts for joins/leaves/returns/swaps/ Up next adds (with picture)/problems/chat, the rest logged; while sitting out only chat, nudges, starting, Up next (+ joins if chosen); alone no social notices; replayed lines logged; owns its toast timer. - System notifications (flutter_local_notifications: D-Bus on Linux, WinRT on Windows) when the window isn't focused; a click focuses it. - Toasts sit above the control bar and move with it. - Versions: each member's in the members card and avatar tooltip, the server's in the card header; the strip no longer shows it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
84 lines
3.1 KiB
Dart
84 lines
3.1 KiB
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:hive_ce_flutter/hive_flutter.dart';
|
|
import 'package:media_kit/media_kit.dart';
|
|
import 'package:sync_relay_core/core.dart';
|
|
|
|
import 'app.dart';
|
|
import 'src/platform/app_log.dart';
|
|
import 'src/platform/app_shutdown.dart';
|
|
import 'src/platform/desktop/desktop_app_dirs.dart';
|
|
import 'src/platform/desktop_entry.dart';
|
|
import 'src/screens/home/ui.dart';
|
|
import 'src/session/app_events.dart' show UpdateAvailable;
|
|
import 'src/state/session_state.dart';
|
|
import 'src/state/settings.dart';
|
|
import 'src/update/update_controller.dart' show UpdateController, UpdatePhase, launchArgs;
|
|
|
|
Future<void> main(List<String> args) async {
|
|
launchArgs = List.unmodifiable(args);
|
|
if (args.contains('--upgrade')) {
|
|
exitCode = await runUpgrade();
|
|
exit(exitCode);
|
|
}
|
|
initLogging();
|
|
FlutterError.onError = (details) {
|
|
debugPrint('FLUTTER ERROR: ${details.exceptionAsString()}\n${details.stack}');
|
|
FlutterError.presentError(details);
|
|
};
|
|
ErrorWidget.builder = (details) => Material(
|
|
color: const Color(0xFF101010),
|
|
child: Center(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Text(
|
|
'Something broke rendering this view:\n${details.exceptionAsString()}',
|
|
style: const TextStyle(color: Colors.white),
|
|
textAlign: TextAlign.center,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
final dirs = await const DesktopAppDirs().resolve();
|
|
await startAppLogging(dirs);
|
|
Hive.init(dirs.hive);
|
|
await AppSettings.instance.ensureLoaded();
|
|
// Close button / Alt+F4: the orderly close ([shutDownApp]), so others
|
|
// see "left", a hosted server shuts down and no player outlives the
|
|
// engine.
|
|
final ports = SessionState.instance.ports;
|
|
await ports.shell.start(
|
|
title: dirs.profile == null ? appName : '$appName [${dirs.profile}]', onCloseRequest: shutDownApp);
|
|
// Focus, minimise and restore feed auto sit-out and the Notifier (in
|
|
// the background, notices go out as system notifications).
|
|
ports.shell.watchActivity((a) {
|
|
SessionState.instance.coordinator.windowActivity(a);
|
|
SessionState.instance.notifier.window = a;
|
|
});
|
|
try {
|
|
await SessionState.instance.loadForm();
|
|
} catch (e, st) {
|
|
debugPrint('load connect form failed: $e\n$st');
|
|
}
|
|
MediaKit.ensureInitialized();
|
|
// yt-dlp for web page links: downloaded on first run, kept current.
|
|
ports.links.warmUp();
|
|
// Linux: the launcher entry and icon Wayland needs (release installs).
|
|
unawaited(installDesktopEntry());
|
|
// A found update is an event too (the band shows it).
|
|
final updates = UpdateController.instance;
|
|
updates.status.addListener(() {
|
|
final s = updates.status.value;
|
|
final version = s.manifest?.version;
|
|
if (s.phase == UpdatePhase.available && version != null) {
|
|
SessionState.instance.notifier.notify(UpdateAvailable(version));
|
|
}
|
|
});
|
|
runApp(const WatchTogetherApp());
|
|
// The sound device opens once the window is up, not on the first sound.
|
|
Future.delayed(const Duration(seconds: 2), SessionState.instance.sfx.warmUp);
|
|
}
|