impr: use svelte/reactivity classes for URL, Map, Set

This commit is contained in:
James Xylight committed 2025-08-01 14:18:59 -07:00
1 parent 4680c251d2
commit d1bad1b64e
8 files changed
+21 -38

No files matched your search

@@ -1,4 +1,5 @@
import type { Comment, CommentView } from 'lemmy-js-client'
import { SvelteMap } from 'svelte/reactivity'
export interface CommentNodeI {
comment_view: CommentView
@@ -28,7 +29,7 @@ export function buildCommentsTree(
baseDepth: number = 0,
filter: (c: CommentView) => boolean = () => true,
): CommentNodeI[] {
const map = new Map<number, CommentNodeI>()
const map = new SvelteMap<number, CommentNodeI>()
let min_depth = Number.MAX_VALUE
for (const comment_view of comments) {
@@ -6,7 +6,7 @@
post: PostView
}
let { post } = $props()
let { post }: Props = $props()
</script>
<Post {post} class="py-0!" />
@@ -1,5 +1,6 @@
import { settings } from '$lib/settings.svelte'
import type { PostView } from 'lemmy-js-client'
import { SvelteMap, SvelteSet } from 'svelte/reactivity'
export type PostViewWithCrossposts = PostView & {
withCrossposts: true
@@ -10,12 +11,12 @@ export type PostViewWithoutCrossposts = PostView & { withCrossposts?: false }
export const combineCrossposts = (
posts: PostView[],
): (PostViewWithCrossposts | PostViewWithoutCrossposts)[] => {
const urlMap = new Map<
const urlMap = new SvelteMap<
string,
PostViewWithCrossposts | PostViewWithoutCrossposts
>()
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
const seenUrls = new Set<string>()
const seenUrls = new SvelteSet<string>()
posts?.forEach(post => {
if (