add: better quote post ui
This commit is contained in:
parent
fb2a9285d2
commit
2b91422d18
8 changed files with 138 additions and 102 deletions
|
@ -243,6 +243,8 @@ pub struct CreatePostProps {
|
|||
pub community: usize,
|
||||
#[serde(default)]
|
||||
pub from_draft: usize,
|
||||
#[serde(default)]
|
||||
pub quote: usize,
|
||||
}
|
||||
|
||||
/// `/communities/intents/post`
|
||||
|
@ -299,12 +301,29 @@ pub async fn create_post_request(
|
|||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
};
|
||||
|
||||
// get quoting
|
||||
let quoting = if props.quote != 0 {
|
||||
match data.0.get_post_by_id(props.quote).await {
|
||||
Ok(q) => Some((
|
||||
match data.0.get_user_by_id(q.owner).await {
|
||||
Ok(ua) => ua,
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
},
|
||||
q,
|
||||
)),
|
||||
Err(e) => return Err(Html(render_error(e, &jar, &data, &Some(user)).await)),
|
||||
}
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
// ...
|
||||
let lang = get_lang!(jar, data.0);
|
||||
let mut context = initial_context(&data.0.0, lang, &Some(user)).await;
|
||||
|
||||
context.insert("draft", &draft);
|
||||
context.insert("drafts", &drafts);
|
||||
context.insert("quoting", "ing);
|
||||
context.insert("communities", &communities);
|
||||
context.insert("selected_community", &props.community);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue