Added withContext(Dispatchers.IO) for network call
This commit is contained in:
+11
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
package com.vitorpamplona.amethyst.ui.screen.loggedIn.home.live
|
||||
|
||||
import android.util.Log
|
||||
import androidx.compose.foundation.Canvas
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.runtime.Composable
|
||||
@@ -36,7 +37,9 @@ import com.vitorpamplona.amethyst.model.emphChat.EphemeralChatChannel
|
||||
import com.vitorpamplona.amethyst.model.nip53LiveActivities.LiveActivitiesChannel
|
||||
import com.vitorpamplona.amethyst.service.OnlineChecker
|
||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@Composable
|
||||
fun LiveStatusIndicator(
|
||||
@@ -75,6 +78,8 @@ private suspend fun checkChannelIsOnline(
|
||||
channel: Channel,
|
||||
accountViewModel: AccountViewModel,
|
||||
): Boolean =
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
when (channel) {
|
||||
is LiveActivitiesChannel -> {
|
||||
// Check if streaming URL is online, fall back to relay check
|
||||
@@ -98,3 +103,9 @@ private suspend fun checkChannelIsOnline(
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Log.d("LiveStatusIndicator", "Network error checking channel ${channel.toBestDisplayName()}: ${e.message}")
|
||||
// Return false if any network error occurs
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user