Migrates the check if stream is online to a single compose object.
This commit is contained in:
@@ -54,6 +54,7 @@ import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists
|
import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.CheckIfUrlIsOnline
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.EndedFlag
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.EndedFlag
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.LiveFlag
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.LiveFlag
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.OfflineFlag
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.OfflineFlag
|
||||||
@@ -418,16 +419,6 @@ fun RenderLiveActivityThumb(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
var isOnline by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
LaunchedEffect(key1 = card.media) {
|
|
||||||
accountViewModel.checkIsOnline(card.media) { newIsOnline ->
|
|
||||||
if (isOnline != newIsOnline) {
|
|
||||||
isOnline = newIsOnline
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier.fillMaxWidth()
|
modifier = Modifier.fillMaxWidth()
|
||||||
) {
|
) {
|
||||||
@@ -453,15 +444,20 @@ fun RenderLiveActivityThumb(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box(Modifier.padding(10.dp)) {
|
Box(Modifier.padding(10.dp)) {
|
||||||
Crossfade(targetState = card.status) {
|
Crossfade(targetState = card.status, label = "RenderLiveActivityThumb") {
|
||||||
when (it) {
|
when (it) {
|
||||||
STATUS_LIVE -> {
|
STATUS_LIVE -> {
|
||||||
if (card.media.isNullOrBlank()) {
|
val url = card.media
|
||||||
LiveFlag()
|
if (url.isNullOrBlank()) {
|
||||||
} else if (isOnline) {
|
|
||||||
LiveFlag()
|
LiveFlag()
|
||||||
} else {
|
} else {
|
||||||
OfflineFlag()
|
CheckIfUrlIsOnline(url, accountViewModel) { isOnline ->
|
||||||
|
if (isOnline) {
|
||||||
|
LiveFlag()
|
||||||
|
} else {
|
||||||
|
OfflineFlag()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STATUS_ENDED -> {
|
STATUS_ENDED -> {
|
||||||
|
|||||||
@@ -115,6 +115,8 @@ import com.vitorpamplona.amethyst.ui.components.imageExtensions
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists
|
import com.vitorpamplona.amethyst.ui.screen.equalImmutableLists
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.CheckIfUrlIsOnline
|
||||||
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.CrossfadeCheckIfUrlIsOnline
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.JoinCommunityButton
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.JoinCommunityButton
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.LeaveCommunityButton
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.LeaveCommunityButton
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.LiveFlag
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.LiveFlag
|
||||||
@@ -188,6 +190,7 @@ import com.vitorpamplona.quartz.events.GenericRepostEvent
|
|||||||
import com.vitorpamplona.quartz.events.HighlightEvent
|
import com.vitorpamplona.quartz.events.HighlightEvent
|
||||||
import com.vitorpamplona.quartz.events.LiveActivitiesChatMessageEvent
|
import com.vitorpamplona.quartz.events.LiveActivitiesChatMessageEvent
|
||||||
import com.vitorpamplona.quartz.events.LiveActivitiesEvent
|
import com.vitorpamplona.quartz.events.LiveActivitiesEvent
|
||||||
|
import com.vitorpamplona.quartz.events.LiveActivitiesEvent.Companion.STATUS_ENDED
|
||||||
import com.vitorpamplona.quartz.events.LiveActivitiesEvent.Companion.STATUS_LIVE
|
import com.vitorpamplona.quartz.events.LiveActivitiesEvent.Companion.STATUS_LIVE
|
||||||
import com.vitorpamplona.quartz.events.LiveActivitiesEvent.Companion.STATUS_PLANNED
|
import com.vitorpamplona.quartz.events.LiveActivitiesEvent.Companion.STATUS_PLANNED
|
||||||
import com.vitorpamplona.quartz.events.LongTextNoteEvent
|
import com.vitorpamplona.quartz.events.LongTextNoteEvent
|
||||||
@@ -626,7 +629,7 @@ fun LongCommunityHeader(
|
|||||||
Column(
|
Column(
|
||||||
Modifier.weight(1f)
|
Modifier.weight(1f)
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = CenterVertically) {
|
||||||
val defaultBackground = MaterialTheme.colorScheme.background
|
val defaultBackground = MaterialTheme.colorScheme.background
|
||||||
val background = remember {
|
val background = remember {
|
||||||
mutableStateOf(defaultBackground)
|
mutableStateOf(defaultBackground)
|
||||||
@@ -656,7 +659,7 @@ fun LongCommunityHeader(
|
|||||||
|
|
||||||
Row(
|
Row(
|
||||||
lineModifier,
|
lineModifier,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = CenterVertically
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.owner),
|
text = stringResource(id = R.string.owner),
|
||||||
@@ -693,7 +696,7 @@ fun LongCommunityHeader(
|
|||||||
lineModifier.clickable {
|
lineModifier.clickable {
|
||||||
nav("User/${it.second.pubkeyHex}")
|
nav("User/${it.second.pubkeyHex}")
|
||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = CenterVertically
|
||||||
) {
|
) {
|
||||||
it.first.role?.let { it1 ->
|
it.first.role?.let { it1 ->
|
||||||
Text(
|
Text(
|
||||||
@@ -712,7 +715,7 @@ fun LongCommunityHeader(
|
|||||||
|
|
||||||
Row(
|
Row(
|
||||||
lineModifier,
|
lineModifier,
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = CenterVertically
|
||||||
) {
|
) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(id = R.string.created_at),
|
text = stringResource(id = R.string.created_at),
|
||||||
@@ -735,7 +738,7 @@ fun ShortCommunityHeader(baseNote: AddressableNote, accountViewModel: AccountVie
|
|||||||
accountViewModel.settings.showProfilePictures.value
|
accountViewModel.settings.showProfilePictures.value
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = CenterVertically) {
|
||||||
noteEvent.image()?.let {
|
noteEvent.image()?.let {
|
||||||
RobohashAsyncImageProxy(
|
RobohashAsyncImageProxy(
|
||||||
robot = baseNote.idHex,
|
robot = baseNote.idHex,
|
||||||
@@ -754,7 +757,7 @@ fun ShortCommunityHeader(baseNote: AddressableNote, accountViewModel: AccountVie
|
|||||||
.weight(1f),
|
.weight(1f),
|
||||||
verticalArrangement = Arrangement.Center
|
verticalArrangement = Arrangement.Center
|
||||||
) {
|
) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = CenterVertically) {
|
||||||
Text(
|
Text(
|
||||||
text = remember(noteState) { noteEvent.dTag() },
|
text = remember(noteState) { noteEvent.dTag() },
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
@@ -767,7 +770,7 @@ fun ShortCommunityHeader(baseNote: AddressableNote, accountViewModel: AccountVie
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(Size35dp)
|
.height(Size35dp)
|
||||||
.padding(start = 5.dp),
|
.padding(start = 5.dp),
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = CenterVertically
|
||||||
) {
|
) {
|
||||||
ShortCommunityActionOptions(baseNote, accountViewModel, nav)
|
ShortCommunityActionOptions(baseNote, accountViewModel, nav)
|
||||||
}
|
}
|
||||||
@@ -1549,7 +1552,7 @@ fun RenderAppDefinition(
|
|||||||
|
|
||||||
val website = remember(it) { it.website }
|
val website = remember(it) { it.website }
|
||||||
if (!website.isNullOrEmpty()) {
|
if (!website.isNullOrEmpty()) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
Row(verticalAlignment = CenterVertically) {
|
||||||
LinkIcon(Size16Modifier, MaterialTheme.colorScheme.placeholderText)
|
LinkIcon(Size16Modifier, MaterialTheme.colorScheme.placeholderText)
|
||||||
|
|
||||||
ClickableText(
|
ClickableText(
|
||||||
@@ -1770,7 +1773,7 @@ fun DisplayRelaySet(
|
|||||||
|
|
||||||
if (relays.size > 3 && !expanded) {
|
if (relays.size > 3 && !expanded) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
horizontalArrangement = Arrangement.Center,
|
horizontalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
@@ -1874,7 +1877,7 @@ fun DisplayPeopleList(
|
|||||||
|
|
||||||
if (members.size > 3 && !expanded) {
|
if (members.size > 3 && !expanded) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
horizontalArrangement = Arrangement.Center,
|
horizontalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
@@ -1918,7 +1921,7 @@ private fun RenderBadgeAward(
|
|||||||
.clickable {
|
.clickable {
|
||||||
nav("User/${user.pubkeyHex}")
|
nav("User/${user.pubkeyHex}")
|
||||||
},
|
},
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = CenterVertically
|
||||||
) {
|
) {
|
||||||
ClickableUserPicture(
|
ClickableUserPicture(
|
||||||
baseUser = user,
|
baseUser = user,
|
||||||
@@ -2186,7 +2189,7 @@ public fun RenderEmojiPack(
|
|||||||
|
|
||||||
if (allEmojis.size > 60 && !expanded) {
|
if (allEmojis.size > 60 && !expanded) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
horizontalArrangement = Arrangement.Center,
|
horizontalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
@@ -2336,7 +2339,7 @@ fun RenderPinListEvent(
|
|||||||
|
|
||||||
if (pins.size > 3 && !expanded) {
|
if (pins.size > 3 && !expanded) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
horizontalArrangement = Arrangement.Center,
|
horizontalArrangement = Arrangement.Center,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.align(Alignment.BottomCenter)
|
.align(Alignment.BottomCenter)
|
||||||
@@ -3212,7 +3215,7 @@ fun DisplayReward(
|
|||||||
|
|
||||||
Column() {
|
Column() {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier.clickable { popupExpanded = true }
|
modifier = Modifier.clickable { popupExpanded = true }
|
||||||
) {
|
) {
|
||||||
ClickableText(
|
ClickableText(
|
||||||
@@ -3519,7 +3522,7 @@ fun AudioTrackHeader(noteEvent: AudioTrackEvent, note: Note, accountViewModel: A
|
|||||||
Column(modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
|
Column(modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
Row() {
|
Row() {
|
||||||
subject?.let {
|
subject?.let {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically, modifier = Modifier.padding(top = 5.dp, bottom = 5.dp)) {
|
Row(verticalAlignment = CenterVertically, modifier = Modifier.padding(top = 5.dp, bottom = 5.dp)) {
|
||||||
Text(
|
Text(
|
||||||
text = it,
|
text = it,
|
||||||
fontWeight = FontWeight.Bold,
|
fontWeight = FontWeight.Bold,
|
||||||
@@ -3533,7 +3536,7 @@ fun AudioTrackHeader(noteEvent: AudioTrackEvent, note: Note, accountViewModel: A
|
|||||||
|
|
||||||
participantUsers.forEach {
|
participantUsers.forEach {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(top = 5.dp, start = 10.dp, end = 10.dp)
|
.padding(top = 5.dp, start = 10.dp, end = 10.dp)
|
||||||
.clickable {
|
.clickable {
|
||||||
@@ -3556,7 +3559,7 @@ fun AudioTrackHeader(noteEvent: AudioTrackEvent, note: Note, accountViewModel: A
|
|||||||
|
|
||||||
media?.let { media ->
|
media?.let { media ->
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = CenterVertically
|
||||||
) {
|
) {
|
||||||
cover?.let { cover ->
|
cover?.let { cover ->
|
||||||
LoadThumbAndThenVideoView(
|
LoadThumbAndThenVideoView(
|
||||||
@@ -3607,7 +3610,7 @@ fun AudioHeader(noteEvent: AudioHeaderEvent, note: Note, accountViewModel: Accou
|
|||||||
Column(modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
|
Column(modifier = Modifier.fillMaxWidth(), horizontalAlignment = Alignment.CenterHorizontally) {
|
||||||
media?.let { media ->
|
media?.let { media ->
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically
|
verticalAlignment = CenterVertically
|
||||||
) {
|
) {
|
||||||
VideoView(
|
VideoView(
|
||||||
videoUri = media,
|
videoUri = media,
|
||||||
@@ -3639,7 +3642,7 @@ fun AudioHeader(noteEvent: AudioHeaderEvent, note: Note, accountViewModel: Accou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.fillMaxWidth(), verticalAlignment = CenterVertically) {
|
||||||
val hashtags = remember(noteEvent) { noteEvent.hashtags().toImmutableList() }
|
val hashtags = remember(noteEvent) { noteEvent.hashtags().toImmutableList() }
|
||||||
DisplayUncitedHashtags(hashtags, content ?: "", nav)
|
DisplayUncitedHashtags(hashtags, content ?: "", nav)
|
||||||
}
|
}
|
||||||
@@ -3673,16 +3676,6 @@ fun RenderLiveActivityEventInner(baseNote: Note, accountViewModel: AccountViewMo
|
|||||||
val status = remember(eventUpdates) { noteEvent.status() }
|
val status = remember(eventUpdates) { noteEvent.status() }
|
||||||
val starts = remember(eventUpdates) { noteEvent.starts() }
|
val starts = remember(eventUpdates) { noteEvent.starts() }
|
||||||
|
|
||||||
var isOnline by remember { mutableStateOf(false) }
|
|
||||||
|
|
||||||
LaunchedEffect(key1 = media) {
|
|
||||||
accountViewModel.checkIsOnline(media) { newIsOnline ->
|
|
||||||
if (isOnline != newIsOnline) {
|
|
||||||
isOnline = newIsOnline
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
@@ -3701,11 +3694,13 @@ fun RenderLiveActivityEventInner(baseNote: Note, accountViewModel: AccountViewMo
|
|||||||
|
|
||||||
Spacer(modifier = StdHorzSpacer)
|
Spacer(modifier = StdHorzSpacer)
|
||||||
|
|
||||||
Crossfade(targetState = status) {
|
Crossfade(targetState = status, label = "RenderLiveActivityEventInner") {
|
||||||
when (it) {
|
when (it) {
|
||||||
STATUS_LIVE -> {
|
STATUS_LIVE -> {
|
||||||
if (isOnline) {
|
media?.let {
|
||||||
LiveFlag()
|
CrossfadeCheckIfUrlIsOnline(it, accountViewModel) {
|
||||||
|
LiveFlag()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
STATUS_PLANNED -> {
|
STATUS_PLANNED -> {
|
||||||
@@ -3731,7 +3726,7 @@ fun RenderLiveActivityEventInner(baseNote: Note, accountViewModel: AccountViewMo
|
|||||||
|
|
||||||
participantUsers.forEach {
|
participantUsers.forEach {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(top = 5.dp, start = 10.dp, end = 10.dp)
|
.padding(top = 5.dp, start = 10.dp, end = 10.dp)
|
||||||
.clickable {
|
.clickable {
|
||||||
@@ -3754,37 +3749,39 @@ fun RenderLiveActivityEventInner(baseNote: Note, accountViewModel: AccountViewMo
|
|||||||
|
|
||||||
media?.let { media ->
|
media?.let { media ->
|
||||||
if (status == STATUS_LIVE) {
|
if (status == STATUS_LIVE) {
|
||||||
if (isOnline) {
|
CheckIfUrlIsOnline(media, accountViewModel) { isOnline ->
|
||||||
Row(
|
if (isOnline) {
|
||||||
verticalAlignment = Alignment.CenterVertically
|
Row(
|
||||||
) {
|
verticalAlignment = CenterVertically
|
||||||
VideoView(
|
) {
|
||||||
videoUri = media,
|
VideoView(
|
||||||
title = subject,
|
videoUri = media,
|
||||||
artworkUri = cover,
|
title = subject,
|
||||||
authorName = baseNote.author?.toBestDisplayName(),
|
artworkUri = cover,
|
||||||
roundedCorner = true,
|
authorName = baseNote.author?.toBestDisplayName(),
|
||||||
accountViewModel = accountViewModel,
|
roundedCorner = true,
|
||||||
nostrUriCallback = "nostr:${baseNote.toNEvent()}"
|
accountViewModel = accountViewModel,
|
||||||
)
|
nostrUriCallback = "nostr:${baseNote.toNEvent()}"
|
||||||
}
|
)
|
||||||
} else {
|
}
|
||||||
Row(
|
} else {
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
Row(
|
||||||
modifier = Modifier
|
verticalAlignment = CenterVertically,
|
||||||
.padding(10.dp)
|
modifier = Modifier
|
||||||
.height(100.dp)
|
.padding(10.dp)
|
||||||
) {
|
.height(100.dp)
|
||||||
Text(
|
) {
|
||||||
text = stringResource(id = R.string.live_stream_is_offline),
|
Text(
|
||||||
color = MaterialTheme.colorScheme.onBackground,
|
text = stringResource(id = R.string.live_stream_is_offline),
|
||||||
fontWeight = FontWeight.Bold
|
color = MaterialTheme.colorScheme.onBackground,
|
||||||
)
|
fontWeight = FontWeight.Bold
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (status == "ended") {
|
} else if (status == STATUS_ENDED) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = CenterVertically,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.padding(10.dp)
|
.padding(10.dp)
|
||||||
.height(100.dp)
|
.height(100.dp)
|
||||||
@@ -3892,7 +3889,7 @@ private fun RenderClassifieds(noteEvent: ClassifiedsEvent, note: Note, accountVi
|
|||||||
} ?: CreateImageHeader(note, accountViewModel)
|
} ?: CreateImageHeader(note, accountViewModel)
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(Modifier.padding(start = 10.dp, end = 10.dp, top = 10.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.padding(start = 10.dp, end = 10.dp, top = 10.dp), verticalAlignment = CenterVertically) {
|
||||||
title?.let {
|
title?.let {
|
||||||
Text(
|
Text(
|
||||||
text = it,
|
text = it,
|
||||||
@@ -3929,7 +3926,7 @@ private fun RenderClassifieds(noteEvent: ClassifiedsEvent, note: Note, accountVi
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (summary != null || location != null) {
|
if (summary != null || location != null) {
|
||||||
Row(Modifier.padding(start = 10.dp, end = 10.dp, top = 5.dp), verticalAlignment = Alignment.CenterVertically) {
|
Row(Modifier.padding(start = 10.dp, end = 10.dp, top = 5.dp), verticalAlignment = CenterVertically) {
|
||||||
summary?.let {
|
summary?.let {
|
||||||
Text(
|
Text(
|
||||||
text = it,
|
text = it,
|
||||||
|
|||||||
@@ -654,7 +654,7 @@ fun ShowVideoStreaming(
|
|||||||
}
|
}
|
||||||
|
|
||||||
url?.let {
|
url?.let {
|
||||||
CheckIfUrlIsOnline(url, accountViewModel) {
|
CrossfadeCheckIfUrlIsOnline(url, accountViewModel) {
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
modifier = remember { Modifier.heightIn(max = 300.dp) }
|
modifier = remember { Modifier.heightIn(max = 300.dp) }
|
||||||
|
|||||||
@@ -166,7 +166,26 @@ private fun HomePages(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun CheckIfUrlIsOnline(url: String, accountViewModel: AccountViewModel, whenOnline: @Composable () -> Unit) {
|
fun CheckIfUrlIsOnline(url: String, accountViewModel: AccountViewModel, whenOnline: @Composable (Boolean) -> Unit) {
|
||||||
|
var online by remember {
|
||||||
|
mutableStateOf(
|
||||||
|
OnlineChecker.isOnlineCached(url)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
LaunchedEffect(key1 = url) {
|
||||||
|
accountViewModel.checkIsOnline(url) { isOnline ->
|
||||||
|
if (online != isOnline) {
|
||||||
|
online = isOnline
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
whenOnline(online)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CrossfadeCheckIfUrlIsOnline(url: String, accountViewModel: AccountViewModel, whenOnline: @Composable () -> Unit) {
|
||||||
var online by remember {
|
var online by remember {
|
||||||
mutableStateOf(
|
mutableStateOf(
|
||||||
OnlineChecker.isOnlineCached(url)
|
OnlineChecker.isOnlineCached(url)
|
||||||
|
|||||||
Reference in New Issue
Block a user