skip restart if existing veilidcore instance is running

This commit is contained in:
Brandon Vandegrift 2025-04-09 01:01:54 -04:00
parent 2344184620
commit 3640d32e02

View file

@ -46,18 +46,10 @@ class ProcessorRepository {
Stream<VeilidUpdate> updateStream;
try {
if (await Veilid.instance.isShutdown()) {
log.debug('Starting VeilidCore');
updateStream = await Veilid.instance
.startupVeilidCore(await getVeilidConfig(kIsWeb, VeilidChatApp.name));
} on VeilidAPIExceptionAlreadyInitialized catch (_) {
log.debug(
'VeilidCore is already started, shutting down and restarting...');
startedUp = true;
await shutdown();
updateStream = await Veilid.instance
.startupVeilidCore(await getVeilidConfig(kIsWeb, VeilidChatApp.name));
}
_updateSubscription = updateStream.listen((update) {
if (update is VeilidLog) {
@ -82,6 +74,13 @@ class ProcessorRepository {
startedUp = true;
await Veilid.instance.attach();
} else {
log.debug('VeilidCore is already started, skipping startup');
startedUp = true;
// TODO: Need a way to get the updateStream and add a listener after it's already started.
// Without this, the app starts up, but things that depend on update stream never get notified.
// Example being the attachment state always shows the detached icon.
}
}
Future<void> shutdown() async {