forked from alemi/upub
fix(web): profile update form correctly creates obj
This commit is contained in:
parent
9abf1b65ab
commit
9785b9856c
1 changed files with 30 additions and 9 deletions
|
@ -1,4 +1,4 @@
|
||||||
use apb::{ActivityMut, Object, ObjectMut};
|
use apb::{ActivityMut, DocumentMut, Object, ObjectMut};
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use crate::{prelude::*, DEFAULT_COLOR};
|
use crate::{prelude::*, DEFAULT_COLOR};
|
||||||
|
|
||||||
|
@ -131,10 +131,31 @@ pub fn ConfigPage(setter: WriteSignal<crate::Config>) -> impl IntoView {
|
||||||
<input class="w-100" type="submit" value="submit"
|
<input class="w-100" type="submit" value="submit"
|
||||||
on:click=move|e| {
|
on:click=move|e| {
|
||||||
e.prevent_default();
|
e.prevent_default();
|
||||||
let display_name = display_name_ref.get().map(|x| x.value()).unwrap_or("".into());
|
let display_name = display_name_ref.get()
|
||||||
let avatar = avatar_url_ref.get().map(|x| x.value()).unwrap_or("".into());
|
.map(|x| x.value())
|
||||||
let banner = banner_url_ref.get().map(|x| x.value()).unwrap_or("".into());
|
.filter(|x| !x.is_empty());
|
||||||
let summary = summary_ref.get().map(|x| x.value()).unwrap_or("".into());
|
|
||||||
|
let summary = summary_ref.get()
|
||||||
|
.map(|x| x.value())
|
||||||
|
.filter(|x| !x.is_empty());
|
||||||
|
|
||||||
|
let avatar = avatar_url_ref.get()
|
||||||
|
.map(|x| x.value())
|
||||||
|
.filter(|x| !x.is_empty())
|
||||||
|
.map(|x|
|
||||||
|
apb::new()
|
||||||
|
.set_document_type(Some(apb::DocumentType::Image))
|
||||||
|
.set_url(apb::Node::link(x))
|
||||||
|
);
|
||||||
|
|
||||||
|
let banner = banner_url_ref.get()
|
||||||
|
.map(|x| x.value())
|
||||||
|
.filter(|x| !x.is_empty())
|
||||||
|
.map(|x|
|
||||||
|
apb::new()
|
||||||
|
.set_document_type(Some(apb::DocumentType::Image))
|
||||||
|
.set_url(apb::Node::link(x))
|
||||||
|
);
|
||||||
|
|
||||||
let id = auth.userid.get_untracked().unwrap_or_default();
|
let id = auth.userid.get_untracked().unwrap_or_default();
|
||||||
let Some(me) = CACHE.get(&id) else {
|
let Some(me) = CACHE.get(&id) else {
|
||||||
|
@ -147,10 +168,10 @@ pub fn ConfigPage(setter: WriteSignal<crate::Config>) -> impl IntoView {
|
||||||
.set_to(apb::Node::links(vec![apb::target::PUBLIC.to_string(), format!("{id}/followers")]))
|
.set_to(apb::Node::links(vec![apb::target::PUBLIC.to_string(), format!("{id}/followers")]))
|
||||||
.set_object(apb::Node::object(
|
.set_object(apb::Node::object(
|
||||||
(*me).clone()
|
(*me).clone()
|
||||||
.set_name(Some(&display_name))
|
.set_name(display_name.as_deref())
|
||||||
.set_summary(Some(&summary))
|
.set_summary(summary.as_deref())
|
||||||
.set_icon(apb::Node::link(avatar))
|
.set_icon(apb::Node::maybe_object(avatar))
|
||||||
.set_image(apb::Node::link(banner))
|
.set_image(apb::Node::maybe_object(banner))
|
||||||
.set_published(Some(chrono::Utc::now()))
|
.set_published(Some(chrono::Utc::now()))
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue