cleanup: improve reacvtivity on post page, remove useless community icon
This commit is contained in:
1 parent
8fcb8af015
commit
6b64e0f59f
7 files changed
+22
-76
No files matched your search
@@ -60,12 +60,14 @@
|
||||
</div>
|
||||
<Button
|
||||
color="primary"
|
||||
rounding="pill"
|
||||
size="sm"
|
||||
href="/post/{comment.post.id}?thread={comment.comment.path}#{comment
|
||||
.comment.id}"
|
||||
class="self-start"
|
||||
>
|
||||
{$t('common.jump')}
|
||||
<Icon src={ArrowUturnUp} size="16" micro />
|
||||
<Icon src={ArrowUturnUp} size="14" micro />
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -72,8 +72,6 @@
|
||||
import CommunityHeader from '../community/CommunityHeader.svelte'
|
||||
import { publishedToDate } from '$lib/components/util/date'
|
||||
|
||||
let popoverOpen = $state(false)
|
||||
|
||||
interface Props {
|
||||
community?: Community | undefined
|
||||
showCommunity?: boolean
|
||||
@@ -132,36 +130,13 @@
|
||||
class:compact={view == 'compact'}
|
||||
{style}
|
||||
>
|
||||
{#if showCommunity && community != undefined && subscribed}
|
||||
<Popover bind:open={popoverOpen} manual>
|
||||
{#snippet target()}
|
||||
<button
|
||||
onclick={() => (popoverOpen = !popoverOpen)}
|
||||
class="relative cursor-pointer row-span-2 flex-shrink-0 pr-2 group/community"
|
||||
>
|
||||
<Avatar
|
||||
url={community?.icon}
|
||||
width={view == 'compact' ? 24 : 32}
|
||||
alt={community?.name}
|
||||
class="group-hover/community:ring-2 transition-all ring-offset-0 ring-primary-900 dark:ring-primary-100"
|
||||
/>
|
||||
</button>
|
||||
{/snippet}
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
{#snippet popover()}
|
||||
{#if community && subscribed}
|
||||
<div
|
||||
class="max-w-md rounded-2xl bg-white dark:bg-zinc-950"
|
||||
onclick={stopPropagation(() => {})}
|
||||
>
|
||||
<CommunityHeader bind:community bind:subscribed />
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</Popover>
|
||||
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||
{#if showCommunity && community}
|
||||
<Avatar
|
||||
url={community?.icon}
|
||||
width={view == 'compact' ? 24 : 32}
|
||||
alt={community?.name}
|
||||
class="row-span-2 flex-shrink-0 mr-2"
|
||||
/>
|
||||
{/if}
|
||||
{#if showCommunity && community}
|
||||
<CommunityLink
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
|
||||
"
|
||||
style="{pageHeader
|
||||
? `margin-top: min(-6rem, calc(-1 * calc(${$contentPadding.top}px))); padding-top: max(6rem, calc(${$contentPadding.top}px));`
|
||||
? `margin-top: min(-12rem, calc(-1 * calc(${$contentPadding.top}px))); padding-top: max(12rem, calc(${$contentPadding.top}px));`
|
||||
: ''} {style};
|
||||
"
|
||||
>
|
||||
|
||||
@@ -194,7 +194,6 @@
|
||||
<hr class="dark:opacity-10 w-[90%] my-2 mx-auto" />
|
||||
<li class="flex flex-col px-2 py-1 mx-auto my-1 text-xs w-full">
|
||||
<div class="flex flex-row gap-2 w-full items-center">
|
||||
<!-- svelte-ignore missing_declaration -->
|
||||
<div class="flex-1">
|
||||
<button
|
||||
class="hover:brightness-110 transition-all"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)}
|
||||
|
||||
Reference in new issue
Block a user