mirror of
https://github.com/samsonjs/media.git
synced 2026-03-25 09:25:53 +00:00
Only unsubscribe from specified parentId
PiperOrigin-RevId: 422331961
This commit is contained in:
parent
cd56084b3e
commit
86fdbd6f6b
1 changed files with 14 additions and 8 deletions
|
|
@ -183,9 +183,7 @@ import java.util.concurrent.Future;
|
|||
() -> {
|
||||
@Nullable LibraryResult<Void> result = tryGetFutureResult(future);
|
||||
if (result == null || result.resultCode != RESULT_SUCCESS) {
|
||||
synchronized (lock) {
|
||||
subscriptions.remove(checkStateNotNull(browser.getControllerCb()));
|
||||
}
|
||||
removeSubscription(controller, parentId);
|
||||
}
|
||||
},
|
||||
MoreExecutors.directExecutor());
|
||||
|
|
@ -203,11 +201,7 @@ import java.util.concurrent.Future;
|
|||
"onUnsubscribe must return non-null future");
|
||||
|
||||
future.addListener(
|
||||
() -> {
|
||||
synchronized (lock) {
|
||||
subscriptions.remove(checkStateNotNull(browser.getControllerCb()));
|
||||
}
|
||||
},
|
||||
() -> removeSubscription(checkStateNotNull(browser.getControllerCb()), parentId),
|
||||
MoreExecutors.directExecutor());
|
||||
|
||||
return future;
|
||||
|
|
@ -307,4 +301,16 @@ import java.util.concurrent.Future;
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void removeSubscription(ControllerCb controllerCb, String parentId) {
|
||||
synchronized (lock) {
|
||||
@Nullable Set<String> subscription = subscriptions.get(controllerCb);
|
||||
if (subscription != null) {
|
||||
subscription.remove(parentId);
|
||||
if (subscription.isEmpty()) {
|
||||
subscriptions.remove(controllerCb);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue