Making sure the service manager stops the relay subscriptions before disconnecting.
This commit is contained in:
@@ -102,23 +102,23 @@ class ServiceManager {
|
|||||||
private fun pause() {
|
private fun pause() {
|
||||||
Log.d("ServiceManager", "Pausing Relay Services")
|
Log.d("ServiceManager", "Pausing Relay Services")
|
||||||
|
|
||||||
NostrAccountDataSource.stop()
|
NostrAccountDataSource.stopSync()
|
||||||
NostrHomeDataSource.stop()
|
NostrHomeDataSource.stopSync()
|
||||||
NostrChannelDataSource.stop()
|
NostrChannelDataSource.stopSync()
|
||||||
NostrChatroomDataSource.stop()
|
NostrChatroomDataSource.stopSync()
|
||||||
NostrChatroomListDataSource.stop()
|
NostrChatroomListDataSource.stopSync()
|
||||||
NostrDiscoveryDataSource.stop()
|
NostrDiscoveryDataSource.stopSync()
|
||||||
|
|
||||||
NostrCommunityDataSource.stop()
|
NostrCommunityDataSource.stopSync()
|
||||||
NostrHashtagDataSource.stop()
|
NostrHashtagDataSource.stopSync()
|
||||||
NostrGeohashDataSource.stop()
|
NostrGeohashDataSource.stopSync()
|
||||||
NostrSearchEventOrUserDataSource.stop()
|
NostrSearchEventOrUserDataSource.stopSync()
|
||||||
NostrSingleChannelDataSource.stop()
|
NostrSingleChannelDataSource.stopSync()
|
||||||
NostrSingleEventDataSource.stop()
|
NostrSingleEventDataSource.stopSync()
|
||||||
NostrSingleUserDataSource.stop()
|
NostrSingleUserDataSource.stopSync()
|
||||||
NostrThreadDataSource.stop()
|
NostrThreadDataSource.stopSync()
|
||||||
NostrUserProfileDataSource.stop()
|
NostrUserProfileDataSource.stopSync()
|
||||||
NostrVideoDataSource.stop()
|
NostrVideoDataSource.stopSync()
|
||||||
|
|
||||||
Client.disconnect()
|
Client.disconnect()
|
||||||
isStarted = false
|
isStarted = false
|
||||||
|
|||||||
@@ -119,6 +119,16 @@ abstract class NostrDataSource(val debugName: String) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun stopSync() {
|
||||||
|
active = false
|
||||||
|
println("DataSource: ${this.javaClass.simpleName} Stop")
|
||||||
|
|
||||||
|
subscriptions.values.forEach { subscription ->
|
||||||
|
Client.close(subscription.id)
|
||||||
|
subscription.typedFilters = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun requestNewChannel(onEOSE: ((Long, String) -> Unit)? = null): Subscription {
|
fun requestNewChannel(onEOSE: ((Long, String) -> Unit)? = null): Subscription {
|
||||||
val newSubscription = Subscription(UUID.randomUUID().toString().substring(0, 4), onEOSE)
|
val newSubscription = Subscription(UUID.randomUUID().toString().substring(0, 4), onEOSE)
|
||||||
subscriptions = subscriptions + Pair(newSubscription.id, newSubscription)
|
subscriptions = subscriptions + Pair(newSubscription.id, newSubscription)
|
||||||
|
|||||||
Reference in New Issue
Block a user