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