Improving the memory use of hashmaps
This commit is contained in:
@@ -133,6 +133,7 @@ import com.vitorpamplona.amethyst.ui.theme.Font14SP
|
|||||||
import com.vitorpamplona.amethyst.ui.theme.HalfDoubleVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.HalfDoubleVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HalfPadding
|
import com.vitorpamplona.amethyst.ui.theme.HalfPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HalfStartPadding
|
import com.vitorpamplona.amethyst.ui.theme.HalfStartPadding
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.HalfTopPadding
|
||||||
import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier
|
import com.vitorpamplona.amethyst.ui.theme.HeaderPictureModifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
import com.vitorpamplona.amethyst.ui.theme.QuoteBorder
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
@@ -644,8 +645,13 @@ fun LongCommunityHeader(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val hashtags = remember(noteEvent) { noteEvent.hashtags().toImmutableList() }
|
if (noteEvent.hasHashtags()) {
|
||||||
DisplayUncitedHashtags(hashtags, summary ?: "", nav)
|
DisplayUncitedHashtags(
|
||||||
|
remember(noteEvent) { noteEvent.hashtags().toImmutableList() },
|
||||||
|
summary ?: "",
|
||||||
|
nav
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column() {
|
Column() {
|
||||||
@@ -1405,8 +1411,10 @@ fun RenderTextEvent(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val hashtags = remember(note.event) { note.event?.hashtags()?.toImmutableList() ?: persistentListOf() }
|
if (note.event?.hasHashtags() == true) {
|
||||||
DisplayUncitedHashtags(hashtags, eventContent, nav)
|
val hashtags = remember(note.event) { note.event?.hashtags()?.toImmutableList() ?: persistentListOf() }
|
||||||
|
DisplayUncitedHashtags(hashtags, eventContent, nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1456,8 +1464,10 @@ fun RenderPoll(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val hashtags = remember { noteEvent.hashtags().toImmutableList() }
|
if (noteEvent.hasHashtags()) {
|
||||||
DisplayUncitedHashtags(hashtags, eventContent, nav)
|
val hashtags = remember { noteEvent.hashtags().toImmutableList() }
|
||||||
|
DisplayUncitedHashtags(hashtags, eventContent, nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1675,7 +1685,6 @@ private fun RenderPrivateMessage(
|
|||||||
val withMe = remember { noteEvent.with(accountViewModel.userProfile().pubkeyHex) }
|
val withMe = remember { noteEvent.with(accountViewModel.userProfile().pubkeyHex) }
|
||||||
if (withMe) {
|
if (withMe) {
|
||||||
LoadDecryptedContent(note, accountViewModel) { eventContent ->
|
LoadDecryptedContent(note, accountViewModel) { eventContent ->
|
||||||
val hashtags = remember(note.event?.id()) { note.event?.hashtags()?.toImmutableList() ?: persistentListOf() }
|
|
||||||
val modifier = remember(note.event?.id()) { Modifier.fillMaxWidth() }
|
val modifier = remember(note.event?.id()) { Modifier.fillMaxWidth() }
|
||||||
val isAuthorTheLoggedUser = remember(note.event?.id()) { accountViewModel.isLoggedUser(note.author) }
|
val isAuthorTheLoggedUser = remember(note.event?.id()) { accountViewModel.isLoggedUser(note.author) }
|
||||||
|
|
||||||
@@ -1704,7 +1713,10 @@ private fun RenderPrivateMessage(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
DisplayUncitedHashtags(hashtags, eventContent, nav)
|
if (noteEvent.hasHashtags()) {
|
||||||
|
val hashtags = remember(note.event?.id()) { note.event?.hashtags()?.toImmutableList() ?: persistentListOf() }
|
||||||
|
DisplayUncitedHashtags(hashtags, eventContent, nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -3184,26 +3196,20 @@ fun DisplayUncitedHashtags(
|
|||||||
eventContent: String,
|
eventContent: String,
|
||||||
nav: (String) -> Unit
|
nav: (String) -> Unit
|
||||||
) {
|
) {
|
||||||
val hasHashtags = remember(eventContent) {
|
val unusedHashtags = remember(eventContent) {
|
||||||
hashtags.isNotEmpty()
|
hashtags.filter { !eventContent.contains(it, true) }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasHashtags) {
|
if (unusedHashtags.isNotEmpty()) {
|
||||||
val unusedHashtags = remember(eventContent) {
|
|
||||||
hashtags.filter { !eventContent.contains(it, true) }
|
|
||||||
}
|
|
||||||
|
|
||||||
FlowRow(
|
FlowRow(
|
||||||
modifier = remember { Modifier.padding(top = 5.dp) }
|
modifier = HalfTopPadding
|
||||||
) {
|
) {
|
||||||
unusedHashtags.forEach { hashtag ->
|
unusedHashtags.forEach { hashtag ->
|
||||||
ClickableText(
|
ClickableText(
|
||||||
text = remember { AnnotatedString("#$hashtag ") },
|
text = remember { AnnotatedString("#$hashtag ") },
|
||||||
onClick = { nav("Hashtag/$hashtag") },
|
onClick = { nav("Hashtag/$hashtag") },
|
||||||
style = LocalTextStyle.current.copy(
|
style = LocalTextStyle.current.copy(
|
||||||
color = MaterialTheme.colorScheme.primary.copy(
|
color = MaterialTheme.colorScheme.lessImportantLink
|
||||||
alpha = 0.52f
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -3658,9 +3664,11 @@ fun AudioHeader(noteEvent: AudioHeaderEvent, note: Note, accountViewModel: Accou
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Row(Modifier.fillMaxWidth(), verticalAlignment = CenterVertically) {
|
if (noteEvent.hasHashtags()) {
|
||||||
val hashtags = remember(noteEvent) { noteEvent.hashtags().toImmutableList() }
|
Row(Modifier.fillMaxWidth(), verticalAlignment = CenterVertically) {
|
||||||
DisplayUncitedHashtags(hashtags, content ?: "", nav)
|
val hashtags = remember(noteEvent) { noteEvent.hashtags().toImmutableList() }
|
||||||
|
DisplayUncitedHashtags(hashtags, content ?: "", nav)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -788,7 +788,7 @@ fun LongChannelHeader(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baseChannel is LiveActivitiesChannel) {
|
if (baseChannel is LiveActivitiesChannel && baseChannel.info?.hasHashtags() == true) {
|
||||||
val hashtags = remember(baseChannel.info) {
|
val hashtags = remember(baseChannel.info) {
|
||||||
baseChannel.info?.hashtags()?.toImmutableList() ?: persistentListOf()
|
baseChannel.info?.hashtags()?.toImmutableList() ?: persistentListOf()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ val Size75dp = 75.dp
|
|||||||
val HalfStartPadding = Modifier.padding(start = 5.dp)
|
val HalfStartPadding = Modifier.padding(start = 5.dp)
|
||||||
val StdStartPadding = Modifier.padding(start = 10.dp)
|
val StdStartPadding = Modifier.padding(start = 10.dp)
|
||||||
val StdTopPadding = Modifier.padding(top = 10.dp)
|
val StdTopPadding = Modifier.padding(top = 10.dp)
|
||||||
|
val HalfTopPadding = Modifier.padding(top = 5.dp)
|
||||||
|
|
||||||
val HalfPadding = Modifier.padding(5.dp)
|
val HalfPadding = Modifier.padding(5.dp)
|
||||||
val StdPadding = Modifier.padding(10.dp)
|
val StdPadding = Modifier.padding(10.dp)
|
||||||
|
|||||||
@@ -124,6 +124,9 @@ open class Event(
|
|||||||
ATag.parse(aTagValue, relay)
|
ATag.parse(aTagValue, relay)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hasHashtags() = tags.any { it.size > 1 && it[0] == "t" }
|
||||||
|
override fun hasGeohashes() = tags.any { it.size > 1 && it[0] == "g" }
|
||||||
|
|
||||||
override fun hashtags() = tags.filter { it.size > 1 && it[0] == "t" }.map { it[1] }
|
override fun hashtags() = tags.filter { it.size > 1 && it[0] == "t" }.map { it[1] }
|
||||||
override fun geohashes() = tags.filter { it.size > 1 && it[0] == "g" }.map { it[1] }
|
override fun geohashes() = tags.filter { it.size > 1 && it[0] == "g" }.map { it[1] }
|
||||||
|
|
||||||
|
|||||||
@@ -55,6 +55,9 @@ interface EventInterface {
|
|||||||
|
|
||||||
fun expiration(): Long?
|
fun expiration(): Long?
|
||||||
|
|
||||||
|
fun hasHashtags(): Boolean
|
||||||
|
fun hasGeohashes(): Boolean
|
||||||
|
|
||||||
fun hashtags(): List<String>
|
fun hashtags(): List<String>
|
||||||
fun geohashes(): List<String>
|
fun geohashes(): List<String>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user