From 20c7b2bcad4dc69665ebff74f3547c31789ca2ee Mon Sep 17 00:00:00 2001 From: Xylight Date: Sun, 8 Feb 2026 11:28:06 -0800 Subject: [PATCH] cleanup: $lib/feature/comment --- src/lib/app/util.svelte.ts | 15 +++++++++------ src/lib/feature/comment/CommentForm.svelte | 1 + src/lib/feature/comment/CommentItem.svelte | 7 +------ src/lib/feature/comment/CommentTree.svelte | 4 ---- src/lib/ui/sidebar/SidebarButton.svelte | 4 +--- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/lib/app/util.svelte.ts b/src/lib/app/util.svelte.ts index d0b2c90b..4c2982df 100644 --- a/src/lib/app/util.svelte.ts +++ b/src/lib/app/util.svelte.ts @@ -1,5 +1,6 @@ import { browser } from '$app/environment' import { goto } from '$app/navigation' +import { env } from '$env/dynamic/public' import { client } from '$lib/api/client.svelte' import type { Community, Person } from '$lib/api/types' import { SvelteURL } from 'svelte/reactivity' @@ -26,6 +27,7 @@ export const searchParam = ( }) } +// why is this using SvelteURL brother export const fullCommunityName = (name: string, actorId: string) => `${name}@${new SvelteURL(actorId).hostname}` @@ -33,8 +35,8 @@ export const placeholders = { get: (type: 'url' | 'post' | 'body' | 'comment') => { switch (type) { case 'post': - return Math.random() < 0.01 - ? 'A C E C* B* G D E E F G F E D C E' + return Math.random() < 0.01 && env.PUBLIC_XYLIGHT_MODE + ? 'top 10 reasons why TCP is brilliant and UDP is a spawn of satan' : t.get('placeholders.title') case 'body': return t.get('placeholders.body') @@ -46,6 +48,8 @@ export const placeholders = { }, } +// lol this function was made 3 years ago when lil xylight +// was still learning cs export function moveItem( array: T[], currentIndex: number, @@ -62,10 +66,7 @@ export function moveItem( const newArray = [...array] - // Remove the item from the current index const [item] = newArray.splice(currentIndex, 1) - - // Insert the item at the new index newArray.splice(newIndex, 0, item) return newArray @@ -139,7 +140,6 @@ export function fuzzySearch(text: string, pattern: string): number { lastIndex = index } - // Bonus for matching start of words if (textLower.startsWith(patternLower)) { score += 2 } else if (textLower.includes(' ' + patternLower)) { @@ -167,6 +167,9 @@ export function snapshot(item: T) { return $state.snapshot(item) } +// these methods should really not exist +// instead we should use lemmy's url_content_type which +// gives us a mimetype (which is more reliable) export const isImage = (url: string | undefined) => { try { if (!url) return false diff --git a/src/lib/feature/comment/CommentForm.svelte b/src/lib/feature/comment/CommentForm.svelte index 9a92cdf1..b9e46209 100644 --- a/src/lib/feature/comment/CommentForm.svelte +++ b/src/lib/feature/comment/CommentForm.svelte @@ -68,6 +68,7 @@ content: value, post_id: postId, parent_id: parentId, + language_id: language, }) oncomment?.(response) diff --git a/src/lib/feature/comment/CommentItem.svelte b/src/lib/feature/comment/CommentItem.svelte index 1b06a980..ed98447c 100644 --- a/src/lib/feature/comment/CommentItem.svelte +++ b/src/lib/feature/comment/CommentItem.svelte @@ -28,11 +28,7 @@ }: Props = $props() -
+
{#if meta}
@@ -68,7 +64,6 @@
{/if}