Label machine provenance and choose server before chat harness
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import '../../features/settings/server_connections.dart';
|
||||
|
||||
/// The machine owning this mounted app. A profile rename rebuilds consumers;
|
||||
/// changing machines creates a new gateway and app instead.
|
||||
class ServerContext extends InheritedNotifier<ServerConnections> {
|
||||
const ServerContext({
|
||||
super.key,
|
||||
required ServerConnections connections,
|
||||
required this.serverId,
|
||||
required super.child,
|
||||
}) : super(notifier: connections);
|
||||
|
||||
final String? serverId;
|
||||
static ServerContext? maybeOf(BuildContext context) =>
|
||||
context.dependOnInheritedWidgetOfExactType<ServerContext>();
|
||||
|
||||
String? get name {
|
||||
for (final server in notifier!.catalog.servers) {
|
||||
if (server.id == serverId) return server.name;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
static String metadata(BuildContext context, String detail) =>
|
||||
[?maybeOf(context)?.name, if (detail.isNotEmpty) detail].join(' · ');
|
||||
}
|
||||
Reference in New Issue
Block a user