Merge pull request #349 from Xyphyn/infinite-scroll
feat: add infinite scroll
This commit is contained in:
19 files changed
+561
-110
No files matched your search
+13
-12
@@ -1,17 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "1.30.4",
|
"version": "1.30.4",
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"dev": "vite dev",
|
|
||||||
"build": "vite build",
|
|
||||||
"test": "vitest",
|
|
||||||
"preview": "vite preview",
|
|
||||||
"start": "node build/index.js",
|
|
||||||
"bunstart": "bun build/index.js",
|
|
||||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
|
||||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@catdadcode/svelte-adapter-bun": "^0.5.7",
|
"@catdadcode/svelte-adapter-bun": "^0.5.7",
|
||||||
"@dicebear/core": "^8.0.1",
|
"@dicebear/core": "^8.0.1",
|
||||||
@@ -22,6 +11,7 @@
|
|||||||
"@sveltejs/kit": "latest",
|
"@sveltejs/kit": "latest",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
"@sveltejs/vite-plugin-svelte": "^3.0.0",
|
||||||
"@tailwindcss/container-queries": "^0.1.1",
|
"@tailwindcss/container-queries": "^0.1.1",
|
||||||
|
"@tanstack/svelte-virtual": "^3.8.1",
|
||||||
"@types/markdown-it": "^12.2.3",
|
"@types/markdown-it": "^12.2.3",
|
||||||
"@types/markdown-it-container": "^2.0.6",
|
"@types/markdown-it-container": "^2.0.6",
|
||||||
"@types/nprogress": "^0.2.0",
|
"@types/nprogress": "^0.2.0",
|
||||||
@@ -40,7 +30,7 @@
|
|||||||
"svelte": "latest",
|
"svelte": "latest",
|
||||||
"svelte-check": "^3.0.1",
|
"svelte-check": "^3.0.1",
|
||||||
"svelte-hero-icons": "^5.0.0",
|
"svelte-hero-icons": "^5.0.0",
|
||||||
"svelte-tiny-virtual-list": "^2.0.5",
|
"svelte-infinite-scroll": "^2.0.1",
|
||||||
"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",
|
||||||
@@ -50,5 +40,16 @@
|
|||||||
"vitest": "^1.0.0",
|
"vitest": "^1.0.0",
|
||||||
"workbox-window": "^7.0.0"
|
"workbox-window": "^7.0.0"
|
||||||
},
|
},
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite dev",
|
||||||
|
"build": "vite build",
|
||||||
|
"test": "vitest",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"start": "node build/index.js",
|
||||||
|
"bunstart": "bun build/index.js",
|
||||||
|
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||||
|
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
|
||||||
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
class="items-center flex flex-row gap-2 hover:underline max-w-full min-w-0 {$$props.class ||
|
class="items-center flex flex-row gap-2 hover:underline max-w-full min-w-0 {$$props.class ||
|
||||||
''}"
|
''}"
|
||||||
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
|
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
|
||||||
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
{#if avatar}
|
{#if avatar}
|
||||||
<Avatar
|
<Avatar
|
||||||
|
|||||||
@@ -84,7 +84,7 @@
|
|||||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||||
<Material
|
<Material
|
||||||
color={view != 'card' ? 'none' : 'distinct'}
|
color={view != 'card' ? 'none' : 'distinct'}
|
||||||
class="relative max-w-full min-w-0 w-full group cursor-pointer
|
class="post relative max-w-full min-w-0 w-full group cursor-pointer
|
||||||
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
|
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
|
||||||
? 'py-4 list-type'
|
? 'py-4 list-type'
|
||||||
: view == 'list'
|
: view == 'list'
|
||||||
@@ -95,6 +95,7 @@
|
|||||||
on:click={(e) => {
|
on:click={(e) => {
|
||||||
onClick(e)
|
onClick(e)
|
||||||
}}
|
}}
|
||||||
|
style={$$props.style ?? ''}
|
||||||
>
|
>
|
||||||
<PostMeta
|
<PostMeta
|
||||||
community={post.community}
|
community={post.community}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Link, { parseURL } from '$lib/components/input/Link.svelte'
|
import Link, { parseURL } from '$lib/components/input/Link.svelte'
|
||||||
import { Material } from 'mono-svelte'
|
import { Button, Material } from 'mono-svelte'
|
||||||
import { Icon, Link as LinkIcon } from 'svelte-hero-icons'
|
import { Icon, Link as LinkIcon } from 'svelte-hero-icons'
|
||||||
import { optimizeImageURL } from './helpers'
|
import { optimizeImageURL } from './helpers'
|
||||||
|
|
||||||
@@ -64,12 +64,15 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</Material>
|
</Material>
|
||||||
{:else}
|
{:else}
|
||||||
<Link
|
<Button
|
||||||
href={url}
|
href={url}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
class="text-slate-700 dark:text-zinc-300 inline-flex items-center gap-1 text-sm"
|
class="text-slate-700 dark:text-zinc-300 inline-flex items-center gap-1 text-xs overflow-hidden w-max max-w-full"
|
||||||
|
size="sm"
|
||||||
|
color="ghost"
|
||||||
|
rounding="pill"
|
||||||
>
|
>
|
||||||
<Icon src={LinkIcon} size="14" mini slot="icon" class="flex-shrink-0" />
|
<Icon src={LinkIcon} size="14" mini slot="prefix" class="flex-shrink-0" />
|
||||||
{#if richURL}
|
{#if richURL}
|
||||||
<div class="flex max-w-full overflow-hidden">
|
<div class="flex max-w-full overflow-hidden">
|
||||||
{richURL.hostname}
|
{richURL.hostname}
|
||||||
@@ -80,7 +83,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
{url}
|
{url}
|
||||||
{/if}
|
{/if}
|
||||||
</Link>
|
</Button>
|
||||||
{#if thumbnail_url && !compact}
|
{#if thumbnail_url && !compact}
|
||||||
<a href={url} target="_blank">
|
<a href={url} target="_blank">
|
||||||
<img
|
<img
|
||||||
|
|||||||
@@ -253,6 +253,7 @@
|
|||||||
class:text-slate-600={$userSettings.markReadPosts && read}
|
class:text-slate-600={$userSettings.markReadPosts && read}
|
||||||
class:dark:text-zinc-400={$userSettings.markReadPosts && read}
|
class:dark:text-zinc-400={$userSettings.markReadPosts && read}
|
||||||
style="grid-area: title;"
|
style="grid-area: title;"
|
||||||
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
<Markdown source={title} inline noStyle class="leading-[1.3]"></Markdown>
|
<Markdown source={title} inline noStyle class="leading-[1.3]"></Markdown>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
+12
-9
@@ -7,6 +7,11 @@
|
|||||||
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
|
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
|
||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import { fly, slide } from 'svelte/transition'
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
import { browser } from '$app/environment'
|
||||||
|
import { afterUpdate, onMount, tick, type SvelteComponent } from 'svelte'
|
||||||
|
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||||
|
import { afterNavigate, beforeNavigate } from '$app/navigation'
|
||||||
|
import { _posts } from '../../../../../routes/+page.svelte'
|
||||||
|
|
||||||
type PostViewWithCrossposts = PostView & {
|
type PostViewWithCrossposts = PostView & {
|
||||||
withCrossposts: true
|
withCrossposts: true
|
||||||
@@ -98,16 +103,16 @@
|
|||||||
</Placeholder>
|
</Placeholder>
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
{#each combinedPosts as post, index (post.post.id)}
|
{#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
|
||||||
in:fly|global={{
|
in:fly|global={{
|
||||||
y: -8,
|
y: -8,
|
||||||
duration: index < 4 ? 500 : 0,
|
duration: 500,
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
delay: index < 4 ? index * 100 : 0,
|
delay: 100 + index * 20,
|
||||||
}}
|
}}
|
||||||
class="relative"
|
class="relative post-container"
|
||||||
>
|
>
|
||||||
<Post
|
<Post
|
||||||
hideCommunity={community}
|
hideCommunity={community}
|
||||||
@@ -116,12 +121,9 @@
|
|||||||
? 'compact'
|
? 'compact'
|
||||||
: $userSettings.view}
|
: $userSettings.view}
|
||||||
{post}
|
{post}
|
||||||
class="transition-all duration-250 {post.withCrossposts &&
|
class="transition-all duration-250"
|
||||||
viewPost != post.post.id
|
|
||||||
? ''
|
|
||||||
: ''}"
|
|
||||||
on:hide={() => {
|
on:hide={() => {
|
||||||
combinedPosts = combinedPosts.toSpliced(index, 1)
|
posts = posts.toSpliced(index, 1)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="badges">
|
<svelte:fragment slot="badges">
|
||||||
@@ -175,4 +177,5 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
|
<slot />
|
||||||
</ul>
|
</ul>
|
||||||
@@ -0,0 +1,222 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
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 { Badge, Button } from 'mono-svelte'
|
||||||
|
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
|
||||||
|
import { expoOut } from 'svelte/easing'
|
||||||
|
import { fly, slide } from 'svelte/transition'
|
||||||
|
import { browser } from '$app/environment'
|
||||||
|
import { afterUpdate, onMount, tick, type SvelteComponent } from 'svelte'
|
||||||
|
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||||
|
import { afterNavigate, beforeNavigate } from '$app/navigation'
|
||||||
|
import { _posts } from '../../../../../routes/+page.svelte'
|
||||||
|
|
||||||
|
type PostViewWithCrossposts = PostView & {
|
||||||
|
withCrossposts: true
|
||||||
|
crossposts: PostView[]
|
||||||
|
}
|
||||||
|
type PostViewWithoutCrossposts = PostView & { withCrossposts?: false }
|
||||||
|
|
||||||
|
export let posts: PostView[]
|
||||||
|
export let community: boolean = false
|
||||||
|
|
||||||
|
const addCrosspostProperty = (
|
||||||
|
post: PostView,
|
||||||
|
crossposts: PostView[]
|
||||||
|
): PostViewWithCrossposts => ({
|
||||||
|
...post,
|
||||||
|
crossposts: crossposts,
|
||||||
|
withCrossposts: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
const combineCrossposts = (
|
||||||
|
posts: PostView[]
|
||||||
|
): (PostViewWithCrossposts | PostViewWithoutCrossposts)[] => {
|
||||||
|
const urlMap = new Map<
|
||||||
|
string,
|
||||||
|
PostViewWithCrossposts | PostViewWithoutCrossposts
|
||||||
|
>()
|
||||||
|
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
|
||||||
|
const seenUrls = new Set<string>()
|
||||||
|
|
||||||
|
posts?.forEach((post) => {
|
||||||
|
if (
|
||||||
|
!post ||
|
||||||
|
($userSettings.hidePosts.deleted && post.post.deleted) ||
|
||||||
|
($userSettings.hidePosts.removed && post.post.removed)
|
||||||
|
)
|
||||||
|
return
|
||||||
|
if (!post?.post?.url) {
|
||||||
|
results.push(post)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
let existing = urlMap.get(post.post.url)
|
||||||
|
if (existing) {
|
||||||
|
existing.withCrossposts = true
|
||||||
|
if (existing.withCrossposts) {
|
||||||
|
existing.crossposts = [...(existing.crossposts || []), post]
|
||||||
|
}
|
||||||
|
|
||||||
|
urlMap.set(post.post.url, existing)
|
||||||
|
} else {
|
||||||
|
urlMap.set(post.post.url, post)
|
||||||
|
results.push(post)
|
||||||
|
}
|
||||||
|
seenUrls.add(post.post.url)
|
||||||
|
})
|
||||||
|
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
// $: combinedPosts = combineCrossposts(posts)
|
||||||
|
|
||||||
|
let viewPost: number = -1
|
||||||
|
|
||||||
|
const virtualizer = createWindowVirtualizer({
|
||||||
|
count: posts.length,
|
||||||
|
estimateSize: () => 150,
|
||||||
|
})
|
||||||
|
|
||||||
|
$: if (posts.length)
|
||||||
|
$virtualizer.setOptions({
|
||||||
|
count: posts.length,
|
||||||
|
})
|
||||||
|
|
||||||
|
let virtualItemEls: HTMLElement[] = []
|
||||||
|
|
||||||
|
$: items = $virtualizer.getVirtualItems()
|
||||||
|
$: {
|
||||||
|
if (virtualItemEls.length)
|
||||||
|
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
||||||
|
}
|
||||||
|
|
||||||
|
afterNavigate(() => {
|
||||||
|
$virtualizer.scrollToIndex($_posts?.lastSeen)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<ul
|
||||||
|
class="flex flex-col list-none {$userSettings.view == 'card'
|
||||||
|
? 'gap-3 md:gap-4'
|
||||||
|
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
|
||||||
|
style={$userSettings.leftAlign
|
||||||
|
? `--template-areas:
|
||||||
|
'media meta'
|
||||||
|
'media title'
|
||||||
|
'media body'
|
||||||
|
'embed embed'
|
||||||
|
'actions actions'; --template-columns: auto 1fr;`
|
||||||
|
: ``}
|
||||||
|
>
|
||||||
|
{#if posts?.length == 0}
|
||||||
|
<div class="h-full grid place-items-center">
|
||||||
|
<Placeholder
|
||||||
|
icon={ArchiveBox}
|
||||||
|
title="No posts"
|
||||||
|
description="There are no posts that match this filter."
|
||||||
|
>
|
||||||
|
<Button href="/communities">
|
||||||
|
<Icon src={Plus} size="16" mini slot="prefix" />
|
||||||
|
<span>Follow some communities</span>
|
||||||
|
</Button>
|
||||||
|
</Placeholder>
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<!-- {#each combinedPosts as post, index} -->
|
||||||
|
<!-- {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} -->
|
||||||
|
<div
|
||||||
|
style="position:relative; height: {browser
|
||||||
|
? `${$virtualizer.getTotalSize()}px`
|
||||||
|
: '100%'}; width: 100%;"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items[0]
|
||||||
|
? items[0].start
|
||||||
|
: 0}px);"
|
||||||
|
class="divide-y divide-slate-200 dark:divide-zinc-800"
|
||||||
|
id="feed"
|
||||||
|
>
|
||||||
|
{#each items as row, index (row.index)}
|
||||||
|
<li
|
||||||
|
in:fly|global={{
|
||||||
|
y: -8,
|
||||||
|
duration: 500,
|
||||||
|
opacity: 0,
|
||||||
|
delay: 100 + index * 20,
|
||||||
|
}}
|
||||||
|
bind:this={virtualItemEls[index]}
|
||||||
|
data-index={row.index}
|
||||||
|
class="relative post-container"
|
||||||
|
>
|
||||||
|
<Post
|
||||||
|
hideCommunity={community}
|
||||||
|
view={(posts[row.index].post.featured_community ||
|
||||||
|
posts[row.index].post.featured_local) &&
|
||||||
|
$userSettings.posts.compactFeatured
|
||||||
|
? 'compact'
|
||||||
|
: $userSettings.view}
|
||||||
|
post={posts[row.index]}
|
||||||
|
class="transition-all duration-250"
|
||||||
|
on:hide={() => {
|
||||||
|
posts = posts.toSpliced(row.index, 1)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<svelte:fragment slot="badges">
|
||||||
|
<!-- {#if posts[index].withCrossposts}
|
||||||
|
<button
|
||||||
|
on:click={() => {
|
||||||
|
if (viewPost == posts[index].post.id) viewPost = -1
|
||||||
|
else viewPost = posts[index].post.id
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Badge
|
||||||
|
class="z-10 backdrop-blur-xl hover:brightness-110 cursor-pointer transition-all"
|
||||||
|
color="gray-subtle"
|
||||||
|
>
|
||||||
|
{#if viewPost == posts[index].post.id}
|
||||||
|
<Icon mini src={Minus} size="14" />
|
||||||
|
{:else}
|
||||||
|
<Icon mini src={Plus} size="14" />
|
||||||
|
{/if}
|
||||||
|
{posts[index].crossposts.length} crosspost{posts[index]
|
||||||
|
.crossposts.length == 1
|
||||||
|
? ''
|
||||||
|
: 's'}
|
||||||
|
</Badge>
|
||||||
|
</button>{/if} -->
|
||||||
|
</svelte:fragment>
|
||||||
|
</Post>
|
||||||
|
<!-- {#if posts[index].withCrossposts && viewPost == posts[index].post.id}
|
||||||
|
<div
|
||||||
|
transition:slide|global={{
|
||||||
|
axis: 'y',
|
||||||
|
duration: 500,
|
||||||
|
easing: expoOut,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="text-sm flex flex-row gap-2 items-center"
|
||||||
|
class:my-4={$userSettings.view == 'card'}
|
||||||
|
>
|
||||||
|
Crossposts <hr class="w-full dark:border-zinc-800" />
|
||||||
|
{posts[index].crossposts.length}
|
||||||
|
</span>
|
||||||
|
{#each posts[index].crossposts as crosspost, index}
|
||||||
|
<div class="w-full transition-all mb-4">
|
||||||
|
<Post post={crosspost} view={$userSettings.view} />
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{/if} -->
|
||||||
|
</li>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- {/if} -->
|
||||||
|
<!-- {/each} -->
|
||||||
|
{/if}
|
||||||
|
<slot />
|
||||||
|
</ul>
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
class="items-center flex flex-row gap-1 hover:underline max-w-full min-w-0 {$$props.class ??
|
class="items-center flex flex-row gap-1 hover:underline max-w-full min-w-0 {$$props.class ??
|
||||||
''}"
|
''}"
|
||||||
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
|
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
|
||||||
|
data-sveltekit-preload-data="tap"
|
||||||
>
|
>
|
||||||
{#if avatar}
|
{#if avatar}
|
||||||
<Avatar
|
<Avatar
|
||||||
|
|||||||
@@ -473,7 +473,8 @@
|
|||||||
},
|
},
|
||||||
"message": {
|
"message": {
|
||||||
"success": "Success",
|
"success": "Success",
|
||||||
"error": "Error"
|
"error": "Error",
|
||||||
|
"retry": "Retry"
|
||||||
},
|
},
|
||||||
"toast": {
|
"toast": {
|
||||||
"noComments": "The API returned no comments.",
|
"noComments": "The API returned no comments.",
|
||||||
@@ -598,6 +599,10 @@
|
|||||||
"title": "Default sort",
|
"title": "Default sort",
|
||||||
"description": "The default sorting to use in feeds."
|
"description": "The default sorting to use in feeds."
|
||||||
},
|
},
|
||||||
|
"infiniteScroll": {
|
||||||
|
"title": "Infinite scroll",
|
||||||
|
"description": "New posts are added as you scroll down, without having to click 'next'."
|
||||||
|
},
|
||||||
"postsInNewTab": {
|
"postsInNewTab": {
|
||||||
"title": "Open posts in new tab",
|
"title": "Open posts in new tab",
|
||||||
"description": "Open posts in a separate tab instead of the current."
|
"description": "Open posts in a separate tab instead of the current."
|
||||||
|
|||||||
@@ -88,6 +88,7 @@ interface Settings {
|
|||||||
compactFeatured: boolean
|
compactFeatured: boolean
|
||||||
showHidden: boolean
|
showHidden: boolean
|
||||||
}
|
}
|
||||||
|
infiniteScroll: boolean
|
||||||
language: string | null
|
language: string | null
|
||||||
useRtl: boolean
|
useRtl: boolean
|
||||||
translator: string | undefined
|
translator: string | undefined
|
||||||
@@ -160,6 +161,7 @@ export const defaultSettings: Settings = {
|
|||||||
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
|
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
|
||||||
showHidden: false,
|
showHidden: false,
|
||||||
},
|
},
|
||||||
|
infiniteScroll: true,
|
||||||
language: env.PUBLIC_LANGUAGE ?? null,
|
language: env.PUBLIC_LANGUAGE ?? null,
|
||||||
useRtl: false,
|
useRtl: false,
|
||||||
translator: env.PUBLIC_TRANSLATOR ?? undefined,
|
translator: env.PUBLIC_TRANSLATOR ?? undefined,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
|
import { t } from '$lib/translations'
|
||||||
import { Button } from 'mono-svelte'
|
import { Button } from 'mono-svelte'
|
||||||
import { Icon, XMark } from 'svelte-hero-icons'
|
import { Icon, XMark } from 'svelte-hero-icons'
|
||||||
</script>
|
</script>
|
||||||
@@ -18,6 +19,6 @@
|
|||||||
{$page.error?.message}
|
{$page.error?.message}
|
||||||
</code>
|
</code>
|
||||||
<Button size="sm" class="w-max" on:click={() => goto($page.url)}>
|
<Button size="sm" class="w-max" on:click={() => goto($page.url)}>
|
||||||
Retry
|
{$t('message.retry')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
+178
-15
@@ -1,26 +1,143 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
export interface CachedPosts {
|
||||||
|
data: GetPostsResponse
|
||||||
|
params: URLSearchParams
|
||||||
|
lastSeen: number
|
||||||
|
instance: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const _posts = writable<CachedPosts>(undefined)
|
||||||
|
|
||||||
|
export const shouldReload = (
|
||||||
|
cache: CachedPosts | undefined,
|
||||||
|
params: string,
|
||||||
|
instance: string
|
||||||
|
): boolean =>
|
||||||
|
cache?.instance != instance || cache?.params.toString() != params
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import StickyCard from '$lib/components/ui/StickyCard.svelte'
|
|
||||||
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
|
|
||||||
import Pageination from '$lib/components/ui/Pageination.svelte'
|
import Pageination from '$lib/components/ui/Pageination.svelte'
|
||||||
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 PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
|
import {
|
||||||
import { Button, Modal, Select, Spinner } from 'mono-svelte'
|
ChartBar,
|
||||||
import { ChartBar, GlobeAmericas, Icon, ServerStack } from 'svelte-hero-icons'
|
ExclamationCircle,
|
||||||
import { profile } from '$lib/auth.js'
|
ExclamationTriangle,
|
||||||
import { site } from '$lib/lemmy.js'
|
GlobeAmericas,
|
||||||
import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
|
Icon,
|
||||||
import { feature } from '$lib/version.js'
|
ServerStack,
|
||||||
import { userSettings } from '$lib/settings.js'
|
} from 'svelte-hero-icons'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import { getClient, 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 { enhance } from '$app/forms'
|
import InfiniteScroll from 'svelte-infinite-scroll'
|
||||||
|
import { Button, Material, Spinner } from 'mono-svelte'
|
||||||
|
import { get, writable } from 'svelte/store'
|
||||||
|
import type { GetPostsResponse } from 'lemmy-js-client'
|
||||||
|
import { userSettings } from '$lib/settings.js'
|
||||||
|
import { afterNavigate } from '$app/navigation'
|
||||||
|
import { browser } from '$app/environment'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
import { instance } from '$lib/instance.js'
|
||||||
|
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
|
||||||
|
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
|
const limit = 20
|
||||||
|
let hasMore = data.posts.posts.length != 0
|
||||||
|
let error: any = undefined
|
||||||
|
let loading = false
|
||||||
|
|
||||||
|
async function loadMore() {
|
||||||
|
if (!hasMore || loading) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
loading = true
|
||||||
|
const newPosts = await getClient()
|
||||||
|
.getPosts({
|
||||||
|
limit: limit,
|
||||||
|
page: data.page,
|
||||||
|
sort: data.sort,
|
||||||
|
type_: data.listingType,
|
||||||
|
page_cursor: data.cursor.next,
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
throw new Error(e)
|
||||||
|
})
|
||||||
|
|
||||||
|
error = null
|
||||||
|
|
||||||
|
hasMore = newPosts.posts.length != 0
|
||||||
|
|
||||||
|
data.cursor.next = newPosts.next_page
|
||||||
|
data.posts.posts = [...data.posts.posts, ...newPosts.posts]
|
||||||
|
|
||||||
|
_posts.update((ps) => ({
|
||||||
|
data: data.posts,
|
||||||
|
params: ps.params,
|
||||||
|
lastSeen: ps.lastSeen,
|
||||||
|
instance: ps.instance,
|
||||||
|
}))
|
||||||
|
|
||||||
|
loading = false
|
||||||
|
} catch (e) {
|
||||||
|
error = e
|
||||||
|
loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const callback: IntersectionObserverCallback = (entries, observer) => {
|
||||||
|
entries.forEach((entry) => {
|
||||||
|
if (!entry.isIntersecting) return
|
||||||
|
|
||||||
|
const element = entry.target as HTMLElement
|
||||||
|
const id = element.getAttribute('data-index')
|
||||||
|
|
||||||
|
if (!id) return
|
||||||
|
|
||||||
|
$_posts.lastSeen = Number(id)
|
||||||
|
observer.unobserve(element)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const observer = new IntersectionObserver(callback, {
|
||||||
|
root: null,
|
||||||
|
rootMargin: '0px',
|
||||||
|
threshold: 0.25,
|
||||||
|
})
|
||||||
|
|
||||||
|
const elements = document.querySelectorAll('.post-container')
|
||||||
|
elements.forEach((el) => observer.observe(el))
|
||||||
|
|
||||||
|
const postContainer = document.querySelector('#feed')
|
||||||
|
if (postContainer) {
|
||||||
|
const mutationObserver = new MutationObserver((mutations) => {
|
||||||
|
mutations.forEach((mutation) => {
|
||||||
|
if (mutation.type === 'childList') {
|
||||||
|
mutation.addedNodes.forEach((node) => {
|
||||||
|
if (
|
||||||
|
node instanceof HTMLElement &&
|
||||||
|
node.classList.contains('post-container')
|
||||||
|
) {
|
||||||
|
observer.observe(node)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
mutationObserver.observe(postContainer, {
|
||||||
|
childList: true,
|
||||||
|
subtree: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
|
||||||
@@ -34,8 +151,48 @@
|
|||||||
<ViewSelect />
|
<ViewSelect />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<PostFeed posts={data.posts.posts} />
|
|
||||||
<div class="mt-auto">
|
<svelte:component
|
||||||
|
this={browser ? VirtualFeed : PostFeed}
|
||||||
|
posts={data.posts.posts}
|
||||||
|
>
|
||||||
|
{#if $userSettings.infiniteScroll && browser}
|
||||||
|
{#if error}
|
||||||
|
<div
|
||||||
|
class="flex flex-col justify-center items-center
|
||||||
|
rounded-xl gap-2 py-8 mt-6
|
||||||
|
border !border-b !border-red-500 bg-red-500/5 px-4"
|
||||||
|
>
|
||||||
|
<div class="bg-red-500/30 rounded-full p-3 text-red-500">
|
||||||
|
<Icon src={ExclamationTriangle} size="24" solid></Icon>
|
||||||
|
</div>
|
||||||
|
<pre class="py-0.5">{error}</pre>
|
||||||
|
<Button
|
||||||
|
color="primary"
|
||||||
|
{loading}
|
||||||
|
disabled={loading}
|
||||||
|
on:click={loadMore}
|
||||||
|
>
|
||||||
|
{$t('message.retry')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
{:else if hasMore}
|
||||||
|
<div class="w-full flex flex-col skeleton gap-2 animate-pulse pt-6">
|
||||||
|
<div class="w-96 h-8"></div>
|
||||||
|
<div class="w-full h-48"></div>
|
||||||
|
<div class="!bg-transparent h-8 flex justify-between">
|
||||||
|
<div class="w-48 h-8"></div>
|
||||||
|
<div class="w-24 h-8"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
<InfiniteScroll window threshold={1000} on:loadMore={loadMore} />
|
||||||
|
{/if}
|
||||||
|
</svelte:component>
|
||||||
|
<svelte:element
|
||||||
|
this={$userSettings.infiniteScroll ? 'noscript' : 'div'}
|
||||||
|
class="mt-auto"
|
||||||
|
>
|
||||||
<Pageination
|
<Pageination
|
||||||
page={data.page}
|
page={data.page}
|
||||||
cursor={{ next: data.cursor.next, back: data.cursor.back }}
|
cursor={{ next: data.cursor.next, back: data.cursor.back }}
|
||||||
@@ -52,5 +209,11 @@
|
|||||||
})}
|
})}
|
||||||
</span>
|
</span>
|
||||||
</Pageination>
|
</Pageination>
|
||||||
</div>
|
</svelte:element>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<style lang="postcss">
|
||||||
|
.skeleton * {
|
||||||
|
@apply bg-slate-100 dark:bg-zinc-800 rounded-md;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
+28
-12
@@ -1,10 +1,11 @@
|
|||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient } from '$lib/lemmy.js'
|
||||||
import { userSettings } from '$lib/settings.js'
|
import { userSettings } from '$lib/settings.js'
|
||||||
import type { ListingType, SortType } from 'lemmy-js-client'
|
import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client'
|
||||||
import { get } from 'svelte/store'
|
import { get, writable } from 'svelte/store'
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from '@sveltejs/kit'
|
||||||
import { profile } from '$lib/auth.js'
|
import { _posts, shouldReload, type CachedPosts } from './+page.svelte'
|
||||||
import { feature } from '$lib/version.js'
|
import { browser } from '$app/environment'
|
||||||
|
import { instance } from '$lib/instance'
|
||||||
|
|
||||||
export async function load({ url, fetch }) {
|
export async function load({ url, fetch }) {
|
||||||
const cursor = url.searchParams.get('cursor') as string | undefined
|
const cursor = url.searchParams.get('cursor') as string | undefined
|
||||||
@@ -18,14 +19,29 @@ export async function load({ url, fetch }) {
|
|||||||
const listingType: ListingType =
|
const listingType: ListingType =
|
||||||
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
|
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
|
||||||
|
|
||||||
const posts = await getClient(undefined, fetch).getPosts({
|
const cached: CachedPosts | undefined = get(_posts)
|
||||||
limit: 20,
|
|
||||||
page: page,
|
const posts = shouldReload(cached, url.searchParams.toString(), get(instance))
|
||||||
sort: sort,
|
? await getClient(undefined, fetch).getPosts({
|
||||||
type_: listingType,
|
limit: 20,
|
||||||
page_cursor: cursor,
|
page: page,
|
||||||
show_hidden: settings.posts.showHidden,
|
sort: sort,
|
||||||
})
|
type_: listingType,
|
||||||
|
page_cursor: cursor,
|
||||||
|
show_hidden: settings.posts.showHidden,
|
||||||
|
})
|
||||||
|
: cached.data
|
||||||
|
|
||||||
|
if (
|
||||||
|
shouldReload(cached, url.searchParams.toString(), get(instance)) &&
|
||||||
|
browser
|
||||||
|
)
|
||||||
|
_posts.set({
|
||||||
|
data: posts,
|
||||||
|
params: url.searchParams,
|
||||||
|
lastSeen: 0,
|
||||||
|
instance: get(instance),
|
||||||
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
import { fullCommunityName, searchParam } from '$lib/util.js'
|
import { fullCommunityName, searchParam } from '$lib/util.js'
|
||||||
import { onDestroy, onMount } from 'svelte'
|
import { onDestroy, onMount } from 'svelte'
|
||||||
import { setSessionStorage } from '$lib/session.js'
|
import { setSessionStorage } from '$lib/session.js'
|
||||||
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
|
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
|
||||||
import { Button, Modal, toast } from 'mono-svelte'
|
import { Button, Modal, toast } from 'mono-svelte'
|
||||||
import { afterNavigate } from '$app/navigation'
|
import { afterNavigate } from '$app/navigation'
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
import Expandable from '$lib/components/ui/Expandable.svelte'
|
import Expandable from '$lib/components/ui/Expandable.svelte'
|
||||||
import { Popover } from 'mono-svelte'
|
import { Popover } from 'mono-svelte'
|
||||||
import { t } from '$lib/translations.js'
|
import { t } from '$lib/translations.js'
|
||||||
|
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -112,7 +113,24 @@
|
|||||||
$: remoteView =
|
$: remoteView =
|
||||||
$page.params.instance?.toLowerCase() != $instance.toLowerCase()
|
$page.params.instance?.toLowerCase() != $instance.toLowerCase()
|
||||||
|
|
||||||
const test = 'wow'
|
const virtualizer = createWindowVirtualizer({
|
||||||
|
count: 0,
|
||||||
|
estimateSize: () => 50,
|
||||||
|
})
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
const comments = await data.comments
|
||||||
|
|
||||||
|
$virtualizer.setOptions({ count: comments.comments.length })
|
||||||
|
})
|
||||||
|
|
||||||
|
let virtualItemEls: HTMLElement[] = []
|
||||||
|
|
||||||
|
$: items = $virtualizer.getVirtualItems()
|
||||||
|
$: {
|
||||||
|
if (virtualItemEls.length)
|
||||||
|
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|||||||
@@ -1,56 +1,57 @@
|
|||||||
import { browser } from '$app/environment'
|
import { browser } from "$app/environment";
|
||||||
import { env } from '$env/dynamic/public'
|
import { env } from "$env/dynamic/public";
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from "$lib/auth.js";
|
||||||
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
|
import CommunityCard from "$lib/components/lemmy/community/CommunityCard.svelte";
|
||||||
import { getClient } from '$lib/lemmy.js'
|
import { getClient } from "$lib/lemmy.js";
|
||||||
import { awaitIfServer } from '$lib/promise.js'
|
import { awaitIfServer } from "$lib/promise.js";
|
||||||
import { SSR_ENABLED, userSettings } from '$lib/settings.js'
|
import { SSR_ENABLED, userSettings } from "$lib/settings.js";
|
||||||
import { error } from '@sveltejs/kit'
|
import { error } from "@sveltejs/kit";
|
||||||
import { get } from 'svelte/store'
|
import type { GetComments } from "lemmy-js-client";
|
||||||
|
import { get } from "svelte/store";
|
||||||
|
|
||||||
export async function load({ params, url, fetch }) {
|
export async function load({ params, url, fetch }) {
|
||||||
const thread = url.searchParams.get('thread')
|
const thread = url.searchParams.get("thread");
|
||||||
let parentId: number | undefined
|
let parentId: number | undefined;
|
||||||
let showContext: string | undefined = undefined
|
let showContext: string | undefined = undefined;
|
||||||
|
|
||||||
let max_depth = 3
|
let max_depth = 3;
|
||||||
|
|
||||||
if (thread) {
|
if (thread) {
|
||||||
const split = thread.split('.')
|
const split = thread.split(".");
|
||||||
if (split.length >= 9) {
|
if (split.length >= 9) {
|
||||||
const sliced = split.slice(0, split.length - 4)
|
const sliced = split.slice(0, split.length - 4);
|
||||||
showContext = sliced[sliced.length - 1]
|
showContext = sliced[sliced.length - 1];
|
||||||
parentId = Number(split[split.length - 5])
|
parentId = Number(split[split.length - 5]);
|
||||||
} else {
|
} else {
|
||||||
parentId = Number(split[1])
|
parentId = Number(split[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Number.isInteger(parentId)) {
|
if (!Number.isInteger(parentId)) {
|
||||||
parentId = undefined
|
parentId = undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
max_depth = 10
|
max_depth = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sort = get(userSettings)?.defaultSort?.comments ?? 'Hot'
|
const sort = get(userSettings)?.defaultSort?.comments ?? "Hot";
|
||||||
|
|
||||||
const commentParams: any = {
|
const commentParams: GetComments = {
|
||||||
post_id: Number(params.id),
|
post_id: Number(params.id),
|
||||||
type_: 'All',
|
type_: "All",
|
||||||
limit: 50,
|
limit: 50,
|
||||||
page: 1,
|
page: 1,
|
||||||
max_depth: max_depth,
|
max_depth: max_depth,
|
||||||
saved_only: false,
|
saved_only: false,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
parent_id: parentId,
|
parent_id: parentId,
|
||||||
}
|
};
|
||||||
|
|
||||||
|
const comments = getClient(params.instance, fetch).getComments(commentParams);
|
||||||
const post = await getClient(params.instance.toLowerCase(), fetch).getPost({
|
const post = await getClient(params.instance.toLowerCase(), fetch).getPost({
|
||||||
id: Number(params.id),
|
id: Number(params.id),
|
||||||
})
|
});
|
||||||
const comments = getClient(params.instance, fetch).getComments(commentParams)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
thread: {
|
thread: {
|
||||||
@@ -60,13 +61,13 @@ export async function load({ params, url, fetch }) {
|
|||||||
post: post,
|
post: post,
|
||||||
commentSort: sort,
|
commentSort: sort,
|
||||||
comments: (await awaitIfServer(comments)).data,
|
comments: (await awaitIfServer(comments)).data,
|
||||||
// slots: {
|
slots: {
|
||||||
// sidebar: {
|
sidebar: {
|
||||||
// component: CommunityCard,
|
component: CommunityCard,
|
||||||
// props: {
|
props: {
|
||||||
// community_view: post.community_view,
|
community_view: post.community_view,
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
// },
|
},
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
@@ -222,6 +222,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Setting>
|
</Setting>
|
||||||
|
<ToggleSetting
|
||||||
|
beta
|
||||||
|
bind:checked={$userSettings.infiniteScroll}
|
||||||
|
title={$t('settings.app.infiniteScroll.title')}
|
||||||
|
description={$t('settings.app.infiniteScroll.description')}
|
||||||
|
/>
|
||||||
<ToggleSetting
|
<ToggleSetting
|
||||||
bind:checked={$userSettings.openLinksInNewTab}
|
bind:checked={$userSettings.openLinksInNewTab}
|
||||||
title={$t('settings.app.postsInNewTab.title')}
|
title={$t('settings.app.postsInNewTab.title')}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
export let title: string
|
export let title: string
|
||||||
export let description: string | undefined = undefined
|
export let description: string | undefined = undefined
|
||||||
export let checked: boolean = false
|
export let checked: boolean = false
|
||||||
|
export let beta = false
|
||||||
|
|
||||||
export let supportedPlatforms = {
|
export let supportedPlatforms = {
|
||||||
desktop: true,
|
desktop: true,
|
||||||
@@ -20,25 +21,30 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col w-full justify-between gap-2 max-w-full">
|
<div class="flex flex-col w-full justify-between gap-2 max-w-full">
|
||||||
{#if Object.values(supportedPlatforms).some((v) => v == false)}
|
{#if Object.values(supportedPlatforms).some((v) => v == false) || beta}
|
||||||
<div class="flex items-center gap-2 flex-wrap">
|
<div class="flex items-center gap-2 flex-wrap">
|
||||||
{#if supportedPlatforms.desktop}
|
{#if beta}
|
||||||
<Badge>
|
<Badge>Beta</Badge>
|
||||||
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
|
|
||||||
{$t('settings.desktop')}
|
|
||||||
</Badge>
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if supportedPlatforms.tablet}
|
{#if Object.values(supportedPlatforms).some((v) => v == false)}
|
||||||
<Badge>
|
{#if supportedPlatforms.desktop}
|
||||||
<Icon src={DeviceTablet} micro size="14" slot="icon" />
|
<Badge>
|
||||||
{$t('settings.tablet')}
|
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
|
||||||
</Badge>
|
{$t('settings.desktop')}
|
||||||
{/if}
|
</Badge>
|
||||||
{#if supportedPlatforms.mobile}
|
{/if}
|
||||||
<Badge>
|
{#if supportedPlatforms.tablet}
|
||||||
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
|
<Badge>
|
||||||
{$t('settings.mobile')}
|
<Icon src={DeviceTablet} micro size="14" slot="icon" />
|
||||||
</Badge>
|
{$t('settings.tablet')}
|
||||||
|
</Badge>
|
||||||
|
{/if}
|
||||||
|
{#if supportedPlatforms.mobile}
|
||||||
|
<Badge>
|
||||||
|
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
|
||||||
|
{$t('settings.mobile')}
|
||||||
|
</Badge>
|
||||||
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in new issue
Block a user