mirror of
https://github.com/greenart7c3/Amber.git
synced 2026-10-06 03:18:23 +00:00
Show event content/tags and decrypt content in activities screen
- Store full event JSON (not just content field) for SIGN_EVENT across all ingestion paths (BunkerMultiEvent, IntentMultiEvent, BunkerRequestUtils, IntentUtils, SignerProvider) so tags are available in history - Store decrypted plaintext for NIP04/NIP44/DECRYPT_ZAP_EVENT decrypt ops instead of ciphertext (use encryptedData.result / response / result) - ActivityRow now tries to parse content as AmberEvent: if successful, renders EventSection (content) + TagsSection (tags) matching EventDetailModal style; falls back to plain text when content is not a Nostr event JSON https://claude.ai/code/session_01BDz4wDAw5UjDWGfxnbzwu4
This commit is contained in:
@@ -211,7 +211,7 @@ class SignerProvider : ContentProvider() {
|
||||
event.kind,
|
||||
TimeUtils.now(),
|
||||
false,
|
||||
content = event.content,
|
||||
content = event.toJson(),
|
||||
),
|
||||
account.npub,
|
||||
)
|
||||
@@ -236,7 +236,7 @@ class SignerProvider : ContentProvider() {
|
||||
event.kind,
|
||||
TimeUtils.now(),
|
||||
true,
|
||||
content = event.content,
|
||||
content = signedEvent.toJson(),
|
||||
),
|
||||
account.npub,
|
||||
)
|
||||
@@ -371,7 +371,7 @@ class SignerProvider : ContentProvider() {
|
||||
null,
|
||||
TimeUtils.now(),
|
||||
true,
|
||||
content = content,
|
||||
content = if (type == SignerType.NIP04_DECRYPT || type == SignerType.NIP44_DECRYPT || type == SignerType.DECRYPT_ZAP_EVENT) result else content,
|
||||
),
|
||||
account.npub,
|
||||
)
|
||||
|
||||
@@ -364,7 +364,14 @@ object BunkerRequestUtils {
|
||||
kind,
|
||||
TimeUtils.now(),
|
||||
true,
|
||||
content = getDataFromBunker(bunkerRequest.request),
|
||||
content = when (type) {
|
||||
SignerType.SIGN_EVENT,
|
||||
SignerType.NIP04_DECRYPT,
|
||||
SignerType.NIP44_DECRYPT,
|
||||
SignerType.DECRYPT_ZAP_EVENT,
|
||||
-> response
|
||||
else -> getDataFromBunker(bunkerRequest.request)
|
||||
},
|
||||
),
|
||||
account.npub,
|
||||
)
|
||||
|
||||
@@ -766,7 +766,14 @@ object IntentUtils {
|
||||
kind,
|
||||
TimeUtils.now(),
|
||||
true,
|
||||
content = intentData.data,
|
||||
content = when (intentData.type) {
|
||||
SignerType.SIGN_EVENT -> event
|
||||
SignerType.NIP04_DECRYPT,
|
||||
SignerType.NIP44_DECRYPT,
|
||||
SignerType.DECRYPT_ZAP_EVENT,
|
||||
-> value
|
||||
else -> intentData.data
|
||||
},
|
||||
),
|
||||
account.npub,
|
||||
)
|
||||
|
||||
@@ -28,6 +28,7 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalClipboard
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -49,8 +50,13 @@ import com.greenart7c3.nostrsigner.models.Account
|
||||
import com.greenart7c3.nostrsigner.models.TimeUtils
|
||||
import com.greenart7c3.nostrsigner.models.supportedKindNumbers
|
||||
import com.greenart7c3.nostrsigner.service.ApplicationNameCache
|
||||
import com.greenart7c3.nostrsigner.service.model.AmberEvent
|
||||
import com.greenart7c3.nostrsigner.service.toShortenHex
|
||||
import com.greenart7c3.nostrsigner.ui.components.EventSection
|
||||
import com.greenart7c3.nostrsigner.ui.components.TagsSection
|
||||
import com.greenart7c3.nostrsigner.ui.components.copyToClipboard
|
||||
import com.greenart7c3.nostrsigner.ui.components.SimpleSearchBar
|
||||
import com.vitorpamplona.quartz.nip01Core.core.Event
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@@ -147,6 +153,15 @@ fun ActivitiesScreen(
|
||||
|
||||
@Composable
|
||||
fun ActivityRow(activity: HistoryEntity, account: Account) {
|
||||
val clipboard = LocalClipboard.current
|
||||
val parsedEvent = remember(activity.content) {
|
||||
if (activity.content.isBlank()) {
|
||||
null
|
||||
} else {
|
||||
runCatching { AmberEvent.fromJson(activity.content).toEvent() }.getOrNull()
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@@ -172,7 +187,29 @@ fun ActivityRow(activity: HistoryEntity, account: Account) {
|
||||
color = if (activity.accepted) Color.Unspecified else Color.Gray,
|
||||
)
|
||||
|
||||
if (activity.content.isNotBlank()) {
|
||||
if (parsedEvent != null) {
|
||||
if (parsedEvent.content.isNotBlank()) {
|
||||
EventSection(
|
||||
label = stringResource(R.string.content),
|
||||
displayValue = parsedEvent.content,
|
||||
onCopy = { copyToClipboard(clipboard, parsedEvent.content) },
|
||||
)
|
||||
}
|
||||
if (parsedEvent.tags.isNotEmpty()) {
|
||||
TagsSection(
|
||||
label = stringResource(R.string.tags),
|
||||
tags = parsedEvent.tags,
|
||||
onCopy = {
|
||||
copyToClipboard(
|
||||
clipboard,
|
||||
parsedEvent.tags.joinToString(separator = ", ") {
|
||||
"[${it.joinToString(separator = ", ") { tag -> "\"$tag\"" }}]"
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
} else if (activity.content.isNotBlank()) {
|
||||
Text(
|
||||
modifier = Modifier.padding(top = 2.dp),
|
||||
text = activity.content,
|
||||
|
||||
+6
-2
@@ -398,7 +398,7 @@ fun BunkerMultiEventHomeScreen(
|
||||
kind = localEvent.kind,
|
||||
time = TimeUtils.now(),
|
||||
accepted = request.checked.value,
|
||||
content = localEvent.content,
|
||||
content = localEvent.toJson(),
|
||||
),
|
||||
thisAccount.npub,
|
||||
)
|
||||
@@ -553,7 +553,11 @@ fun BunkerMultiEventHomeScreen(
|
||||
null,
|
||||
TimeUtils.now(),
|
||||
request.checked.value,
|
||||
content = request.request.params.getOrElse(1) { "" },
|
||||
content = if (type == SignerType.NIP04_DECRYPT || type == SignerType.NIP44_DECRYPT || type == SignerType.DECRYPT_ZAP_EVENT) {
|
||||
request.encryptedData?.result ?: ""
|
||||
} else {
|
||||
request.request.params.getOrElse(1) { "" }
|
||||
},
|
||||
),
|
||||
thisAccount.npub,
|
||||
)
|
||||
|
||||
+6
-2
@@ -409,7 +409,7 @@ fun IntentMultiEventHomeScreen(
|
||||
localEvent.kind,
|
||||
TimeUtils.now(),
|
||||
intentData.checked.value,
|
||||
content = localEvent.content,
|
||||
content = localEvent.toJson(),
|
||||
),
|
||||
thisAccount.npub,
|
||||
)
|
||||
@@ -503,7 +503,11 @@ fun IntentMultiEventHomeScreen(
|
||||
null,
|
||||
TimeUtils.now(),
|
||||
intentData.checked.value,
|
||||
content = intentData.data,
|
||||
content = if (intentData.type == SignerType.NIP04_DECRYPT || intentData.type == SignerType.NIP44_DECRYPT || intentData.type == SignerType.DECRYPT_ZAP_EVENT) {
|
||||
intentData.encryptedData?.result ?: ""
|
||||
} else {
|
||||
intentData.data
|
||||
},
|
||||
),
|
||||
thisAccount.npub,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user