diff --git a/package.json b/package.json index d9b561f7..74a157ec 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "photon-lemmy", - "version": "1.21.1", + "version": "1.21.4", "private": true, "scripts": { "dev": "vite dev", diff --git a/src/lib/components/lemmy/post/PostFeed.svelte b/src/lib/components/lemmy/post/PostFeed.svelte index 9ed544d2..ff253170 100644 --- a/src/lib/components/lemmy/post/PostFeed.svelte +++ b/src/lib/components/lemmy/post/PostFeed.svelte @@ -33,27 +33,34 @@ string, PostViewWithCrossposts | PostViewWithoutCrossposts >() + const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = [] + const seenUrls = new Set() posts.forEach((post) => { - if (!post.post.url) return + if (!post.post.url) { + results.push(post) + return + } let existing = urlMap.get(post.post.url) if (existing) { - existing = addCrosspostProperty(existing, [ - ...(existing.withCrossposts ? existing.crossposts : []), - post, - ]) + existing.withCrossposts = true + if (existing.withCrossposts) { + existing.crossposts = [...(existing.crossposts || []), post] + } urlMap.set(post.post.url, existing) } else { urlMap.set(post.post.url, post) + results.push(post) } + seenUrls.add(post.post.url) }) - return Array.from(urlMap.values()) + return results } - $: combinedPosts = posts + $: combinedPosts = combineCrossposts(posts) let viewPost: number = -1 @@ -77,7 +84,7 @@ {:else} - {#each posts as post, index} + {#each combinedPosts as post, index} {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
  • + + {#if post.withCrossposts && viewPost == post.post.id} +
    + + Crossposts
    + {post.crossposts.length} +
    + {#each post.crossposts as crosspost, index} +
    + +
    + {/each} +
    + {/if}
  • {/if} {/each}