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
|
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.NostrClient
|
||||||
import com.vitorpamplona.ammolite.relays.datasources.SubscriptionController
|
import com.vitorpamplona.ammolite.relays.datasources.SubscriptionController
|
||||||
|
|
||||||
@@ -29,6 +31,7 @@ abstract class BaseEoseManager<T>(
|
|||||||
) {
|
) {
|
||||||
val orchestrator =
|
val orchestrator =
|
||||||
SubscriptionController(client) {
|
SubscriptionController(client) {
|
||||||
|
if (isDebug) Log.d("${this.javaClass.simpleName}", "Updating Subscriptions")
|
||||||
updateSubscriptions(allKeys())
|
updateSubscriptions(allKeys())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,9 +41,30 @@ abstract class BaseEoseManager<T>(
|
|||||||
|
|
||||||
fun invalidateFilters() = orchestrator.invalidateFilters()
|
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
|
package com.vitorpamplona.ammolite.relays.datasources
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
import com.vitorpamplona.ammolite.relays.BundledUpdate
|
||||||
import com.vitorpamplona.ammolite.relays.NostrClient
|
import com.vitorpamplona.ammolite.relays.NostrClient
|
||||||
import com.vitorpamplona.ammolite.relays.Relay
|
import com.vitorpamplona.ammolite.relays.Relay
|
||||||
@@ -81,20 +80,17 @@ class SubscriptionController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
Log.d("${this.javaClass.simpleName}", "Init, Subscribe")
|
|
||||||
client.subscribe(clientListener)
|
client.subscribe(clientListener)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun destroy() {
|
override fun destroy() {
|
||||||
// makes sure to run
|
// makes sure to run
|
||||||
Log.d("${this.javaClass.simpleName}", "Destroy, Unsubscribe")
|
|
||||||
stop()
|
stop()
|
||||||
client.unsubscribe(clientListener)
|
client.unsubscribe(clientListener)
|
||||||
bundler.cancel()
|
bundler.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun start() {
|
override fun start() {
|
||||||
Log.d("${this.javaClass.simpleName}", "Start")
|
|
||||||
active = true
|
active = true
|
||||||
invalidateFilters()
|
invalidateFilters()
|
||||||
}
|
}
|
||||||
@@ -102,7 +98,6 @@ class SubscriptionController(
|
|||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
override fun stop() {
|
override fun stop() {
|
||||||
active = false
|
active = false
|
||||||
Log.d("${this.javaClass.simpleName}", "Stop")
|
|
||||||
|
|
||||||
subscriptions.forEach { subscription ->
|
subscriptions.forEach { subscription ->
|
||||||
client.close(subscription.id)
|
client.close(subscription.id)
|
||||||
@@ -142,7 +137,6 @@ class SubscriptionController(
|
|||||||
private fun resetFiltersSuspend() {
|
private fun resetFiltersSuspend() {
|
||||||
// only runs one at a time. Ignores the others
|
// only runs one at a time. Ignores the others
|
||||||
if (changingFilters.compareAndSet(false, true)) {
|
if (changingFilters.compareAndSet(false, true)) {
|
||||||
Log.d("${this.javaClass.simpleName}", "resetFiltersSuspend $active")
|
|
||||||
try {
|
try {
|
||||||
resetFiltersSuspendInner()
|
resetFiltersSuspendInner()
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user