feat: add option to hide read posts
This commit is contained in:
1 parent
8f58a9a181
commit
8a1fe35897
4 files changed
+36
-41
No files matched your search
@@ -1,23 +1,39 @@
|
||||
<script lang="ts">
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import type { PostView } from 'lemmy-js-client'
|
||||
import { ArchiveBox, Icon, Plus } from 'svelte-hero-icons'
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
export let posts: PostView[]
|
||||
</script>
|
||||
|
||||
{#each posts as post, index (post.post.id)}
|
||||
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
|
||||
<div
|
||||
in:fly={{
|
||||
y: -8,
|
||||
duration: 500,
|
||||
opacity: 0,
|
||||
delay: index < 4 ? index * 100 : 0,
|
||||
}}
|
||||
>
|
||||
<Post {post} />
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{#if posts.length == 0}
|
||||
<div class="h-full grid place-items-center">
|
||||
<Placeholder>
|
||||
<Icon src={ArchiveBox} size="32" solid slot="icon" />
|
||||
<span slot="title">No posts</span>
|
||||
<Button href="/communities" class="mt-4" slot="action">
|
||||
<Icon src={Plus} size="16" mini slot="icon" />
|
||||
<span>Follow some communities</span>
|
||||
</Button>
|
||||
</Placeholder>
|
||||
</div>
|
||||
{:else}
|
||||
{#each posts as post, index (post.post.id)}
|
||||
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed) && !($userSettings.hidePosts.read && post.read)}
|
||||
<div
|
||||
in:fly={{
|
||||
y: -8,
|
||||
duration: 500,
|
||||
opacity: 0,
|
||||
delay: index < 4 ? index * 100 : 0,
|
||||
}}
|
||||
>
|
||||
<Post {post} />
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
+2
-12
@@ -36,7 +36,7 @@
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
<div class="flex flex-row gap-4 w-full">
|
||||
<div class="flex flex-row gap-4 w-full h-full">
|
||||
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
||||
<header>
|
||||
<h1 class="text-3xl font-bold">Frontpage</h1>
|
||||
@@ -55,17 +55,7 @@
|
||||
/>
|
||||
<Sort selected={data.sort} />
|
||||
</div>
|
||||
<section class="flex flex-col gap-3 sm:gap-4">
|
||||
{#if data.posts.posts.length == 0}
|
||||
<Placeholder>
|
||||
<Icon src={ArchiveBox} size="32" solid slot="icon" />
|
||||
<span slot="title">No posts</span>
|
||||
<Button href="/communities" class="mt-4" slot="action">
|
||||
<Icon src={Plus} size="16" mini slot="icon" />
|
||||
<span>Follow some communities</span>
|
||||
</Button>
|
||||
</Placeholder>
|
||||
{/if}
|
||||
<section class="flex flex-col gap-3 sm:gap-4 h-full">
|
||||
<PostFeed posts={data.posts.posts} />
|
||||
</section>
|
||||
<div class="mt-auto">
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import { fullCommunityName, searchParam } from '$lib/util.js'
|
||||
import { onDestroy, onMount } from 'svelte'
|
||||
import { setSessionStorage } from '$lib/session.js'
|
||||
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -77,13 +78,7 @@
|
||||
<div class="flex flex-col sm:flex-row gap-4 max-w-full w-full">
|
||||
<Sort selected={data.sort} />
|
||||
</div>
|
||||
{#each data.posts.posts as post, index (post.post.id)}
|
||||
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
|
||||
<div in:fly={{ y: -8, opacity: 0, delay: index < 4 ? index * 100 : 0 }}>
|
||||
<Post hideCommunity={true} {post} />
|
||||
</div>
|
||||
{/if}
|
||||
{/each}
|
||||
<PostFeed posts={data.posts.posts} />
|
||||
<Pageination
|
||||
page={data.page}
|
||||
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
import Subscribe from './Subscribe.svelte'
|
||||
import Button from '$lib/components/input/Button.svelte'
|
||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
|
||||
export let data
|
||||
|
||||
@@ -28,14 +29,7 @@
|
||||
<MultiSelect
|
||||
options={['Subscribed', 'Local', 'All']}
|
||||
selected={$page.url.searchParams.get('type') ?? 'All'}
|
||||
on:select={(e) => {
|
||||
const url = $page.url
|
||||
url.searchParams.set('type', e.detail)
|
||||
url.searchParams.delete('page')
|
||||
goto(url, {
|
||||
invalidateAll: true,
|
||||
})
|
||||
}}
|
||||
on:select={(e) => searchParam($page.url, 'type', e.detail, 'page')}
|
||||
/>
|
||||
<div class="flex flex-col sm:flex-row gap-2 sm:ml-auto items-center">
|
||||
<TextInput
|
||||
|
||||
Reference in new issue
Block a user