mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-20 05:09:51 -04:00
skip restart if existing veilidcore instance is running
This commit is contained in:
parent
2344184620
commit
3640d32e02
1 changed files with 30 additions and 31 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue