Fixes Relay Icon rendering.
This commit is contained in:
@@ -539,25 +539,25 @@ private fun RelayBadges(baseNote: Note) {
|
|||||||
@Composable
|
@Composable
|
||||||
fun RenderRelay(dirtyUrl: String) {
|
fun RenderRelay(dirtyUrl: String) {
|
||||||
val uri = LocalUriHandler.current
|
val uri = LocalUriHandler.current
|
||||||
val website = remember {
|
val website = remember(dirtyUrl) {
|
||||||
val cleanUrl = dirtyUrl.removePrefix("wss://").removePrefix("ws://")
|
val cleanUrl = dirtyUrl.removePrefix("wss://").removePrefix("ws://").removeSuffix("/")
|
||||||
"https://$cleanUrl"
|
"https://$cleanUrl"
|
||||||
}
|
}
|
||||||
val iconUrl = remember {
|
val iconUrl = remember(dirtyUrl) {
|
||||||
val cleanUrl = dirtyUrl.removePrefix("wss://").removePrefix("ws://")
|
val cleanUrl = dirtyUrl.removePrefix("wss://").removePrefix("ws://").removeSuffix("/")
|
||||||
"https://$cleanUrl/favicon.ico"
|
"https://$cleanUrl/favicon.ico"
|
||||||
}
|
}
|
||||||
|
|
||||||
val clickableModifier = remember {
|
val clickableModifier = remember(dirtyUrl) {
|
||||||
Modifier
|
Modifier
|
||||||
.size(15.dp)
|
|
||||||
.padding(1.dp)
|
.padding(1.dp)
|
||||||
|
.size(15.dp)
|
||||||
.clickable(onClick = { uri.openUri(website) })
|
.clickable(onClick = { uri.openUri(website) })
|
||||||
}
|
}
|
||||||
|
|
||||||
val iconModifier = remember {
|
val iconModifier = remember(dirtyUrl) {
|
||||||
Modifier
|
Modifier
|
||||||
.size(15.dp)
|
.size(13.dp)
|
||||||
.clip(shape = CircleShape)
|
.clip(shape = CircleShape)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -566,7 +566,7 @@ fun RenderRelay(dirtyUrl: String) {
|
|||||||
) {
|
) {
|
||||||
RobohashFallbackAsyncImage(
|
RobohashFallbackAsyncImage(
|
||||||
robot = iconUrl,
|
robot = iconUrl,
|
||||||
robotSize = 15.dp,
|
robotSize = 13.dp,
|
||||||
model = iconUrl,
|
model = iconUrl,
|
||||||
contentDescription = stringResource(id = R.string.relay_icon),
|
contentDescription = stringResource(id = R.string.relay_icon),
|
||||||
colorFilter = RelayIconFilter,
|
colorFilter = RelayIconFilter,
|
||||||
|
|||||||
@@ -62,7 +62,6 @@ import androidx.compose.ui.graphics.luminance
|
|||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
import androidx.compose.ui.platform.LocalClipboardManager
|
import androidx.compose.ui.platform.LocalClipboardManager
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.platform.LocalUriHandler
|
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.text.AnnotatedString
|
import androidx.compose.ui.text.AnnotatedString
|
||||||
@@ -113,7 +112,6 @@ import com.vitorpamplona.amethyst.ui.components.ObserveDisplayNip05Status
|
|||||||
import com.vitorpamplona.amethyst.ui.components.ResizeImage
|
import com.vitorpamplona.amethyst.ui.components.ResizeImage
|
||||||
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImage
|
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImage
|
||||||
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImageProxy
|
import com.vitorpamplona.amethyst.ui.components.RobohashAsyncImageProxy
|
||||||
import com.vitorpamplona.amethyst.ui.components.RobohashFallbackAsyncImage
|
|
||||||
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
import com.vitorpamplona.amethyst.ui.components.SensitivityWarning
|
||||||
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
import com.vitorpamplona.amethyst.ui.components.TranslatableRichTextViewer
|
||||||
import com.vitorpamplona.amethyst.ui.components.VideoView
|
import com.vitorpamplona.amethyst.ui.components.VideoView
|
||||||
@@ -129,7 +127,6 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.ChannelHeader
|
|||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ReportNoteDialog
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.ReportNoteDialog
|
||||||
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
|
import com.vitorpamplona.amethyst.ui.theme.BitcoinOrange
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Following
|
import com.vitorpamplona.amethyst.ui.theme.Following
|
||||||
import com.vitorpamplona.amethyst.ui.theme.RelayIconFilter
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@@ -1911,43 +1908,11 @@ private fun VerticalRelayPanelWithFlow(
|
|||||||
// FlowRow Seems to be a lot faster than LazyVerticalGrid
|
// FlowRow Seems to be a lot faster than LazyVerticalGrid
|
||||||
FlowRow() {
|
FlowRow() {
|
||||||
relays.forEach { url ->
|
relays.forEach { url ->
|
||||||
RelayIconCompose(url)
|
RenderRelay(url)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
|
||||||
@Stable
|
|
||||||
private fun RelayIconCompose(url: String) {
|
|
||||||
val uri = LocalUriHandler.current
|
|
||||||
|
|
||||||
val model = remember(url) { "https://$url/favicon.ico" }
|
|
||||||
|
|
||||||
val boxModifier = remember {
|
|
||||||
Modifier
|
|
||||||
.padding(1.dp)
|
|
||||||
.size(15.dp)
|
|
||||||
}
|
|
||||||
val iconModifier = remember(url) {
|
|
||||||
Modifier
|
|
||||||
.width(13.dp)
|
|
||||||
.height(13.dp)
|
|
||||||
.clip(shape = CircleShape)
|
|
||||||
.clickable(onClick = { uri.openUri("https://$url") })
|
|
||||||
}
|
|
||||||
|
|
||||||
Box(boxModifier) {
|
|
||||||
RobohashFallbackAsyncImage(
|
|
||||||
robot = model,
|
|
||||||
robotSize = 15.dp,
|
|
||||||
model = model,
|
|
||||||
contentDescription = stringResource(R.string.relay_icon),
|
|
||||||
colorFilter = RelayIconFilter,
|
|
||||||
modifier = iconModifier.background(MaterialTheme.colors.background)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
private fun ShowMoreRelaysButton(onClick: () -> Unit) {
|
private fun ShowMoreRelaysButton(onClick: () -> Unit) {
|
||||||
val boxModifier = remember {
|
val boxModifier = remember {
|
||||||
|
|||||||
Reference in New Issue
Block a user