diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt
index 55fbe12fa..e5fa37c7a 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostView.kt
@@ -1102,8 +1102,12 @@ fun FowardZapTo(
text = stringResource(R.string.zap_split_title),
fontSize = 20.sp,
fontWeight = FontWeight.W500,
- modifier = Modifier.padding(start = 10.dp),
+ modifier = Modifier.padding(horizontal = 10.dp).weight(1f),
)
+
+ OutlinedButton(onClick = { postViewModel.updateZapFromText() }) {
+ Text(text = stringResource(R.string.load_from_text))
+ }
}
HorizontalDivider(thickness = DividerThickness)
diff --git a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt
index e5e93f030..1f7a19f38 100644
--- a/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt
+++ b/app/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewPostViewModel.kt
@@ -938,7 +938,6 @@ open class NewPostViewModel() : ViewModel() {
userSuggestions = emptyList()
}
}
- saveDraft()
}
open fun autocompleteWithUser(item: User) {
@@ -957,16 +956,6 @@ open class NewPostViewModel() : ViewModel() {
} else if (userSuggestionsMainMessage == UserSuggestionAnchor.FORWARD_ZAPS) {
forwardZapTo.addItem(item)
forwardZapToEditting = TextFieldValue("")
- /*
- val lastWord = forwardZapToEditting.text.substring(0, it.end).substringAfterLast("\n").substringAfterLast(" ")
- val lastWordStart = it.end - lastWord.length
- val wordToInsert = "@${item.pubkeyNpub()}"
- forwardZapTo = item
-
- forwardZapToEditting = TextFieldValue(
- forwardZapToEditting.text.replaceRange(lastWordStart, it.end, wordToInsert),
- TextRange(lastWordStart + wordToInsert.length, lastWordStart + wordToInsert.length)
- )*/
} else if (userSuggestionsMainMessage == UserSuggestionAnchor.TO_USERS) {
val lastWord =
toUsers.text.substring(0, it.end).substringAfterLast("\n").substringAfterLast(" ")
@@ -1209,6 +1198,18 @@ open class NewPostViewModel() : ViewModel() {
forwardZapTo.updatePercentage(index, sliderValue)
}
+ fun updateZapFromText() {
+ viewModelScope.launch(Dispatchers.Default) {
+ val tagger = NewMessageTagger(message.text, emptyList(), emptyList(), null, accountViewModel!!)
+ tagger.run()
+ tagger.pTags?.forEach { taggedUser ->
+ if (!forwardZapTo.items.any { it.key == taggedUser }) {
+ forwardZapTo.addItem(taggedUser)
+ }
+ }
+ }
+ }
+
fun updateZapRaiserAmount(newAmount: Long?) {
zapRaiserAmount = newAmount
saveDraft()
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b05f069b1..185e9c5d8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -827,4 +827,6 @@
It\'s not possible to react a draft note
It\'s not possible to zap a draft note
Draft Note
+
+ From Msg