feat: add option to disable post feed virtualization
This commit is contained in:
1 parent
345d4a7366
commit
4797e5ca64
7 files changed
+26
-22
No files matched your search
@@ -47,15 +47,7 @@
|
||||
{:else}
|
||||
{#each combinedPosts as post, index}
|
||||
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
|
||||
<li
|
||||
in:fly|global={{
|
||||
y: -8,
|
||||
duration: 500,
|
||||
opacity: 0,
|
||||
delay: 100 + index * 20,
|
||||
}}
|
||||
class="relative post-container"
|
||||
>
|
||||
<li class="relative post-container">
|
||||
<Post
|
||||
hideCommunity={community}
|
||||
view={(post.post.featured_community || post.post.featured_local) &&
|
||||
|
||||
@@ -799,6 +799,10 @@
|
||||
"debug": {
|
||||
"title": "Debug info",
|
||||
"description": "Display debug information"
|
||||
},
|
||||
"virtualizeFeeds": {
|
||||
"title": "Don't virtualize feeds",
|
||||
"description": "Virtualization only renders visible posts, increasing performance drastically. Disable virtualization if you are having stutter problems. This will disable infinite scroll."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -33,7 +33,7 @@ export async function postFeed(args: {
|
||||
const feed = get(postFeeds)[args.id]
|
||||
|
||||
const posts = shouldReload(feed, args.url, get(instance))
|
||||
? await client({ func: fetch }).getPosts(args.request)
|
||||
? await client({ func: args.fetch }).getPosts(args.request)
|
||||
: feed.data.posts
|
||||
|
||||
if (shouldReload(feed, args.url, get(instance)) && browser)
|
||||
|
||||
+3
-1
@@ -92,6 +92,7 @@ interface Settings {
|
||||
deduplicateEmbed: boolean
|
||||
compactFeatured: boolean
|
||||
showHidden: boolean
|
||||
noVirtualize: boolean
|
||||
}
|
||||
infiniteScroll: boolean
|
||||
language: string | null
|
||||
@@ -105,7 +106,7 @@ interface Settings {
|
||||
}
|
||||
|
||||
export const defaultSettings: Settings = {
|
||||
settingsVer: 1,
|
||||
settingsVer: 2,
|
||||
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
|
||||
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
|
||||
showInstances: {
|
||||
@@ -171,6 +172,7 @@ export const defaultSettings: Settings = {
|
||||
deduplicateEmbed: toBool(env.PUBLIC_DEDUPLICATE_EMBED) ?? true,
|
||||
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
|
||||
showHidden: false,
|
||||
noVirtualize: false,
|
||||
},
|
||||
infiniteScroll: true,
|
||||
language: env.PUBLIC_LANGUAGE ?? null,
|
||||
|
||||
+11
-11
@@ -7,21 +7,15 @@
|
||||
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
|
||||
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
|
||||
import { searchParam } from '$lib/util.js'
|
||||
import { ChartBar, ExclamationTriangle, Icon } from 'svelte-hero-icons'
|
||||
import { getClient, site } from '$lib/lemmy.js'
|
||||
import { ChartBar, Icon } from 'svelte-hero-icons'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
|
||||
import Header from '$lib/components/ui/layout/pages/Header.svelte'
|
||||
import { t } from '$lib/translations.js'
|
||||
import InfiniteScroll from 'svelte-infinite-scroll'
|
||||
import { Button } from 'mono-svelte'
|
||||
import { writable } from 'svelte/store'
|
||||
import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client'
|
||||
import { userSettings } from '$lib/settings.js'
|
||||
import { browser } from '$app/environment'
|
||||
import { onMount } from 'svelte'
|
||||
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||
import { postFeeds, getPostFeed } from '$lib/lemmy/postfeed.js'
|
||||
|
||||
export let data
|
||||
</script>
|
||||
@@ -42,13 +36,19 @@
|
||||
</header>
|
||||
|
||||
<svelte:component
|
||||
this={browser ? VirtualFeed : PostFeed}
|
||||
this={$userSettings.infiniteScroll &&
|
||||
browser &&
|
||||
!$userSettings.posts.noVirtualize
|
||||
? VirtualFeed
|
||||
: PostFeed}
|
||||
posts={data.posts.posts}
|
||||
bind:feedData={data}
|
||||
feedData={data}
|
||||
feedId="main"
|
||||
/>
|
||||
<svelte:element
|
||||
this={$userSettings.infiniteScroll ? 'noscript' : 'div'}
|
||||
this={$userSettings.infiniteScroll && !$userSettings.posts.noVirtualize
|
||||
? 'noscript'
|
||||
: 'div'}
|
||||
class="mt-auto"
|
||||
>
|
||||
<Pageination
|
||||
|
||||
@@ -634,6 +634,11 @@
|
||||
title={$t('settings.other.debug.title')}
|
||||
description={$t('settings.other.debug.description')}
|
||||
/>
|
||||
<ToggleSetting
|
||||
bind:checked={$userSettings.posts.noVirtualize}
|
||||
title={$t('settings.other.virtualizeFeeds.title')}
|
||||
description={$t('settings.other.virtualizeFeeds.description')}
|
||||
/>
|
||||
</Section>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { t } from '$lib/translations'
|
||||
import { Badge, Switch } from 'mono-svelte'
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import {
|
||||
ComputerDesktop,
|
||||
DevicePhoneMobile,
|
||||
|
||||
Reference in new issue
Block a user