Improvements to anonymous replies
This commit is contained in:
@@ -1300,9 +1300,18 @@ class Account(
|
|||||||
val anonymousSigner = NostrSignerInternal(KeyPair())
|
val anonymousSigner = NostrSignerInternal(KeyPair())
|
||||||
val event = anonymousSigner.sign(template)
|
val event = anonymousSigner.sign(template)
|
||||||
|
|
||||||
val relayList = nip65RelayList.outboxFlow.value.toSet()
|
cache.justConsumeMyOwnEvent(event)
|
||||||
|
val note =
|
||||||
|
if (event is AddressableEvent) {
|
||||||
|
cache.getOrCreateAddressableNote(event.address())
|
||||||
|
} else {
|
||||||
|
cache.getOrCreateNote(event.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
val relayList = computeRelayListToBroadcast(note)
|
||||||
|
|
||||||
client.send(event, relayList)
|
client.send(event, relayList)
|
||||||
|
|
||||||
broadcast.forEach { client.send(it, relayList) }
|
broadcast.forEach { client.send(it, relayList) }
|
||||||
|
|
||||||
return event
|
return event
|
||||||
|
|||||||
+10
-2
@@ -194,6 +194,8 @@ open class CommentPostViewModel :
|
|||||||
var wantsZapraiser by mutableStateOf(false)
|
var wantsZapraiser by mutableStateOf(false)
|
||||||
override val zapRaiserAmount = mutableStateOf<Long?>(null)
|
override val zapRaiserAmount = mutableStateOf<Long?>(null)
|
||||||
|
|
||||||
|
var wantsAnonymousPost by mutableStateOf(false)
|
||||||
|
|
||||||
fun lnAddress(): String? = account.userProfile().lnAddress()
|
fun lnAddress(): String? = account.userProfile().lnAddress()
|
||||||
|
|
||||||
fun hasLnAddress(): Boolean = account.userProfile().lnAddress() != null
|
fun hasLnAddress(): Boolean = account.userProfile().lnAddress() != null
|
||||||
@@ -342,10 +344,15 @@ open class CommentPostViewModel :
|
|||||||
}
|
}
|
||||||
|
|
||||||
val version = draftTag.current
|
val version = draftTag.current
|
||||||
|
val anonymous = wantsAnonymousPost
|
||||||
cancel()
|
cancel()
|
||||||
|
|
||||||
accountViewModel.account.signAndComputeBroadcast(template, extraNotesToBroadcast)
|
if (anonymous) {
|
||||||
|
accountViewModel.account.signAnonymouslyAndBroadcast(template, extraNotesToBroadcast)
|
||||||
|
} else {
|
||||||
|
accountViewModel.account.signAndComputeBroadcast(template, extraNotesToBroadcast)
|
||||||
|
}
|
||||||
|
|
||||||
accountViewModel.viewModelScope.launch(Dispatchers.IO) {
|
accountViewModel.viewModelScope.launch(Dispatchers.IO) {
|
||||||
accountViewModel.account.deleteDraftIgnoreErrors(version)
|
accountViewModel.account.deleteDraftIgnoreErrors(version)
|
||||||
}
|
}
|
||||||
@@ -588,6 +595,7 @@ open class CommentPostViewModel :
|
|||||||
contentWarningDescription = ""
|
contentWarningDescription = ""
|
||||||
wantsToAddGeoHash = false
|
wantsToAddGeoHash = false
|
||||||
wantsSecretEmoji = false
|
wantsSecretEmoji = false
|
||||||
|
wantsAnonymousPost = false
|
||||||
|
|
||||||
forwardZapTo.value = SplitBuilder()
|
forwardZapTo.value = SplitBuilder()
|
||||||
forwardZapToEditting.value = TextFieldValue("")
|
forwardZapToEditting.value = TextFieldValue("")
|
||||||
|
|||||||
+33
-5
@@ -22,7 +22,9 @@ package com.vitorpamplona.amethyst.ui.note.nip22Comments
|
|||||||
|
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
import androidx.compose.foundation.layout.Spacer
|
import androidx.compose.foundation.layout.Spacer
|
||||||
@@ -35,6 +37,8 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.rememberScrollState
|
import androidx.compose.foundation.rememberScrollState
|
||||||
import androidx.compose.foundation.verticalScroll
|
import androidx.compose.foundation.verticalScroll
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.IconButton
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
@@ -79,9 +83,12 @@ import com.vitorpamplona.amethyst.ui.note.creators.zapraiser.ZapRaiserRequest
|
|||||||
import com.vitorpamplona.amethyst.ui.note.creators.zapsplits.ForwardZapTo
|
import com.vitorpamplona.amethyst.ui.note.creators.zapsplits.ForwardZapTo
|
||||||
import com.vitorpamplona.amethyst.ui.note.creators.zapsplits.ForwardZapToButton
|
import com.vitorpamplona.amethyst.ui.note.creators.zapsplits.ForwardZapToButton
|
||||||
import com.vitorpamplona.amethyst.ui.note.types.ReplyRenderType
|
import com.vitorpamplona.amethyst.ui.note.types.ReplyRenderType
|
||||||
|
import com.vitorpamplona.amethyst.ui.painterRes
|
||||||
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
import com.vitorpamplona.amethyst.ui.screen.loggedIn.AccountViewModel
|
||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size30Modifier
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
import com.vitorpamplona.amethyst.ui.theme.SuggestionListDefaultHeightPage
|
||||||
@@ -241,11 +248,32 @@ private fun GenericCommentPostBody(
|
|||||||
Row(
|
Row(
|
||||||
modifier = Modifier.padding(vertical = Size10dp),
|
modifier = Modifier.padding(vertical = Size10dp),
|
||||||
) {
|
) {
|
||||||
BaseUserPicture(
|
if (postViewModel.wantsAnonymousPost) {
|
||||||
accountViewModel.userProfile(),
|
IconButton(
|
||||||
Size35dp,
|
modifier = Size35Modifier,
|
||||||
accountViewModel = accountViewModel,
|
onClick = { postViewModel.wantsAnonymousPost = false },
|
||||||
)
|
) {
|
||||||
|
Icon(
|
||||||
|
painter = painterRes(resourceId = R.drawable.incognito, 1),
|
||||||
|
contentDescription = stringRes(R.string.post_anonymously),
|
||||||
|
modifier = Size30Modifier,
|
||||||
|
tint = MaterialTheme.colorScheme.onBackground,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Box(
|
||||||
|
modifier =
|
||||||
|
Modifier.clickable {
|
||||||
|
postViewModel.wantsAnonymousPost = true
|
||||||
|
},
|
||||||
|
) {
|
||||||
|
BaseUserPicture(
|
||||||
|
accountViewModel.userProfile(),
|
||||||
|
Size35dp,
|
||||||
|
accountViewModel = accountViewModel,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
MessageField(
|
MessageField(
|
||||||
R.string.what_s_on_your_mind,
|
R.string.what_s_on_your_mind,
|
||||||
postViewModel,
|
postViewModel,
|
||||||
|
|||||||
+3
-20
@@ -25,7 +25,6 @@ import android.content.Intent
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.Parcelable
|
import android.os.Parcelable
|
||||||
import androidx.activity.compose.BackHandler
|
import androidx.activity.compose.BackHandler
|
||||||
import androidx.compose.foundation.background
|
|
||||||
import androidx.compose.foundation.clickable
|
import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.horizontalScroll
|
import androidx.compose.foundation.horizontalScroll
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
@@ -49,7 +48,6 @@ import androidx.compose.material3.MaterialTheme
|
|||||||
import androidx.compose.material3.Scaffold
|
import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.DisposableEffect
|
import androidx.compose.runtime.DisposableEffect
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
@@ -110,6 +108,7 @@ import com.vitorpamplona.amethyst.ui.screen.loggedIn.settings.SettingsRow
|
|||||||
import com.vitorpamplona.amethyst.ui.stringRes
|
import com.vitorpamplona.amethyst.ui.stringRes
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
import com.vitorpamplona.amethyst.ui.theme.Size10dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size19Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size19Modifier
|
||||||
|
import com.vitorpamplona.amethyst.ui.theme.Size30Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
import com.vitorpamplona.amethyst.ui.theme.Size35Modifier
|
||||||
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
import com.vitorpamplona.amethyst.ui.theme.Size35dp
|
||||||
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
import com.vitorpamplona.amethyst.ui.theme.StdVertSpacer
|
||||||
@@ -288,23 +287,6 @@ private fun NewPostScreenBody(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (postViewModel.wantsAnonymousPost) {
|
|
||||||
Row(
|
|
||||||
modifier =
|
|
||||||
Modifier
|
|
||||||
.fillMaxWidth()
|
|
||||||
.background(MaterialTheme.colorScheme.errorContainer)
|
|
||||||
.padding(horizontal = Size10dp, vertical = 8.dp),
|
|
||||||
verticalAlignment = CenterVertically,
|
|
||||||
) {
|
|
||||||
Text(
|
|
||||||
text = stringRes(R.string.anonymous_reply_warning),
|
|
||||||
color = MaterialTheme.colorScheme.onErrorContainer,
|
|
||||||
style = MaterialTheme.typography.bodySmall,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Only show text input if no voice message is being posted
|
// Only show text input if no voice message is being posted
|
||||||
if (postViewModel.voiceMetadata == null && postViewModel.voiceRecording == null) {
|
if (postViewModel.voiceMetadata == null && postViewModel.voiceRecording == null) {
|
||||||
Row(
|
Row(
|
||||||
@@ -312,12 +294,13 @@ private fun NewPostScreenBody(
|
|||||||
) {
|
) {
|
||||||
if (postViewModel.wantsAnonymousPost) {
|
if (postViewModel.wantsAnonymousPost) {
|
||||||
IconButton(
|
IconButton(
|
||||||
|
modifier = Size35Modifier,
|
||||||
onClick = { postViewModel.wantsAnonymousPost = false },
|
onClick = { postViewModel.wantsAnonymousPost = false },
|
||||||
) {
|
) {
|
||||||
Icon(
|
Icon(
|
||||||
painter = painterRes(resourceId = R.drawable.incognito, 1),
|
painter = painterRes(resourceId = R.drawable.incognito, 1),
|
||||||
contentDescription = stringRes(R.string.post_anonymously),
|
contentDescription = stringRes(R.string.post_anonymously),
|
||||||
modifier = Size35Modifier,
|
modifier = Size30Modifier,
|
||||||
tint = MaterialTheme.colorScheme.onBackground,
|
tint = MaterialTheme.colorScheme.onBackground,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user