Better handle exists error, prefer webp to png, jpg, banner to jpg, icon to png
This commit is contained in:
parent
5c280ef6f6
commit
c6562da430
|
@ -215,23 +215,34 @@ async fn do_create_handle(
|
|||
let domain = state.domain.clone();
|
||||
let handle = form.handle.clone();
|
||||
|
||||
use hyaenidae_profiles::apub::actions::CreateProfile;
|
||||
|
||||
let res = state
|
||||
let exists = state
|
||||
.profiles
|
||||
.run(&CreateProfile::from_local(user_id, handle, domain))
|
||||
.await;
|
||||
.store
|
||||
.profiles
|
||||
.by_handle(&handle, &domain)?
|
||||
.is_some();
|
||||
|
||||
let error = match res {
|
||||
Ok(Some(id)) => {
|
||||
session
|
||||
.set("current-profile", CurrentProfile { id })
|
||||
.ok()
|
||||
.req()?;
|
||||
return Ok(to_bio());
|
||||
let error = if !exists {
|
||||
use hyaenidae_profiles::apub::actions::CreateProfile;
|
||||
|
||||
let res = state
|
||||
.profiles
|
||||
.run(&CreateProfile::from_local(user_id, handle, domain))
|
||||
.await;
|
||||
|
||||
match res {
|
||||
Ok(Some(id)) => {
|
||||
session
|
||||
.set("current-profile", CurrentProfile { id })
|
||||
.ok()
|
||||
.req()?;
|
||||
return Ok(to_bio());
|
||||
}
|
||||
Ok(None) => None,
|
||||
Err(e) => Some(e.to_string()),
|
||||
}
|
||||
Ok(None) => None,
|
||||
Err(e) => Some(e.to_string()),
|
||||
} else {
|
||||
Some("Handle already in use".to_owned())
|
||||
};
|
||||
|
||||
let mut handle_input = hyaenidae_toolkit::TextInput::new("handle");
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
<div class="profile-view--banner">
|
||||
@if let Some(banner) = profile.banner_key() {
|
||||
<picture>
|
||||
<source
|
||||
type="image/jpeg"
|
||||
srcset="@banner_srcset(banner, ImageType::Jpeg)"
|
||||
/>
|
||||
<source
|
||||
type="image/webp"
|
||||
srcset="@banner_srcset(banner, ImageType::Webp)"
|
||||
/>
|
||||
<source
|
||||
type="image/jpeg"
|
||||
srcset="@banner_srcset(banner, ImageType::Jpeg)"
|
||||
/>
|
||||
<img
|
||||
href="@largest_banner(banner, ImageType::Jpeg)"
|
||||
title="@profile.name()'s banner"
|
||||
|
@ -29,16 +29,16 @@
|
|||
<div class="profile-view--icon">
|
||||
@if let Some(icon) = profile.icon_key() {
|
||||
<picture>
|
||||
<source
|
||||
type="image/jpeg"
|
||||
srcset="@icon_srcset(icon, ImageType::Jpeg)"
|
||||
/>
|
||||
<source
|
||||
type="image/webp"
|
||||
srcset="@icon_srcset(icon, ImageType::Webp)"
|
||||
/>
|
||||
<source
|
||||
type="image/png"
|
||||
srcset="@icon_srcset(icon, ImageType::Png)"
|
||||
/>
|
||||
<img
|
||||
href="@largest_icon(icon, ImageType::Jpeg)"
|
||||
href="@largest_icon(icon, ImageType::Png)"
|
||||
title="@profile.name()'s icon"
|
||||
alt="@profile.name()'s icon"
|
||||
/>
|
||||
|
@ -46,10 +46,14 @@
|
|||
}
|
||||
</div>
|
||||
<div class="profile-view--meta">
|
||||
@if let Some(name) = profile.display_name() {
|
||||
<span class="profile-view--meta--display">@name</span>
|
||||
}
|
||||
<span class="profile-view--meta--handle">@@@profile.full_handle()</span>
|
||||
<div class="profile-view--meta--display">
|
||||
@if let Some(name) = profile.display_name() {
|
||||
@name
|
||||
} else {
|
||||
|
||||
}
|
||||
</div>
|
||||
<div class="profile-view--meta--handle">@@@profile.full_handle()</div>
|
||||
</div>
|
||||
</div>
|
||||
@if let Some(description) = profile.description() {
|
||||
|
|
Loading…
Reference in a new issue