mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-11-10 14:27:29 +01:00
Moving logs from SubscriptionController to the Manager to be able to distinguish between the multiple managers
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.service.relayClient.eoseManagers
|
||||
|
||||
import android.util.Log
|
||||
import com.vitorpamplona.amethyst.isDebug
|
||||
import com.vitorpamplona.ammolite.relays.NostrClient
|
||||
import com.vitorpamplona.ammolite.relays.datasources.SubscriptionController
|
||||
|
||||
@@ -29,6 +31,7 @@ abstract class BaseEoseManager<T>(
|
||||
) {
|
||||
val orchestrator =
|
||||
SubscriptionController(client) {
|
||||
if (isDebug) Log.d("${this.javaClass.simpleName}", "Updating Subscriptions")
|
||||
updateSubscriptions(allKeys())
|
||||
}
|
||||
|
||||
@@ -38,9 +41,30 @@ abstract class BaseEoseManager<T>(
|
||||
|
||||
fun invalidateFilters() = orchestrator.invalidateFilters()
|
||||
|
||||
fun start() = orchestrator.start()
|
||||
fun start() {
|
||||
orchestrator.start()
|
||||
if (isDebug) {
|
||||
Log.d("${this.javaClass.simpleName}", "Start")
|
||||
}
|
||||
}
|
||||
|
||||
fun stop() = orchestrator.stop()
|
||||
fun stop() {
|
||||
orchestrator.stop()
|
||||
if (isDebug) {
|
||||
Log.d("${this.javaClass.simpleName}", "Stop")
|
||||
}
|
||||
}
|
||||
|
||||
fun destroy() = orchestrator.destroy()
|
||||
fun destroy() {
|
||||
orchestrator.destroy()
|
||||
if (isDebug) {
|
||||
Log.d("${this.javaClass.simpleName}", "Destroy, Unsubscribe")
|
||||
}
|
||||
}
|
||||
|
||||
fun init() {
|
||||
if (isDebug) {
|
||||
Log.d("${this.javaClass.simpleName}", "Init, Subscribe")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
*/
|
||||
package com.vitorpamplona.ammolite.relays.datasources
|
||||
|
||||
import android.util.Log
|
||||
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
||||
import com.vitorpamplona.ammolite.relays.NostrClient
|
||||
import com.vitorpamplona.ammolite.relays.Relay
|
||||
@@ -81,20 +80,17 @@ class SubscriptionController(
|
||||
}
|
||||
|
||||
init {
|
||||
Log.d("${this.javaClass.simpleName}", "Init, Subscribe")
|
||||
client.subscribe(clientListener)
|
||||
}
|
||||
|
||||
override fun destroy() {
|
||||
// makes sure to run
|
||||
Log.d("${this.javaClass.simpleName}", "Destroy, Unsubscribe")
|
||||
stop()
|
||||
client.unsubscribe(clientListener)
|
||||
bundler.cancel()
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
Log.d("${this.javaClass.simpleName}", "Start")
|
||||
active = true
|
||||
invalidateFilters()
|
||||
}
|
||||
@@ -102,7 +98,6 @@ class SubscriptionController(
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun stop() {
|
||||
active = false
|
||||
Log.d("${this.javaClass.simpleName}", "Stop")
|
||||
|
||||
subscriptions.forEach { subscription ->
|
||||
client.close(subscription.id)
|
||||
@@ -142,7 +137,6 @@ class SubscriptionController(
|
||||
private fun resetFiltersSuspend() {
|
||||
// only runs one at a time. Ignores the others
|
||||
if (changingFilters.compareAndSet(false, true)) {
|
||||
Log.d("${this.javaClass.simpleName}", "resetFiltersSuspend $active")
|
||||
try {
|
||||
resetFiltersSuspendInner()
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user