feat: add option to disable post feed virtualization

This commit is contained in:
Xylight committed 2024-08-06 17:27:54 -07:00
1 parent 345d4a7366
commit 4797e5ca64
7 files changed
+26 -22

No files matched your search

@@ -47,15 +47,7 @@
{:else} {:else}
{#each combinedPosts as post, index} {#each combinedPosts as post, index}
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
<li <li class="relative post-container">
in:fly|global={{
y: -8,
duration: 500,
opacity: 0,
delay: 100 + index * 20,
}}
class="relative post-container"
>
<Post <Post
hideCommunity={community} hideCommunity={community}
view={(post.post.featured_community || post.post.featured_local) && view={(post.post.featured_community || post.post.featured_local) &&
+4
View File
@@ -799,6 +799,10 @@
"debug": { "debug": {
"title": "Debug info", "title": "Debug info",
"description": "Display debug information" "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."
} }
} }
}, },
+1 -1
View File
@@ -33,7 +33,7 @@ export async function postFeed(args: {
const feed = get(postFeeds)[args.id] const feed = get(postFeeds)[args.id]
const posts = shouldReload(feed, args.url, get(instance)) 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 : feed.data.posts
if (shouldReload(feed, args.url, get(instance)) && browser) if (shouldReload(feed, args.url, get(instance)) && browser)
+3 -1
View File
@@ -92,6 +92,7 @@ interface Settings {
deduplicateEmbed: boolean deduplicateEmbed: boolean
compactFeatured: boolean compactFeatured: boolean
showHidden: boolean showHidden: boolean
noVirtualize: boolean
} }
infiniteScroll: boolean infiniteScroll: boolean
language: string | null language: string | null
@@ -105,7 +106,7 @@ interface Settings {
} }
export const defaultSettings: Settings = { export const defaultSettings: Settings = {
settingsVer: 1, settingsVer: 2,
expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true, expandableImages: toBool(env.PUBLIC_EXPANDABLE_IMAGES) ?? true,
markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true, markReadPosts: toBool(env.PUBLIC_MARK_READ_POSTS) ?? true,
showInstances: { showInstances: {
@@ -171,6 +172,7 @@ export const defaultSettings: Settings = {
deduplicateEmbed: toBool(env.PUBLIC_DEDUPLICATE_EMBED) ?? true, deduplicateEmbed: toBool(env.PUBLIC_DEDUPLICATE_EMBED) ?? true,
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true, compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
showHidden: false, showHidden: false,
noVirtualize: false,
}, },
infiniteScroll: true, infiniteScroll: true,
language: env.PUBLIC_LANGUAGE ?? null, language: env.PUBLIC_LANGUAGE ?? null,
+11 -11
View File
@@ -7,21 +7,15 @@
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte' import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte' import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
import { searchParam } from '$lib/util.js' import { searchParam } from '$lib/util.js'
import { ChartBar, ExclamationTriangle, Icon } from 'svelte-hero-icons' import { ChartBar, Icon } from 'svelte-hero-icons'
import { getClient, site } from '$lib/lemmy.js' import { site } from '$lib/lemmy.js'
import Location from '$lib/components/lemmy/dropdowns/Location.svelte' import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte' import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js' 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 { userSettings } from '$lib/settings.js'
import { browser } from '$app/environment' import { browser } from '$app/environment'
import { onMount } from 'svelte'
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte' import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte' import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
import { postFeeds, getPostFeed } from '$lib/lemmy/postfeed.js'
export let data export let data
</script> </script>
@@ -42,13 +36,19 @@
</header> </header>
<svelte:component <svelte:component
this={browser ? VirtualFeed : PostFeed} this={$userSettings.infiniteScroll &&
browser &&
!$userSettings.posts.noVirtualize
? VirtualFeed
: PostFeed}
posts={data.posts.posts} posts={data.posts.posts}
bind:feedData={data} feedData={data}
feedId="main" feedId="main"
/> />
<svelte:element <svelte:element
this={$userSettings.infiniteScroll ? 'noscript' : 'div'} this={$userSettings.infiniteScroll && !$userSettings.posts.noVirtualize
? 'noscript'
: 'div'}
class="mt-auto" class="mt-auto"
> >
<Pageination <Pageination
+5
View File
@@ -634,6 +634,11 @@
title={$t('settings.other.debug.title')} title={$t('settings.other.debug.title')}
description={$t('settings.other.debug.description')} 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> </Section>
</div> </div>
+1
View File
@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import { t } from '$lib/translations' import { t } from '$lib/translations'
import { Badge, Switch } from 'mono-svelte' import { Badge, Switch } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
import { import {
ComputerDesktop, ComputerDesktop,
DevicePhoneMobile, DevicePhoneMobile,