1
0
Fork 0
forked from alemi/upub

fix(web): dont include summary if empty

This commit is contained in:
əlemi 2024-05-02 16:20:41 +02:00
parent 64d7f25aa2
commit 505bdfa234
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -86,7 +86,7 @@ pub fn PostBox(advanced: WriteSignal<bool>) -> impl IntoView {
<button class="w-100" prop:disabled=posting type="button" style="height: 3em" on:click=move |_| {
set_posting.set(true);
spawn_local(async move {
let summary = summary_ref.get().map(|x| x.value());
let summary = get_if_some(summary_ref);
let content = content_ref.get().map(|x| x.value()).unwrap_or_default();
let (to, cc) = if get_checked(public_ref) {
(apb::Node::links(vec![apb::target::PUBLIC.to_string()]), apb::Node::links(vec![format!("{URL_BASE}/users/{}/followers", auth.username())]))
@ -266,14 +266,14 @@ pub fn AdvancedPostBox(advanced: WriteSignal<bool>) -> impl IntoView {
fn get_if_some(node: NodeRef<html::Input>) -> Option<String> {
node.get()
.filter(|x| !x.value().is_empty())
.map(|x| x.value())
.filter(|x| !x.is_empty())
}
fn get_vec_if_some(node: NodeRef<html::Input>) -> Vec<String> {
node.get()
.filter(|x| !x.value().is_empty())
.map(|x| x.value())
.filter(|x| !x.is_empty())
.map(|x|
x.split(',')
.map(|x| x.to_string())