Dont lock clients when disabling

This commit is contained in:
Kelvin 2025-07-07 16:42:37 +02:00
commit 01cb544dfd

View file

@ -395,8 +395,9 @@ class StatePlatform {
}
suspend fun selectClients(afterLoad: (() -> Unit)?, vararg ids: String) {
withContext(Dispatchers.IO) {
var removed: MutableList<IPlatformClient>;
synchronized(_clientsLock) {
val removed = _enabledClients.toMutableList();
removed = _enabledClients.toMutableList();
_enabledClients.clear();
for (id in ids) {
val client = getClient(id);
@ -412,12 +413,12 @@ class StatePlatform {
}
_enabledClientsPersistent.set(*ids);
_enabledClientsPersistent.save();
}
for (oldClient in removed) {
oldClient.disable();
onSourceDisabled.emit(oldClient);
}
}
afterLoad?.invoke();
};
}