Marks GlobalScope as optin
This commit is contained in:
@@ -3745,32 +3745,38 @@ class Account(
|
|||||||
settings.backupContactList?.let {
|
settings.backupContactList?.let {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved contacts ${it.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved contacts ${it.toJson()}")
|
||||||
|
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) { LocalCache.consume(it) }
|
GlobalScope.launch(Dispatchers.IO) { LocalCache.consume(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.backupUserMetadata?.let {
|
settings.backupUserMetadata?.let {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved user metadata ${it.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved user metadata ${it.toJson()}")
|
||||||
|
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) { LocalCache.consume(it, null) }
|
GlobalScope.launch(Dispatchers.IO) { LocalCache.consume(it, null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.backupDMRelayList?.let {
|
settings.backupDMRelayList?.let {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved DM Relay List ${it.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved DM Relay List ${it.toJson()}")
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.backupNIP65RelayList?.let {
|
settings.backupNIP65RelayList?.let {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved nip65 relay list ${it.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved nip65 relay list ${it.toJson()}")
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.backupSearchRelayList?.let {
|
settings.backupSearchRelayList?.let {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved search relay list ${it.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved search relay list ${it.toJson()}")
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
settings.backupPrivateHomeRelayList?.let { event ->
|
settings.backupPrivateHomeRelayList?.let { event ->
|
||||||
Log.d("AccountRegisterObservers", "Loading saved private home relay list ${event.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved private home relay list ${event.toJson()}")
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
event.privateTags(signer) {
|
event.privateTags(signer) {
|
||||||
LocalCache.verifyAndConsume(event, null)
|
LocalCache.verifyAndConsume(event, null)
|
||||||
@@ -3780,6 +3786,7 @@ class Account(
|
|||||||
|
|
||||||
settings.backupAppSpecificData?.let { event ->
|
settings.backupAppSpecificData?.let { event ->
|
||||||
Log.d("AccountRegisterObservers", "Loading saved app specific data ${event.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved app specific data ${event.toJson()}")
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
LocalCache.verifyAndConsume(event, null)
|
LocalCache.verifyAndConsume(event, null)
|
||||||
signer.decrypt(event.content, event.pubKey) { decrypted ->
|
signer.decrypt(event.content, event.pubKey) { decrypted ->
|
||||||
@@ -3798,6 +3805,7 @@ class Account(
|
|||||||
|
|
||||||
settings.backupMuteList?.let {
|
settings.backupMuteList?.let {
|
||||||
Log.d("AccountRegisterObservers", "Loading saved mute list ${it.toJson()}")
|
Log.d("AccountRegisterObservers", "Loading saved mute list ${it.toJson()}")
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
GlobalScope.launch(Dispatchers.IO) { LocalCache.verifyAndConsume(it, null) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -70,7 +70,7 @@ fun AnimatedSaveButton(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@kotlin.OptIn(ExperimentalPermissionsApi::class)
|
@OptIn(ExperimentalPermissionsApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
fun SaveButton(onSaveClick: (localContext: Context) -> Unit) {
|
fun SaveButton(onSaveClick: (localContext: Context) -> Unit) {
|
||||||
Box(modifier = PinBottomIconSize) {
|
Box(modifier = PinBottomIconSize) {
|
||||||
|
|||||||
+3
@@ -35,6 +35,7 @@ import com.google.common.util.concurrent.Futures
|
|||||||
import com.google.common.util.concurrent.ListenableFuture
|
import com.google.common.util.concurrent.ListenableFuture
|
||||||
import com.vitorpamplona.amethyst.ui.MainActivity
|
import com.vitorpamplona.amethyst.ui.MainActivity
|
||||||
import com.vitorpamplona.quartz.utils.TimeUtils
|
import com.vitorpamplona.quartz.utils.TimeUtils
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -130,6 +131,7 @@ class MediaSessionPool(
|
|||||||
fun cleanupUnused() {
|
fun cleanupUnused() {
|
||||||
if (lastCleanup < TimeUtils.oneMinuteAgo()) {
|
if (lastCleanup < TimeUtils.oneMinuteAgo()) {
|
||||||
lastCleanup = TimeUtils.now()
|
lastCleanup = TimeUtils.now()
|
||||||
|
@kotlin.OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
var counter = 0
|
var counter = 0
|
||||||
val snap = cache.snapshot()
|
val snap = cache.snapshot()
|
||||||
@@ -149,6 +151,7 @@ class MediaSessionPool(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun destroy() {
|
fun destroy() {
|
||||||
|
@kotlin.OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
cache.evictAll()
|
cache.evictAll()
|
||||||
playingMap.forEach {
|
playingMap.forEach {
|
||||||
|
|||||||
+2
@@ -28,6 +28,7 @@ import androidx.media3.session.MediaController
|
|||||||
import androidx.media3.session.SessionToken
|
import androidx.media3.session.SessionToken
|
||||||
import com.vitorpamplona.amethyst.service.playback.composable.MediaControllerState
|
import com.vitorpamplona.amethyst.service.playback.composable.MediaControllerState
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
@@ -45,6 +46,7 @@ object PlaybackServiceClient {
|
|||||||
// release when can
|
// release when can
|
||||||
if (myController != null) {
|
if (myController != null) {
|
||||||
mediaControllerState.controller = null
|
mediaControllerState.controller = null
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.Main) {
|
GlobalScope.launch(Dispatchers.Main) {
|
||||||
// myController.pause()
|
// myController.pause()
|
||||||
// myController.stop()
|
// myController.stop()
|
||||||
|
|||||||
@@ -100,8 +100,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
Log.d("ActivityLifecycle", "MainActivity.onPause $this")
|
Log.d("ActivityLifecycle", "MainActivity.onPause $this")
|
||||||
|
|
||||||
GlobalScope.launch(Dispatchers.IO) { LanguageTranslatorService.clear() }
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
|
LanguageTranslatorService.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
debugState(this@MainActivity)
|
debugState(this@MainActivity)
|
||||||
Amethyst.instance.sources.printCounters()
|
Amethyst.instance.sources.printCounters()
|
||||||
@@ -114,6 +118,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
super.onStop()
|
super.onStop()
|
||||||
|
|
||||||
// Graph doesn't completely clear.
|
// Graph doesn't completely clear.
|
||||||
|
// @OptIn(DelicateCoroutinesApi::class)
|
||||||
// GlobalScope.launch(Dispatchers.Default) {
|
// GlobalScope.launch(Dispatchers.Default) {
|
||||||
// serviceManager.trimMemory()
|
// serviceManager.trimMemory()
|
||||||
// }
|
// }
|
||||||
|
|||||||
+4
-3
@@ -25,6 +25,7 @@ import androidx.compose.foundation.layout.Row
|
|||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material.icons.Icons
|
import androidx.compose.material.icons.Icons
|
||||||
|
import androidx.compose.material.icons.automirrored.filled.OpenInNew
|
||||||
import androidx.compose.material.icons.filled.OpenInNew
|
import androidx.compose.material.icons.filled.OpenInNew
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.IconButton
|
import androidx.compose.material3.IconButton
|
||||||
@@ -306,7 +307,7 @@ fun DisplayStatusInner(
|
|||||||
onClick = { runCatching { uri.openUri(url.trim()) } },
|
onClick = { runCatching { uri.openUri(url.trim()) } },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.OpenInNew,
|
imageVector = Icons.AutoMirrored.Filled.OpenInNew,
|
||||||
null,
|
null,
|
||||||
modifier = Size15Modifier,
|
modifier = Size15Modifier,
|
||||||
tint = MaterialTheme.colorScheme.lessImportantLink,
|
tint = MaterialTheme.colorScheme.lessImportantLink,
|
||||||
@@ -326,7 +327,7 @@ fun DisplayStatusInner(
|
|||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.OpenInNew,
|
imageVector = Icons.AutoMirrored.Filled.OpenInNew,
|
||||||
null,
|
null,
|
||||||
modifier = Size15Modifier,
|
modifier = Size15Modifier,
|
||||||
tint = MaterialTheme.colorScheme.lessImportantLink,
|
tint = MaterialTheme.colorScheme.lessImportantLink,
|
||||||
@@ -348,7 +349,7 @@ fun DisplayStatusInner(
|
|||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
imageVector = Icons.Default.OpenInNew,
|
imageVector = Icons.AutoMirrored.Filled.OpenInNew,
|
||||||
null,
|
null,
|
||||||
modifier = Size15Modifier,
|
modifier = Size15Modifier,
|
||||||
tint = MaterialTheme.colorScheme.lessImportantLink,
|
tint = MaterialTheme.colorScheme.lessImportantLink,
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ fun showAmount(amount: BigDecimal?): String {
|
|||||||
if (amount.abs() < BigDecimal(0.01)) return ""
|
if (amount.abs() < BigDecimal(0.01)) return ""
|
||||||
|
|
||||||
return when {
|
return when {
|
||||||
amount >= TenGiga -> dfGBig.get().format(amount.div(OneGiga).setScale(0, RoundingMode.HALF_UP))
|
amount >= TenGiga -> dfGBig.get()!!.format(amount.div(OneGiga).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= OneGiga -> dfGSmall.get().format(amount.div(OneGiga).setScale(0, RoundingMode.HALF_UP))
|
amount >= OneGiga -> dfGSmall.get()!!.format(amount.div(OneGiga).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= TenMega -> dfMBig.get().format(amount.div(OneMega).setScale(0, RoundingMode.HALF_UP))
|
amount >= TenMega -> dfMBig.get()!!.format(amount.div(OneMega).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= OneMega -> dfMSmall.get().format(amount.div(OneMega).setScale(0, RoundingMode.HALF_UP))
|
amount >= OneMega -> dfMSmall.get()!!.format(amount.div(OneMega).setScale(0, RoundingMode.HALF_UP))
|
||||||
amount >= TenKilo -> dfK.get().format(amount.div(OneKilo).setScale(0, RoundingMode.HALF_UP))
|
amount >= TenKilo -> dfK.get()!!.format(amount.div(OneKilo).setScale(0, RoundingMode.HALF_UP))
|
||||||
else -> dfN.get().format(amount)
|
else -> dfN.get()!!.format(amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ import com.vitorpamplona.quartz.nip50Search.SearchRelayListEvent
|
|||||||
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
import com.vitorpamplona.quartz.nip65RelayList.AdvertisedRelayListEvent
|
||||||
import com.vitorpamplona.quartz.utils.Hex
|
import com.vitorpamplona.quartz.utils.Hex
|
||||||
import kotlinx.coroutines.CancellationException
|
import kotlinx.coroutines.CancellationException
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.FlowPreview
|
import kotlinx.coroutines.FlowPreview
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
@@ -314,6 +315,7 @@ class AccountStateViewModel : ViewModel() {
|
|||||||
|
|
||||||
startUI(accountSettings)
|
startUI(accountSettings)
|
||||||
|
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
delay(2000) // waits for the new user to connect to the new relays.
|
delay(2000) // waits for the new user to connect to the new relays.
|
||||||
accountSettings.backupUserMetadata?.let { Amethyst.instance.client.send(it) }
|
accountSettings.backupUserMetadata?.let { Amethyst.instance.client.send(it) }
|
||||||
|
|||||||
@@ -225,6 +225,7 @@ class NostrClient(
|
|||||||
additionalListener?.let { subscribe(it) }
|
additionalListener?.let { subscribe(it) }
|
||||||
|
|
||||||
val job =
|
val job =
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
if (relayList != null) {
|
if (relayList != null) {
|
||||||
send(signedEvent, relayList)
|
send(signedEvent, relayList)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import androidx.compose.runtime.Immutable
|
|||||||
import com.vitorpamplona.ammolite.service.checkNotInMainThread
|
import com.vitorpamplona.ammolite.service.checkNotInMainThread
|
||||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||||
import com.vitorpamplona.quartz.nip01Core.relay.RelayState
|
import com.vitorpamplona.quartz.nip01Core.relay.RelayState
|
||||||
|
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.GlobalScope
|
import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.channels.BufferOverflow
|
import kotlinx.coroutines.channels.BufferOverflow
|
||||||
@@ -72,6 +73,7 @@ class RelayPool : Relay.Listener {
|
|||||||
relay.connectAndRunAfterSync {
|
relay.connectAndRunAfterSync {
|
||||||
whenConnected(relay)
|
whenConnected(relay)
|
||||||
|
|
||||||
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
GlobalScope.launch(Dispatchers.IO) {
|
GlobalScope.launch(Dispatchers.IO) {
|
||||||
delay(timeout) // waits for a reply
|
delay(timeout) // waits for a reply
|
||||||
relay.disconnect()
|
relay.disconnect()
|
||||||
|
|||||||
Reference in New Issue
Block a user