chore: Update UserAvatar component to display user's first initial if no icon is provided
This commit is contained in:
@@ -3,14 +3,6 @@
|
|||||||
import { goto } from "$app/navigation";
|
import { goto } from "$app/navigation";
|
||||||
export let user: any;
|
export let user: any;
|
||||||
|
|
||||||
let icon: string = "";
|
|
||||||
|
|
||||||
if (user.icon != null && user.icon != "") {
|
|
||||||
icon = user.icon;
|
|
||||||
} else {
|
|
||||||
icon = user.username.charAt(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function navToSettings() {
|
async function navToSettings() {
|
||||||
goto("/settings");
|
goto("/settings");
|
||||||
}
|
}
|
||||||
@@ -22,7 +14,11 @@
|
|||||||
<div class="dropdown dropdown-bottom dropdown-end" tabindex="0" role="button">
|
<div class="dropdown dropdown-bottom dropdown-end" tabindex="0" role="button">
|
||||||
<div class="avatar placeholder">
|
<div class="avatar placeholder">
|
||||||
<div class="bg-neutral text-neutral-content rounded-full w-10 ml-4">
|
<div class="bg-neutral text-neutral-content rounded-full w-10 ml-4">
|
||||||
<img src={user.icon} alt="" />
|
{#if user.icon}
|
||||||
|
<img src={user.icon} alt="" />
|
||||||
|
{:else}
|
||||||
|
<span class="text-2xl -mt-1">{user.first_name[0]}</span>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- svelte-ignore a11y-missing-attribute -->
|
<!-- svelte-ignore a11y-missing-attribute -->
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ export async function POST(event: RequestEvent): Promise<Response> {
|
|||||||
try {
|
try {
|
||||||
const contentType = event.request.headers.get("content-type") ?? "";
|
const contentType = event.request.headers.get("content-type") ?? "";
|
||||||
const fileExtension = contentType.split("/").pop();
|
const fileExtension = contentType.split("/").pop();
|
||||||
const fileName = `${generateId(50)}.${fileExtension}`;
|
const fileName = `${generateId(75)}.${fileExtension}`;
|
||||||
const bucket = event.request.headers.get("bucket") as string;
|
const bucket = event.request.headers.get("bucket") as string;
|
||||||
|
|
||||||
if (!fileExtension || !fileName) {
|
if (!fileExtension || !fileName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user