optimize: denest post

This commit is contained in:
Xylight committed 2024-02-24 10:25:49 -08:00
1 parent 53318d2e5b
commit 725bce893c
2 files changed
+46 -68

No files matched your search

+36 -62
View File
@@ -29,14 +29,12 @@
export let view = $userSettings.view export let view = $userSettings.view
$: type = mediaType(post.post.url, view) $: type = mediaType(post.post.url, view)
let loaded = false
</script> </script>
<Material <Material
color={view != 'card' ? 'none' : 'distinct'} color={view != 'card' ? 'none' : 'distinct'}
padding="none" padding="none"
class="relative max-w-full min-w-0 w-full group z-10 isolation-auto class="relative max-w-full min-w-0 w-full group z-10 flex flex-col gap-2
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact' {view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
? 'py-4' ? 'py-4'
: view == 'list' : view == 'list'
@@ -52,66 +50,42 @@
" "
></button> ></button>
{/if} {/if}
<div <PostMeta
class="flex {$userSettings.leftAlign community={hideCommunity ? undefined : post.community}
? 'flex-row-reverse' user={post.creator}
: 'flex-row'} gap-4 max-w-full w-full min-w-0" published={publishedToDate(post.post.published)}
deleted={post.post.deleted}
removed={post.post.removed}
locked={post.post.locked}
featured={post.post.featured_local || post.post.featured_community}
nsfw={post.post.nsfw}
saved={post.saved}
subscribed={$profile?.user?.follows
.map((c) => c.community.id)
.includes(post.community.id)
? 'Subscribed'
: 'NotSubscribed'}
id={post.post.id}
title={post.post.name}
> >
<div class="flex flex-col w-full gap-2 flex-1 max-w-full min-w-0"> <slot name="badges" slot="badges" />
<div class="flex flex-col w-full gap-2 z-10"> </PostMeta>
<PostMeta <PostMedia bind:post={post.post} {view} {type} />
community={hideCommunity ? undefined : post.community} {#if post.post.body && !post.post.nsfw && view != 'compact'}
user={post.creator} <PostBody body={post.post.body} {view} />
published={publishedToDate(post.post.published)} {/if}
deleted={post.post.deleted} {#if view == 'list' || view == 'compact'}
removed={post.post.removed} <PostMediaCompact {view} bind:post={post.post} />
locked={post.post.locked} {/if}
featured={post.post.featured_local || post.post.featured_community}
nsfw={post.post.nsfw}
saved={post.saved}
subscribed={$profile?.user?.follows
.map((c) => c.community.id)
.includes(post.community.id)
? 'Subscribed'
: 'NotSubscribed'}
>
<slot name="badges" slot="badges" />
</PostMeta>
{#if !(post.post.embed_title == post.post.name && type == 'embed') || view == 'compact'}
<a
target={$userSettings.openLinksInNewTab ? '_blank' : ''}
href="/post/{getInstance()}/{post.post.id}"
class="font-medium max-w-full w-full break-words text-base"
style="word-break: break-word;"
class:text-slate-500={post.read && $userSettings.markReadPosts}
class:dark:text-zinc-400={post.read && $userSettings.markReadPosts}
>
<Markdown source={post.post.name} inline />
</a>
{/if}
</div>
<div class="contents z-50 isolate">
<PostMedia bind:post={post.post} {view} {type} />
</div>
{#if post.post.body && !post.post.nsfw && view != 'compact'}
<PostBody body={post.post.body} {view} />
{/if}
</div>
{#if view == 'list' || view == 'compact'}
<PostMediaCompact {view} bind:post={post.post} />
{/if}
</div>
{#if actions} {#if actions}
<div class="w-full mt-2"> <PostActions
<PostActions bind:post
bind:post on:edit={(e) => {
on:edit={(e) => { toast({
toast({ content: 'The post was edited successfully.',
content: 'The post was edited successfully.', type: 'success',
type: 'success', })
}) }}
}} />
/>
</div>
{/if} {/if}
</Material> </Material>
+10 -6
View File
@@ -77,7 +77,7 @@
<CommunityLink {community} style="grid-area: community;" /> <CommunityLink {community} style="grid-area: community;" />
{/if} {/if}
<span <span
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 flex-wrap items-center row-span-2" class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 flex-wrap items-center row-span-1"
style="grid-area: stats;" style="grid-area: stats;"
> >
{#if user} {#if user}
@@ -127,12 +127,16 @@
{/if} {/if}
<slot name="badges" /> <slot name="badges" />
</div> </div>
{#if title && id}
<a href="/post/{getInstance()}/{id}" class="font-medium">
{title}
</a>
{/if}
</div> </div>
{#if title && id}
<a
href="/post/{getInstance()}/{id}"
class="font-medium row-span-1 text-base"
style="grid-area: title;"
>
{title}
</a>
{/if}
<style> <style>
.meta { .meta {