mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 08:20:51 +00:00
Minor refactoring
This commit is contained in:
parent
4380393c5b
commit
c7563c938d
@ -2353,7 +2353,7 @@ class Account(
|
||||
} else if (event is LnZapRequestEvent && event.isPrivateZap() && isWriteable()) {
|
||||
event.cachedPrivateZap()?.content
|
||||
} else {
|
||||
event?.content()
|
||||
event.content()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -466,13 +466,9 @@ private fun NoteRow(
|
||||
) {
|
||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
||||
when (note.event) {
|
||||
is ChannelCreateEvent -> {
|
||||
RenderCreateChannelNote(note)
|
||||
}
|
||||
is ChannelMetadataEvent -> {
|
||||
RenderChangeChannelMetadataNote(note)
|
||||
}
|
||||
is DraftEvent -> {
|
||||
is ChannelCreateEvent -> RenderCreateChannelNote(note)
|
||||
is ChannelMetadataEvent -> RenderChangeChannelMetadataNote(note)
|
||||
is DraftEvent ->
|
||||
RenderDraftEvent(
|
||||
note,
|
||||
canPreview,
|
||||
@ -483,8 +479,7 @@ private fun NoteRow(
|
||||
accountViewModel,
|
||||
nav,
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
else ->
|
||||
RenderRegularTextNote(
|
||||
note,
|
||||
canPreview,
|
||||
@ -493,7 +488,6 @@ private fun NoteRow(
|
||||
accountViewModel,
|
||||
nav,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.livedata.observeAsState
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
@ -70,19 +71,11 @@ fun LoadDecryptedContentOrNull(
|
||||
accountViewModel: AccountViewModel,
|
||||
inner: @Composable (String?) -> Unit,
|
||||
) {
|
||||
var decryptedContent by
|
||||
remember(note.event) {
|
||||
mutableStateOf(
|
||||
accountViewModel.cachedDecrypt(note),
|
||||
)
|
||||
val decryptedContent by
|
||||
produceState(initialValue = accountViewModel.cachedDecrypt(note), key1 = note.event?.id()) {
|
||||
accountViewModel.decrypt(note) { value = it }
|
||||
}
|
||||
|
||||
if (decryptedContent == null) {
|
||||
LaunchedEffect(key1 = decryptedContent) {
|
||||
accountViewModel.decrypt(note) { decryptedContent = it }
|
||||
}
|
||||
}
|
||||
|
||||
inner(decryptedContent)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user