Adds button to load Zap Splits from the cited users in the text
This commit is contained in:
@@ -1102,8 +1102,12 @@ fun FowardZapTo(
|
|||||||
text = stringResource(R.string.zap_split_title),
|
text = stringResource(R.string.zap_split_title),
|
||||||
fontSize = 20.sp,
|
fontSize = 20.sp,
|
||||||
fontWeight = FontWeight.W500,
|
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)
|
HorizontalDivider(thickness = DividerThickness)
|
||||||
|
|||||||
@@ -938,7 +938,6 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
userSuggestions = emptyList()
|
userSuggestions = emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
saveDraft()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun autocompleteWithUser(item: User) {
|
open fun autocompleteWithUser(item: User) {
|
||||||
@@ -957,16 +956,6 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
} else if (userSuggestionsMainMessage == UserSuggestionAnchor.FORWARD_ZAPS) {
|
} else if (userSuggestionsMainMessage == UserSuggestionAnchor.FORWARD_ZAPS) {
|
||||||
forwardZapTo.addItem(item)
|
forwardZapTo.addItem(item)
|
||||||
forwardZapToEditting = TextFieldValue("")
|
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) {
|
} else if (userSuggestionsMainMessage == UserSuggestionAnchor.TO_USERS) {
|
||||||
val lastWord =
|
val lastWord =
|
||||||
toUsers.text.substring(0, it.end).substringAfterLast("\n").substringAfterLast(" ")
|
toUsers.text.substring(0, it.end).substringAfterLast("\n").substringAfterLast(" ")
|
||||||
@@ -1209,6 +1198,18 @@ open class NewPostViewModel() : ViewModel() {
|
|||||||
forwardZapTo.updatePercentage(index, sliderValue)
|
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?) {
|
fun updateZapRaiserAmount(newAmount: Long?) {
|
||||||
zapRaiserAmount = newAmount
|
zapRaiserAmount = newAmount
|
||||||
saveDraft()
|
saveDraft()
|
||||||
|
|||||||
@@ -827,4 +827,6 @@
|
|||||||
<string name="it_s_not_possible_to_react_to_a_draft_note">It\'s not possible to react a draft note</string>
|
<string name="it_s_not_possible_to_react_to_a_draft_note">It\'s not possible to react a draft note</string>
|
||||||
<string name="it_s_not_possible_to_zap_to_a_draft_note">It\'s not possible to zap a draft note</string>
|
<string name="it_s_not_possible_to_zap_to_a_draft_note">It\'s not possible to zap a draft note</string>
|
||||||
<string name="draft_note">Draft Note</string>
|
<string name="draft_note">Draft Note</string>
|
||||||
|
|
||||||
|
<string name="load_from_text">From Msg</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user