Fix restart service function

by cancelling the source with apiDestroy
This commit is contained in:
S1m 2021-11-26 03:05:02 +01:00
parent e6002a04b8
commit 1aa727b6ef
1 changed files with 4 additions and 1 deletions

View File

@ -29,10 +29,13 @@ val delQueue = emptyList<String>().toMutableList()
private lateinit var mApi: ProviderApi
private lateinit var nextcloudAPI: NextcloudAPI
private lateinit var factory: EventSource.Factory
private lateinit var source: EventSource
fun apiDestroy() {
if (::nextcloudAPI.isInitialized)
nextcloudAPI.stop()
if (::source.isInitialized)
source.cancel()
}
private fun cApi(context: Context, callback: ()->Unit) {
@ -111,7 +114,7 @@ private fun cSync(context: Context, deviceId: String) {
.build()
factory = EventSources.createFactory(client)
factory.newEventSource(request, SSEListener(context))
source = factory.newEventSource(request, SSEListener(context))
Log.d(TAG, "cSync done.")
}