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>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
color="primary"
|
color="primary"
|
||||||
|
rounding="pill"
|
||||||
|
size="sm"
|
||||||
href="/post/{comment.post.id}?thread={comment.comment.path}#{comment
|
href="/post/{comment.post.id}?thread={comment.comment.path}#{comment
|
||||||
.comment.id}"
|
.comment.id}"
|
||||||
class="self-start"
|
class="self-start"
|
||||||
>
|
>
|
||||||
{$t('common.jump')}
|
{$t('common.jump')}
|
||||||
<Icon src={ArrowUturnUp} size="16" micro />
|
<Icon src={ArrowUturnUp} size="14" micro />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -72,8 +72,6 @@
|
|||||||
import CommunityHeader from '../community/CommunityHeader.svelte'
|
import CommunityHeader from '../community/CommunityHeader.svelte'
|
||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
|
|
||||||
let popoverOpen = $state(false)
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community?: Community | undefined
|
community?: Community | undefined
|
||||||
showCommunity?: boolean
|
showCommunity?: boolean
|
||||||
@@ -132,36 +130,13 @@
|
|||||||
class:compact={view == 'compact'}
|
class:compact={view == 'compact'}
|
||||||
{style}
|
{style}
|
||||||
>
|
>
|
||||||
{#if showCommunity && community != undefined && subscribed}
|
{#if showCommunity && community}
|
||||||
<Popover bind:open={popoverOpen} manual>
|
<Avatar
|
||||||
{#snippet target()}
|
url={community?.icon}
|
||||||
<button
|
width={view == 'compact' ? 24 : 32}
|
||||||
onclick={() => (popoverOpen = !popoverOpen)}
|
alt={community?.name}
|
||||||
class="relative cursor-pointer row-span-2 flex-shrink-0 pr-2 group/community"
|
class="row-span-2 flex-shrink-0 mr-2"
|
||||||
>
|
/>
|
||||||
<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}
|
{/if}
|
||||||
{#if showCommunity && community}
|
{#if showCommunity && community}
|
||||||
<CommunityLink
|
<CommunityLink
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
"
|
"
|
||||||
style="{pageHeader
|
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};
|
: ''} {style};
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -194,7 +194,6 @@
|
|||||||
<hr class="dark:opacity-10 w-[90%] my-2 mx-auto" />
|
<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">
|
<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">
|
<div class="flex flex-row gap-2 w-full items-center">
|
||||||
<!-- svelte-ignore missing_declaration -->
|
|
||||||
<div class="flex-1">
|
<div class="flex-1">
|
||||||
<button
|
<button
|
||||||
class="hover:brightness-110 transition-all"
|
class="hover:brightness-110 transition-all"
|
||||||
|
|||||||
@@ -83,23 +83,11 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let barTimeout: number = $state(0)
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (navigating.to) {
|
if (navigating.to) nProgress.start()
|
||||||
document.body.classList.toggle('wait', true)
|
else nProgress.done()
|
||||||
barTimeout = setTimeout(() => nProgress.start(), 100)
|
|
||||||
} else {
|
|
||||||
document.body.classList.toggle('wait', false)
|
|
||||||
clearTimeout(barTimeout)
|
|
||||||
nProgress.done()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
let error = $state(null)
|
|
||||||
|
|
||||||
function onerror(e: any, r: any) {
|
|
||||||
error = e
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { run } from 'svelte/legacy'
|
import { buildCommentsTree } from '$lib/components/lemmy/comment/comments.svelte.js'
|
||||||
|
|
||||||
import {
|
|
||||||
buildCommentsTree,
|
|
||||||
type CommentNodeI,
|
|
||||||
} from '$lib/components/lemmy/comment/comments.svelte.js'
|
|
||||||
import { isImage } from '$lib/ui/image.js'
|
import { isImage } from '$lib/ui/image.js'
|
||||||
import { client, getClient } from '$lib/lemmy.js'
|
import { client, getClient } from '$lib/lemmy.js'
|
||||||
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
||||||
@@ -59,15 +54,12 @@
|
|||||||
import { expoOut } from 'svelte/easing'
|
import { expoOut } from 'svelte/easing'
|
||||||
import Option from 'mono-svelte/forms/select/Option.svelte'
|
import Option from 'mono-svelte/forms/select/Option.svelte'
|
||||||
|
|
||||||
let { data = $bindable() } = $props()
|
let { data: loaded = $bindable() } = $props()
|
||||||
|
let data = $state(loaded)
|
||||||
let comments = $state(data.comments)
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
comments = data.comments
|
data = loaded
|
||||||
})
|
})
|
||||||
|
|
||||||
let type = $derived(mediaType(data.post.post_view.post.url, 'cozy'))
|
|
||||||
|
|
||||||
const updateActions = () => {
|
const updateActions = () => {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
data.contextual = {
|
data.contextual = {
|
||||||
@@ -114,7 +106,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run(() => {
|
$effect(() => {
|
||||||
if (data.post) updateActions()
|
if (data.post) updateActions()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -139,11 +131,6 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
afterNavigate(async () => {
|
|
||||||
// reactivity hack
|
|
||||||
data.post = data.post
|
|
||||||
})
|
|
||||||
|
|
||||||
const fetchOnHome = async (jwt: string) => {
|
const fetchOnHome = async (jwt: string) => {
|
||||||
const id = toast({
|
const id = toast({
|
||||||
content: $t('toast.fetchPostOnHome'),
|
content: $t('toast.fetchPostOnHome'),
|
||||||
@@ -172,7 +159,7 @@
|
|||||||
|
|
||||||
async function reloadComments() {
|
async function reloadComments() {
|
||||||
loading = true
|
loading = true
|
||||||
comments = getClient().getComments({
|
data.comments = getClient().getComments({
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
type_: 'All',
|
type_: 'All',
|
||||||
@@ -190,11 +177,6 @@
|
|||||||
let remoteView = $derived(
|
let remoteView = $derived(
|
||||||
page.params.instance?.toLowerCase() != $instance.toLowerCase(),
|
page.params.instance?.toLowerCase() != $instance.toLowerCase(),
|
||||||
)
|
)
|
||||||
|
|
||||||
function createCommentsState(tree: CommentNodeI[]) {
|
|
||||||
const state = $state(tree)
|
|
||||||
return state
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -388,7 +370,7 @@
|
|||||||
{$t('routes.post.commentCount')}
|
{$t('routes.post.commentCount')}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
{#await comments}
|
{#await data.comments}
|
||||||
<div class="flex flex-col gap-4">
|
<div class="flex flex-col gap-4">
|
||||||
{#each new Array(10) as empty, index}
|
{#each new Array(10) as empty, index}
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -189,7 +189,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/await}
|
{/await}
|
||||||
<div
|
<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}
|
{#each data.results as result}
|
||||||
{#if isPostView(result)}
|
{#if isPostView(result)}
|
||||||
|
|||||||
Reference in new issue
Block a user