Revert "perf: improve efficiency and performance"

This commit is contained in:
Xylight authored and GitHub committed 2025-08-01 21:26:04 +00:00
1 parent 7e188f218a
commit 4177b42fc2
32 files changed
+470 -248

No files matched your search

+22 -18
View File
@@ -2,6 +2,7 @@
import { browser } from '$app/environment'
import { navigating, page } from '$app/state'
import Moderation from '$lib/components/lemmy/moderation/Moderation.svelte'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
import Shell from '$lib/components/ui/layout/Shell.svelte'
import Navbar from '$lib/components/ui/navbar/Navbar.svelte'
@@ -13,17 +14,25 @@
import { inDarkColorScheme, rgbToHex, theme } from '$lib/ui/colors.svelte.js'
import { getDefaultColors } from '$lib/ui/presets'
import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte'
import nProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { onMount } from 'svelte'
import { Forward, Icon } from 'svelte-hero-icons'
import '../style/app.css'
import NavigationProgress from '$lib/components/ui/layout/NavigationProgress.svelte'
interface Props {
children?: import('svelte').Snippet
}
let { children }: Props = $props()
let progressBar = $state<{ start: () => void; stop: () => void }>()
nProgress.configure({
minimum: 0.4,
trickleSpeed: 200,
easing: 'ease-out',
speed: 300,
showSpinner: false,
})
onMount(() => {
if (browser) {
if (window.location.hash == 'main') {
@@ -63,12 +72,12 @@
document.documentElement.dir =
($locale == 'he' || $locale == 'ar') && settings.useRtl ? 'rtl' : 'ltr'
})
$effect(() => {
if (navigating.to) progressBar?.start()
else progressBar?.stop()
})
}
$effect(() => {
if (navigating.to) nProgress.start()
else nProgress.done()
})
</script>
<svelte:head>
@@ -96,7 +105,6 @@
<Button
class="fixed -top-16 focus:top-0 left-0 m-4 z-300 transition-all"
href="#main"
onclick={() => document.getElementById('main')?.focus()}
>
{#snippet prefix()}
<Icon src={Forward} mini size="16" />
@@ -104,8 +112,6 @@
Skip Navigation
</Button>
<NavigationProgress bind:this={progressBar} />
<Shell>
<Moderation />
<ToastContainer />
@@ -133,14 +139,12 @@
{@const SvelteComponent = page.data.slots.sidebar.component}
<SvelteComponent {...page.data.slots.sidebar.props} class="pt-0!" />
{:else if site.data}
{#await import('$lib/components/lemmy/SiteCard.svelte') then { default: SiteCard }}
<SiteCard
site={site.data.site_view}
taglines={site.data.taglines}
admins={site.data.admins}
version={site.data.version}
/>
{/await}
<SiteCard
site={site.data.site_view}
taglines={site.data.taglines}
admins={site.data.admins}
version={site.data.version}
/>
{:else}
<div class="h-64 w-full grid place-items-center">
<Spinner width={32} />
+3 -4
View File
@@ -12,7 +12,6 @@
import { Button } from 'mono-svelte'
import { ArrowPath, Check, Icon, Inbox } from 'svelte-hero-icons'
import InboxItem from './InboxItem.svelte'
import { SvelteURLSearchParams } from 'svelte/reactivity'
let { data } = $props()
@@ -43,11 +42,11 @@
currentSearchParams: URLSearchParams,
newParamString: string,
) {
// Create a new SvelteURLSearchParams object from the current search params
const updatedParams = new SvelteURLSearchParams(currentSearchParams)
// Create a new URLSearchParams object from the current search params
const updatedParams = new URLSearchParams(currentSearchParams)
// Parse the new parameter string
const newParam = new SvelteURLSearchParams(newParamString)
const newParam = new URLSearchParams(newParamString)
// Get the key and value of the new parameter
const [key, value]: [string, string] = newParam.entries().next().value!
+1 -2
View File
@@ -16,7 +16,6 @@
import { Button, Modal } from 'mono-svelte'
import { ChatBubbleOvalLeftEllipsis, Icon, Inbox } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { SvelteSet } from 'svelte/reactivity'
import { fly } from 'svelte/transition'
interface ConversationPreview {
@@ -35,7 +34,7 @@
}
function filterDuplicates<T, K>(array: T[], predicate: (item: T) => K): T[] {
const seen = new SvelteSet()
const seen = new Set()
return array.filter(element => {
const value = predicate(element)
if (seen.has(value)) {
+48
View File
@@ -0,0 +1,48 @@
<script lang="ts">
import { profile } from '$lib/auth.svelte'
import Portal from 'mono-svelte/popover/Portal.svelte'
import { onDestroy, onMount } from 'svelte'
let audio = $state<HTMLAudioElement>()
onMount(() => {
audio?.play()
document.body.style.rotate = `5deg`
document.body.style.transition = 'rotate 1s linear'
})
onDestroy(() => {
document.body.style.rotate = ''
})
</script>
<audio bind:this={audio}>
<source src="/other/mc.mp3" type="audio/mpeg" />
</audio>
<Portal class="z-50 fixed inset-0">
<div
class="inset-0 bg-red-500/20 w-screen h-screen flex flex-col gap-4 items-center p-16 z-50"
style="rotate: -5deg; transition: rotate 1s linear;"
>
<div class="bg-black/20 font-mono fixed left-1/2 -translate-x-1/2">
<p>{profile.current.username ?? 'You'} was slain by Command Palette</p>
</div>
<img
src="/other/mc.png"
class="object-contain w-full h-full"
alt="Minecraft 'you died'"
/>
</div>
</Portal>
<style>
@font-face {
font-family: 'mc';
src: url('/other/mc.otf') format('opentype');
}
.main {
font-family: 'mc';
}
</style>