mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-04-23 15:04:51 +02:00
Don't show button to edit the post if the author of the original post is not the logged in user
This commit is contained in:
parent
2f45067949
commit
cd2b5d78a1
@ -1516,7 +1516,7 @@ fun RenderTextModificationEvent(
|
||||
val noteEvent = note.event as? TextNoteModificationEvent ?: return
|
||||
val noteAuthor = note.author ?: return
|
||||
|
||||
val isAuthorTheLoggedUser = remember(note.event) { accountViewModel.isLoggedUser(note.author) }
|
||||
// val isAuthorTheLoggedUser = remember(note.event) { accountViewModel.isLoggedUser(note.author) }
|
||||
|
||||
val editState =
|
||||
remember {
|
||||
@ -1543,6 +1543,13 @@ fun RenderTextModificationEvent(
|
||||
mutableStateOf(false)
|
||||
}
|
||||
|
||||
val isAuthorTheLoggedUser =
|
||||
remember {
|
||||
val authorOfTheOriginalNote = noteEvent.editedNote()?.let { accountViewModel.getNoteIfExists(it)?.author }
|
||||
|
||||
mutableStateOf(accountViewModel.isLoggedUser(authorOfTheOriginalNote))
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = MaterialTheme.colorScheme.imageModifier,
|
||||
) {
|
||||
@ -1574,6 +1581,16 @@ fun RenderTextModificationEvent(
|
||||
noteEvent.editedNote()?.let {
|
||||
LoadNote(baseNoteHex = it, accountViewModel = accountViewModel) { baseNote ->
|
||||
baseNote?.let {
|
||||
val noteState by baseNote.live().metadata.observeAsState()
|
||||
|
||||
LaunchedEffect(key1 = noteState) {
|
||||
val newAuthor = accountViewModel.isLoggedUser(noteState?.note?.author)
|
||||
|
||||
if (isAuthorTheLoggedUser.value != newAuthor) {
|
||||
isAuthorTheLoggedUser.value = newAuthor
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
modifier =
|
||||
MaterialTheme.colorScheme.innerPostModifier.padding(Size10dp).clickable {
|
||||
@ -1609,13 +1626,15 @@ fun RenderTextModificationEvent(
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = StdVertSpacer)
|
||||
if (isAuthorTheLoggedUser.value) {
|
||||
Spacer(modifier = StdVertSpacer)
|
||||
|
||||
Button(
|
||||
onClick = { wantsToEditPost.value = true },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.accept_the_suggestion))
|
||||
Button(
|
||||
onClick = { wantsToEditPost.value = true },
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
) {
|
||||
Text(text = stringResource(id = R.string.accept_the_suggestion))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -797,7 +797,7 @@
|
||||
<string name="ots_info_description">There\'s proof this post was signed sometime before %1$s. The proof was stamped in the Bitcoin blockchain at that date and time.</string>
|
||||
|
||||
<string name="edit_post">Edit Post</string>
|
||||
<string name="proposal_to_edit">Proposal to improve your post</string>
|
||||
<string name="proposal_to_edit">Proposal to improve a post</string>
|
||||
<string name="message_to_author">Summary of changes</string>
|
||||
<string name="message_to_author_placeholder">Quick fixes…</string>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user