mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 08:20:51 +00:00
add support for polls
This commit is contained in:
parent
f7ab925b1d
commit
84faa7557e
@ -309,6 +309,8 @@ open class NewPostViewModel() : ViewModel() {
|
||||
draft: Note,
|
||||
accountViewModel: AccountViewModel,
|
||||
) {
|
||||
Log.d("draft", draft.event!!.toJson())
|
||||
|
||||
draftTag = LocalCache.drafts.filter {
|
||||
it.value.contains(draft.idHex)
|
||||
}.keys.firstOrNull() ?: draftTag
|
||||
@ -363,6 +365,22 @@ open class NewPostViewModel() : ViewModel() {
|
||||
wantsForwardZapTo = true
|
||||
}
|
||||
|
||||
val polls = draft.event?.tags()?.filter { it.size > 1 && it[0] == "poll_option" } ?: emptyList()
|
||||
wantsPoll = polls.isNotEmpty()
|
||||
|
||||
polls.forEach {
|
||||
pollOptions[it[1].toInt()] = it[2]
|
||||
}
|
||||
|
||||
val minMax = draft.event?.tags()?.filter { it.size > 1 && (it[0] == "value_minimum" || it[0] == "value_maximum") } ?: listOf()
|
||||
minMax.forEach {
|
||||
if (it[0] == "value_maximum") {
|
||||
valueMaximum = it[1].toInt()
|
||||
} else if (it[0] == "value_minimum") {
|
||||
valueMinimum = it[1].toInt()
|
||||
}
|
||||
}
|
||||
|
||||
message = TextFieldValue(draft.event?.content() ?: "")
|
||||
urlPreview = findUrlInMessage()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user