cleanup: improve reacvtivity on post page, remove useless community icon

This commit is contained in:
James Xylight committed 2025-02-04 16:56:50 -08:00
1 parent 8fcb8af015
commit 6b64e0f59f
7 files changed
+22 -76

No files matched your search

+3 -15
View File
@@ -83,23 +83,11 @@
}
})
}
let barTimeout: number = $state(0)
$effect(() => {
if (navigating.to) {
document.body.classList.toggle('wait', true)
barTimeout = setTimeout(() => nProgress.start(), 100)
} else {
document.body.classList.toggle('wait', false)
clearTimeout(barTimeout)
nProgress.done()
}
if (navigating.to) nProgress.start()
else nProgress.done()
})
let error = $state(null)
function onerror(e: any, r: any) {
error = e
}
</script>
<svelte:head>
@@ -1,10 +1,5 @@
<script lang="ts">
import { run } from 'svelte/legacy'
import {
buildCommentsTree,
type CommentNodeI,
} from '$lib/components/lemmy/comment/comments.svelte.js'
import { buildCommentsTree } from '$lib/components/lemmy/comment/comments.svelte.js'
import { isImage } from '$lib/ui/image.js'
import { client, getClient } from '$lib/lemmy.js'
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
@@ -59,15 +54,12 @@
import { expoOut } from 'svelte/easing'
import Option from 'mono-svelte/forms/select/Option.svelte'
let { data = $bindable() } = $props()
let comments = $state(data.comments)
let { data: loaded = $bindable() } = $props()
let data = $state(loaded)
$effect(() => {
comments = data.comments
data = loaded
})
let type = $derived(mediaType(data.post.post_view.post.url, 'cozy'))
const updateActions = () => {
// @ts-ignore
data.contextual = {
@@ -114,7 +106,7 @@
}
}
run(() => {
$effect(() => {
if (data.post) updateActions()
})
@@ -139,11 +131,6 @@
})
})
afterNavigate(async () => {
// reactivity hack
data.post = data.post
})
const fetchOnHome = async (jwt: string) => {
const id = toast({
content: $t('toast.fetchPostOnHome'),
@@ -172,7 +159,7 @@
async function reloadComments() {
loading = true
comments = getClient().getComments({
data.comments = getClient().getComments({
page: 1,
limit: 25,
type_: 'All',
@@ -190,11 +177,6 @@
let remoteView = $derived(
page.params.instance?.toLowerCase() != $instance.toLowerCase(),
)
function createCommentsState(tree: CommentNodeI[]) {
const state = $state(tree)
return state
}
</script>
<svelte:head>
@@ -388,7 +370,7 @@
{$t('routes.post.commentCount')}
</div>
</header>
{#await comments}
{#await data.comments}
<div class="flex flex-col gap-4">
{#each new Array(10) as empty, index}
<div
+1 -1
View File
@@ -189,7 +189,7 @@
{/if}
{/await}
<div
class="flex flex-col mt-4 divide-slate-200 dark:divide-zinc-800 divide-y"
class="flex flex-col mt-4 divide-slate-200 dark:divide-zinc-800 !divide-y"
>
{#each data.results as result}
{#if isPostView(result)}