fix: change keying of virtual feeds

This commit is contained in:
Xylight committed 2024-10-20 16:14:45 -07:00
1 parent 4ff574f6e4
commit 0c0509d436
4 files changed
+16 -32

No files matched your search

+1
View File
@@ -30,6 +30,7 @@
"svelte-hero-icons": "^5.2.0", "svelte-hero-icons": "^5.2.0",
"svelte-infinite-scroll": "^2.0.1", "svelte-infinite-scroll": "^2.0.1",
"svelte-markdown": "^0.4.1", "svelte-markdown": "^0.4.1",
"svelte-virtual-scroll-list": "^1.3.0",
"sveltekit-i18n": "^2.4.2", "sveltekit-i18n": "^2.4.2",
"tailwindcss": "^3.3.3", "tailwindcss": "^3.3.3",
"tslib": "^2.4.1", "tslib": "^2.4.1",
+5 -6
View File
@@ -36,9 +36,8 @@
export let hideCommunity = false export let hideCommunity = false
export let view = $userSettings.view export let view = $userSettings.view
$: type = mediaType(post.post.url, view)
$: tags = parseTags(post.post.name) $: tags = parseTags(post.post.name)
$: type = mediaType(post.post.url, view)
$: rule = getTagRule(tags.tags) $: rule = getTagRule(tags.tags)
$: hideTitle = $: hideTitle =
@@ -141,7 +140,7 @@
> >
{#if rule != 'hide'} {#if rule != 'hide'}
<PostMedia <PostMedia
bind:post={post.post} post={post.post}
blur={rule == 'blur' ? true : undefined} blur={rule == 'blur' ? true : undefined}
{view} {view}
{type} {type}
@@ -150,8 +149,8 @@
</div> </div>
{#if view == 'list' || view == 'compact'} {#if view == 'list' || view == 'compact'}
<PostMediaCompact <PostMediaCompact
bind:post={post.post} post={post.post}
bind:type {type}
class="{$userSettings.leftAlign class="{$userSettings.leftAlign
? 'mr-3' ? 'mr-3'
: 'ml-3'} flex-shrink no-list-margin" : 'ml-3'} flex-shrink no-list-margin"
@@ -171,7 +170,7 @@
/> />
{/if} {/if}
{#if actions} {#if actions}
<PostActions on:hide bind:post style="grid-area: actions;" {view} /> <PostActions on:hide {post} style="grid-area: actions;" {view} />
{:else if view == 'compact'} {:else if view == 'compact'}
<div class="flex flex-row items-center gap-2 text-sm"> <div class="flex flex-row items-center gap-2 text-sm">
<Badge> <Badge>
+5 -22
View File
@@ -18,9 +18,9 @@
let extracted: Tag[] = [] let extracted: Tag[] = []
const newTitle = title.replace( const newTitle = title
/^(\[.[^\]]+\])|(\[.[^\]]+\])$/g, .toString()
(match, content) => { .replace(/^(\[.[^\]]+\])|(\[.[^\]]+\])$/g, (match, content) => {
const contents = match.split(',').map((part: string) => part.trim()) const contents = match.split(',').map((part: string) => part.trim())
contents contents
@@ -33,8 +33,7 @@
) )
}) })
return '' return ''
} })
)
return { return {
tags: extracted, tags: extracted,
@@ -98,22 +97,6 @@
export let tags: Tag[] = [] export let tags: Tag[] = []
let displayTitle = title
const update = () => {
if (tags.length == 0) {
const result = parseTags(title)
tags = result.tags
displayTitle = result.title
}
}
$: {
if (title) {
update()
}
}
let popoverOpen = false let popoverOpen = false
</script> </script>
@@ -306,7 +289,7 @@
data-sveltekit-preload-data="tap" data-sveltekit-preload-data="tap"
> >
<Markdown <Markdown
source={displayTitle} source={title}
inline inline
noStyle noStyle
class={view == 'compact' ? '' : 'leading-[1.3]'} class={view == 'compact' ? '' : 'leading-[1.3]'}
@@ -217,7 +217,9 @@
class="divide-y divide-slate-200 dark:divide-zinc-800" class="divide-y divide-slate-200 dark:divide-zinc-800"
id="feed" id="feed"
> >
{#each items as row, index (row.index)} {#each items as row, index (posts[row.index]?.post.id)}
{#if posts[row.index]}
{@const post = posts?.[row.index]}
<li <li
bind:this={virtualItemEls[index]} bind:this={virtualItemEls[index]}
data-index={row.index} data-index={row.index}
@@ -226,7 +228,6 @@
? 'pop-in opacity-0' ? 'pop-in opacity-0'
: ''}" : ''}"
> >
{#if posts[row.index]}
<Post <Post
hideCommunity={community} hideCommunity={community}
view={(posts[row.index]?.post.featured_community || view={(posts[row.index]?.post.featured_community ||
@@ -234,14 +235,14 @@
$userSettings.posts.compactFeatured $userSettings.posts.compactFeatured
? 'compact' ? 'compact'
: $userSettings.view} : $userSettings.view}
post={posts?.[row.index]} {post}
class="transition-all duration-250" class="transition-all duration-250"
on:hide={() => { on:hide={() => {
posts = posts.toSpliced(row.index, 1) posts = posts.toSpliced(row.index, 1)
}} }}
></Post> ></Post>
{/if}
</li> </li>
{/if}
{/each} {/each}
</div> </div>
</div> </div>