diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt index 36fc9474c..87c91c143 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/reqCommand/account/follows/AccountFollowsLoaderSubAssembler.kt @@ -186,11 +186,11 @@ class AccountFollowsLoaderSubAssembler( } // removes accounts that are not being subscribed anymore. - accountUpdatesJobMap.forEach { - if (it.key !in uniqueSubscribedAccounts.keys) { - endWatcher(it.key) - } - } + // Cancel watchers for accounts no longer observed using a snapshot to avoid CME + accountUpdatesJobMap.keys + .toList() + .filter { it !in uniqueSubscribedAccounts.keys } + .forEach { endWatcher(it) } } private val accountUpdatesJobMap = mutableMapOf()