Skip to content

Commit c8dffd9

Browse files
committed
Remove last continuation from pendingDecisions when cancelled
1 parent 737118b commit c8dffd9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/src/main/java/at/bitfire/cert4android/UserDecisionRegistry.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,17 @@ class UserDecisionRegistry private constructor(
5353
// User decision possible → remember request in pendingDecisions so that a later decision will be applied to this request
5454

5555
cont.invokeOnCancellation {
56+
val decisionsList = pendingDecisions[cert]
57+
5658
// remove from pending decisions on cancellation
5759
synchronized(pendingDecisions) {
58-
pendingDecisions[cert]?.remove(cont)
60+
decisionsList?.remove(cont)
5961
}
6062

63+
// Remove decisions list if empty
64+
if (decisionsList?.isEmpty() == true)
65+
pendingDecisions.remove(cert)
66+
6167
val nm = NotificationUtils.createChannels(context)
6268
nm.cancel(CertUtils.getTag(cert), NotificationUtils.ID_CERT_DECISION)
6369
}

0 commit comments

Comments
 (0)