fix: ssr handoff crash
This commit is contained in:
9 files changed
+98
-113
No files matched your search
@@ -3,7 +3,7 @@ import {
|
|||||||
isAdmin,
|
isAdmin,
|
||||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||||
import { toast } from 'mono-svelte'
|
import { toast } from 'mono-svelte'
|
||||||
import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js'
|
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.svelte.js'
|
||||||
import { client, getClient } from '$lib/lemmy.svelte.js'
|
import { client, getClient } from '$lib/lemmy.svelte.js'
|
||||||
import { site } from './lemmy.svelte'
|
import { site } from './lemmy.svelte'
|
||||||
import { instanceToURL, moveItem } from '$lib/util.svelte'
|
import { instanceToURL, moveItem } from '$lib/util.svelte'
|
||||||
|
|||||||
@@ -1,44 +1,31 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy'
|
import { run } from 'svelte/legacy'
|
||||||
|
|
||||||
import Post from '$lib/components/lemmy/post/Post.svelte'
|
|
||||||
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
|
||||||
import type {
|
|
||||||
GetPostsResponse,
|
|
||||||
ListingType,
|
|
||||||
PostView,
|
|
||||||
SortType,
|
|
||||||
} from 'lemmy-js-client'
|
|
||||||
import { Badge, Button } from 'mono-svelte'
|
|
||||||
import {
|
|
||||||
ArchiveBox,
|
|
||||||
ChevronDoubleUp,
|
|
||||||
ExclamationTriangle,
|
|
||||||
Icon,
|
|
||||||
Minus,
|
|
||||||
Plus,
|
|
||||||
} from 'svelte-hero-icons'
|
|
||||||
import { expoOut } from 'svelte/easing'
|
|
||||||
import { fly, slide } from 'svelte/transition'
|
|
||||||
import { browser } from '$app/environment'
|
import { browser } from '$app/environment'
|
||||||
import { onMount, tick, type SvelteComponent } from 'svelte'
|
import { afterNavigate } from '$app/navigation'
|
||||||
import {
|
import Post from '$lib/components/lemmy/post/Post.svelte'
|
||||||
createVirtualizer,
|
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
||||||
createWindowVirtualizer,
|
import Placeholder from '$lib/components/ui/Placeholder.svelte'
|
||||||
type SvelteVirtualizer,
|
|
||||||
} from '@tanstack/svelte-virtual'
|
|
||||||
import { afterNavigate, beforeNavigate } from '$app/navigation'
|
|
||||||
import { combineCrossposts } from './crosspost.svelte'
|
|
||||||
import { client } from '$lib/lemmy.svelte'
|
import { client } from '$lib/lemmy.svelte'
|
||||||
import {
|
import {
|
||||||
postFeeds,
|
postFeeds,
|
||||||
type PostFeed,
|
type PostFeed,
|
||||||
type PostFeedID,
|
type PostFeedID,
|
||||||
} from '$lib/lemmy/postfeed'
|
} from '$lib/lemmy/postfeed'
|
||||||
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
|
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
|
||||||
|
import type { PostView } from 'lemmy-js-client'
|
||||||
|
import { Button } from 'mono-svelte'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
import {
|
||||||
|
ArchiveBox,
|
||||||
|
ChevronDoubleUp,
|
||||||
|
ExclamationTriangle,
|
||||||
|
Icon,
|
||||||
|
Plus,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
import InfiniteScroll from 'svelte-infinite-scroll'
|
import InfiniteScroll from 'svelte-infinite-scroll'
|
||||||
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
|
|
||||||
|
|
||||||
let virtualItemEls: HTMLElement[] = $state([])
|
let virtualItemEls: HTMLElement[] = $state([])
|
||||||
let virtualListEl: HTMLElement | undefined = $state(undefined)
|
let virtualListEl: HTMLElement | undefined = $state(undefined)
|
||||||
@@ -181,7 +168,7 @@
|
|||||||
if (virtualItemEls.length)
|
if (virtualItemEls.length)
|
||||||
virtualItemEls.forEach($virtualizer.measureElement)
|
virtualItemEls.forEach($virtualizer.measureElement)
|
||||||
})
|
})
|
||||||
run(() => {
|
$effect(() => {
|
||||||
if (posts.length && virtualListEl)
|
if (posts.length && virtualListEl)
|
||||||
$virtualizer.setOptions({
|
$virtualizer.setOptions({
|
||||||
scrollMargin: virtualListEl?.offsetTop,
|
scrollMargin: virtualListEl?.offsetTop,
|
||||||
@@ -193,65 +180,66 @@
|
|||||||
<ul
|
<ul
|
||||||
class="flex flex-col list-none divide-y divide-slate-200 dark:divide-zinc-800"
|
class="flex flex-col list-none divide-y divide-slate-200 dark:divide-zinc-800"
|
||||||
>
|
>
|
||||||
{#if posts?.length == 0}
|
{#key posts}
|
||||||
<div class="h-full grid place-items-center">
|
{#if posts?.length == 0}
|
||||||
<Placeholder
|
<div class="h-full grid place-items-center">
|
||||||
icon={ArchiveBox}
|
<Placeholder
|
||||||
title="No posts"
|
icon={ArchiveBox}
|
||||||
description="There are no posts that match this filter."
|
title="No posts"
|
||||||
>
|
description="There are no posts that match this filter."
|
||||||
<Button href="/communities">
|
>
|
||||||
{#snippet prefix()}
|
<Button href="/communities">
|
||||||
<Icon src={Plus} size="16" mini />
|
{#snippet prefix()}
|
||||||
{/snippet}
|
<Icon src={Plus} size="16" mini />
|
||||||
<span>Follow some communities</span>
|
{/snippet}
|
||||||
</Button>
|
<span>Follow some communities</span>
|
||||||
</Placeholder>
|
</Button>
|
||||||
</div>
|
</Placeholder>
|
||||||
{:else}
|
|
||||||
<div
|
|
||||||
style="position:relative; height: {browser
|
|
||||||
? `${$virtualizer.getTotalSize()}px`
|
|
||||||
: '100%'}; width: 100%;"
|
|
||||||
bind:this={virtualListEl}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items?.[0]
|
|
||||||
? items?.[0]?.start - $virtualizer.options.scrollMargin
|
|
||||||
: 0}px);"
|
|
||||||
class="divide-y divide-slate-200 dark:divide-zinc-900"
|
|
||||||
id="feed"
|
|
||||||
>
|
|
||||||
{#each items as row, index (posts[row.index]?.post.id)}
|
|
||||||
{#if posts[row.index]}
|
|
||||||
{@const post = posts?.[row.index]}
|
|
||||||
<li
|
|
||||||
bind:this={virtualItemEls[index]}
|
|
||||||
data-index={row.index}
|
|
||||||
style={row.index < 7 ? `--anim-delay: ${index * 100}ms` : ''}
|
|
||||||
class="relative post-container {row.index < 7
|
|
||||||
? 'pop-in opacity-0'
|
|
||||||
: ''} -mx-4 sm:-mx-6 px-4 sm:px-6"
|
|
||||||
>
|
|
||||||
<Post
|
|
||||||
bind:post={posts[row.index]}
|
|
||||||
hideCommunity={community}
|
|
||||||
view={(posts[row.index]?.post.featured_community ||
|
|
||||||
posts[row.index]?.post.featured_local) &&
|
|
||||||
settings.posts.compactFeatured
|
|
||||||
? 'compact'
|
|
||||||
: settings.view}
|
|
||||||
class="transition-all duration-250"
|
|
||||||
onhide={() => {
|
|
||||||
posts = posts.toSpliced(row.index, 1)
|
|
||||||
}}
|
|
||||||
></Post>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{:else}
|
||||||
{/if}
|
<div
|
||||||
|
style="position:relative; height: {browser
|
||||||
|
? `${$virtualizer?.getTotalSize()}px`
|
||||||
|
: '100%'}; width: 100%;"
|
||||||
|
bind:this={virtualListEl}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items?.[0]
|
||||||
|
? items?.[0]?.start - $virtualizer.options.scrollMargin
|
||||||
|
: 0}px);"
|
||||||
|
class="divide-y divide-slate-200 dark:divide-zinc-900"
|
||||||
|
id="feed"
|
||||||
|
>
|
||||||
|
{#each items as row, index (posts[row.index]?.post.id)}
|
||||||
|
{#if posts[row.index]}
|
||||||
|
<li
|
||||||
|
bind:this={virtualItemEls[index]}
|
||||||
|
data-index={row.index}
|
||||||
|
style={row.index < 7 ? `--anim-delay: ${index * 100}ms` : ''}
|
||||||
|
class="relative post-container {row.index < 7
|
||||||
|
? 'pop-in opacity-0'
|
||||||
|
: ''} -mx-4 sm:-mx-6 px-4 sm:px-6"
|
||||||
|
>
|
||||||
|
<Post
|
||||||
|
bind:post={posts[row.index]}
|
||||||
|
hideCommunity={community}
|
||||||
|
view={(posts[row.index]?.post.featured_community ||
|
||||||
|
posts[row.index]?.post.featured_local) &&
|
||||||
|
settings.posts.compactFeatured
|
||||||
|
? 'compact'
|
||||||
|
: settings.view}
|
||||||
|
class="transition-all duration-250"
|
||||||
|
onhide={() => {
|
||||||
|
posts = posts.toSpliced(row.index, 1)
|
||||||
|
}}
|
||||||
|
></Post>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{/key}
|
||||||
|
|
||||||
{#if settings.infiniteScroll && browser}
|
{#if settings.infiniteScroll && browser}
|
||||||
{#if error}
|
{#if error}
|
||||||
|
|||||||
+10
-10
@@ -5,6 +5,16 @@ import { env } from '$env/dynamic/public'
|
|||||||
import { writable } from 'svelte/store'
|
import { writable } from 'svelte/store'
|
||||||
import { profile } from './auth.svelte'
|
import { profile } from './auth.svelte'
|
||||||
|
|
||||||
|
class InstanceData {
|
||||||
|
#instance = $derived(profile.data.instance)
|
||||||
|
|
||||||
|
get data() {
|
||||||
|
return this.#instance
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export let instance = new InstanceData()
|
||||||
|
|
||||||
export const LINKED_INSTANCE_URL =
|
export const LINKED_INSTANCE_URL =
|
||||||
(env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true'
|
(env.PUBLIC_LOCK_TO_INSTANCE ?? 'true').toLowerCase() == 'true'
|
||||||
? env.PUBLIC_INSTANCE_URL
|
? env.PUBLIC_INSTANCE_URL
|
||||||
@@ -19,13 +29,3 @@ const getDefaultInstance = (): string => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const DEFAULT_INSTANCE_URL = getDefaultInstance()
|
export const DEFAULT_INSTANCE_URL = getDefaultInstance()
|
||||||
|
|
||||||
class InstanceData {
|
|
||||||
#instance = $derived(profile.data.instance)
|
|
||||||
|
|
||||||
get data() {
|
|
||||||
return this.#instance
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export let instance = new InstanceData()
|
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
floatingContent(node)
|
floatingContent(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
const customFloatingRef = (node: HTMLButtonElement) => {
|
const customFloatingRef = (node: HTMLDivElement) => {
|
||||||
const n = node.children.item(0)
|
const n = node.children.item(0)
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
@@ -102,7 +102,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
{#if target}
|
{#if target}
|
||||||
<button
|
<div
|
||||||
onmouseover={() => (openOnHover ? (open = true) : false)}
|
onmouseover={() => (openOnHover ? (open = true) : false)}
|
||||||
onmouseleave={() => (openOnHover ? (open = false) : false)}
|
onmouseleave={() => (openOnHover ? (open = false) : false)}
|
||||||
onfocus={() => (openOnHover ? (open = true) : false)}
|
onfocus={() => (openOnHover ? (open = true) : false)}
|
||||||
@@ -111,14 +111,14 @@
|
|||||||
onkeydown={(e) => {
|
onkeydown={(e) => {
|
||||||
if (e.key == 'Escape') open = false
|
if (e.key == 'Escape') open = false
|
||||||
}}
|
}}
|
||||||
role="menu"
|
tabindex="0"
|
||||||
type="button"
|
role="button"
|
||||||
class="{canUseContents ? 'contents text-left' : 'w-max h-max'} {clazz}"
|
class="{canUseContents ? 'contents text-left' : 'w-max h-max'} {clazz}"
|
||||||
bind:this={el}
|
bind:this={el}
|
||||||
use:customFloatingRef
|
use:customFloatingRef
|
||||||
>
|
>
|
||||||
{@render target?.()}
|
{@render target?.()}
|
||||||
</button>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if open}
|
{#if open}
|
||||||
|
|||||||
@@ -10,10 +10,7 @@
|
|||||||
} from '$lib/auth.svelte.js'
|
} from '$lib/auth.svelte.js'
|
||||||
import { Menu, MenuButton, Modal } from 'mono-svelte'
|
import { Menu, MenuButton, Modal } from 'mono-svelte'
|
||||||
import DebugObject from '$lib/components/util/debug/DebugObject.svelte'
|
import DebugObject from '$lib/components/util/debug/DebugObject.svelte'
|
||||||
import {
|
import { LINKED_INSTANCE_URL } from '$lib/instance.svelte.js'
|
||||||
DEFAULT_INSTANCE_URL,
|
|
||||||
LINKED_INSTANCE_URL,
|
|
||||||
} from '$lib/instance.svelte.js'
|
|
||||||
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
|
import ProfileAvatar from '$lib/lemmy/ProfileAvatar.svelte'
|
||||||
import { settings } from '$lib/settings.svelte.js'
|
import { settings } from '$lib/settings.svelte.js'
|
||||||
import { Button, TextInput } from 'mono-svelte'
|
import { Button, TextInput } from 'mono-svelte'
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { Button, TextInput, toast } from 'mono-svelte'
|
import { Button, TextInput, toast } from 'mono-svelte'
|
||||||
|
|
||||||
let instance = $state(LINKED_INSTANCE_URL || $currentInstance || '')
|
let instance = $state(LINKED_INSTANCE_URL || currentInstance.data || '')
|
||||||
let email = $state('')
|
let email = $state('')
|
||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
let { data }: Props = $props()
|
let { data }: Props = $props()
|
||||||
|
|
||||||
let instance = $state(LINKED_INSTANCE_URL || $currentInstance || '')
|
let instance = $state(LINKED_INSTANCE_URL || currentInstance.data || '')
|
||||||
let password = $state(''),
|
let password = $state(''),
|
||||||
password_verify = $state('')
|
password_verify = $state('')
|
||||||
let loading = $state(false)
|
let loading = $state(false)
|
||||||
|
|||||||
@@ -231,8 +231,8 @@
|
|||||||
</p>
|
</p>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="none"
|
||||||
class="dark:bg-pink-400 bg-pink-600"
|
class="dark:bg-pink-400 bg-pink-600 text-white dark:text-black"
|
||||||
href="https://buymeacoffee.com/xylight"
|
href="https://buymeacoffee.com/xylight"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import { Badge, Material, Spinner, toast } from 'mono-svelte'
|
import { Badge, Material, Spinner, toast } from 'mono-svelte'
|
||||||
import { DEFAULT_INSTANCE_URL } from '$lib/instance.svelte.js'
|
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.svelte.js'
|
||||||
import { validateInstance } from '$lib/lemmy.svelte.js'
|
import { validateInstance } from '$lib/lemmy.svelte.js'
|
||||||
import { Button, TextInput } from 'mono-svelte'
|
import { Button, TextInput } from 'mono-svelte'
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
|||||||
Reference in new issue
Block a user