Merge pull request #624 from Xyphyn/optimizations

perf: improve efficiency and performance
This commit is contained in:
Xylight authored and GitHub committed 2025-08-01 21:21:52 +00:00
commit 7e188f218a
32 files changed
+248 -470

No files matched your search

+4 -3
View File
@@ -38,9 +38,10 @@
src={open ? Minus : Plus}
size="16"
micro
class="{open
? ''
: 'rotate-90'} transition-transform duration-300 ease-out"
class={[
open && 'rotate-180',
'transition-transform duration-300 ease-out',
]}
/>
{/if}
<div
+3 -2
View File
@@ -6,6 +6,7 @@
import { fly } from 'svelte/transition'
import { page as pageData } from '$app/state'
import { invalidate } from '$app/navigation'
import { SvelteURLSearchParams } from 'svelte/reactivity'
interface Props {
page?: number
@@ -27,8 +28,8 @@
let customHref = (href?: string) => {
if (href?.startsWith('?')) {
const current = new URLSearchParams(pageData.url.searchParams)
const newParams = new URLSearchParams(href)
const current = new SvelteURLSearchParams(pageData.url.searchParams)
const newParams = new SvelteURLSearchParams(href)
current.delete(Array.from(newParams.keys())[0])
current.append(
@@ -0,0 +1,48 @@
<script lang="ts">
let progress = $state(0)
let increaseInterval: number = -1
let startTimeout: number = -1
let stopTimeout: number = -1
export function start() {
clearTimeout(stopTimeout)
progress = 0
startTimeout = setTimeout(() => {
progress = 1
// schedule a setInterval and run the code immediately
;(function i() {
if (progress < 100 && progress > 0)
// slowly get closer and closer to 90% -- 100% doesnt look very good to be stuck on
progress += (100 - (progress - 10)) / 4
increaseInterval = setInterval(i, 400) as unknown as number
})()
}, 100) as unknown as number
}
export function stop() {
if (progress != 0) progress = 100
// reset progress to 0 after bar disappears
setTimeout(() => (progress = 0), 500)
clearInterval(increaseInterval)
clearTimeout(startTimeout)
}
</script>
<div
class={[
'fixed top-0 left-0 h-px z-[400] bg-primary-900 dark:bg-primary-100',
progress == 100 && 'opacity-0',
progress > 0 && 'use-transition',
]}
style="width: {progress}%;"
id="progress-bar"
></div>
<style>
#progress-bar.use-transition {
transition:
width 0.7s cubic-bezier(0, 0, 0.22, 0.76),
opacity 0.5s linear;
}
</style>
+1 -1
View File
@@ -97,7 +97,7 @@
}
}
@media (min-width: 1280px) {
@media (min-width: 80rem) {
.content {
grid-template-columns: 20% 60% 20%;
justify-items: end center start;
@@ -45,6 +45,7 @@ import {
ViewColumns,
type IconSource,
} from 'svelte-hero-icons'
import { SvelteURL } from 'svelte/reactivity'
export interface Group {
name: string
@@ -411,7 +412,7 @@ export function getGroups(
f.community.name,
f.community.actor_id,
)}`,
detail: new URL(f.community.actor_id).hostname,
detail: new SvelteURL(f.community.actor_id).hostname,
})) ?? [],
},
]
@@ -18,9 +18,7 @@
</script>
<SidebarButton
alignment="left"
loading={switching}
rounding="lg"
loaderWidth={22}
selected={profile.current?.id == prof.id}
onclick={async () => {
@@ -47,9 +45,10 @@
/>
{/snippet}
<span
class="inline-flex flex-col gap-0 {profile.current?.id == prof.id
? 'font-semibold'
: ''}"
class={[
'inline-flex flex-col gap-0',
profile.current?.id == prof.id && 'font-semibold',
]}
>
{prof.username ?? prof.user?.local_user_view.person.name}
{#if !guest && !LINKED_INSTANCE_URL}
+15 -21
View File
@@ -34,29 +34,25 @@
{#if profile.current?.jwt}
<SidebarButton icon={UserCircle} href="/profile">
{#snippet label()}
<span>
{$t('profile.profile')}
</span>
{$t('profile.profile')}
{/snippet}
</SidebarButton>
<SidebarButton icon={Inbox} href="/inbox">
{#snippet label()}
<span class="flex items-center gap-2">
{$t('profile.inbox')}
{#if $notifications.inbox}
<Badge
class="min-w-5 h-5 p-0! px-0.5 grid place-items-center ml-auto"
color="red-subtle"
>
{$notifications.inbox > 99 ? '∞' : $notifications.inbox}
</Badge>
{/if}
</span>
{$t('profile.inbox')}
{#if $notifications.inbox}
<Badge
class="min-w-5 h-5 p-0! px-0.5 grid place-items-center ml-auto"
color="red-subtle"
>
{$notifications.inbox > 99 ? '∞' : $notifications.inbox}
</Badge>
{/if}
{/snippet}
</SidebarButton>
<SidebarButton icon={Bookmark} href="/saved">
{#snippet label()}
<span>{$t('profile.saved')}</span>
{$t('profile.saved')}
{/snippet}
</SidebarButton>
{:else}
@@ -66,7 +62,7 @@
icon={ArrowLeftOnRectangle}
>
{#snippet label()}
<span>{$t('account.login')}</span>
{$t('account.login')}
{/snippet}
</SidebarButton>
<SidebarButton
@@ -75,7 +71,7 @@
icon={Identification}
>
{#snippet label()}
<span>{$t('account.signup')}</span>
{$t('account.signup')}
{/snippet}
</SidebarButton>
<SidebarButton
@@ -84,7 +80,7 @@
icon={Cog6Tooth}
>
{#snippet label()}
<span>{$t('nav.menu.settings')}</span>
{$t('nav.menu.settings')}
{/snippet}
</SidebarButton>
{/if}
@@ -109,9 +105,7 @@
{/snippet}
<div class="w-full flex gap-px flex-col">
{#each [...profile.meta.profiles] as prof, index}
<div class="w-full">
<ProfileButton {index} {prof} />
</div>
<ProfileButton {index} {prof} />
{/each}
</div>
<SidebarButton href="/accounts" icon={UserGroup}>