fix: comments not appearing immediately
This commit is contained in:
6 files changed
+53
-148
No files matched your search
@@ -14,7 +14,6 @@
|
|||||||
interface Props extends HTMLAnchorAttributes {
|
interface Props extends HTMLAnchorAttributes {
|
||||||
href: string
|
href: string
|
||||||
highlight?: boolean
|
highlight?: boolean
|
||||||
nowrap?: boolean
|
|
||||||
children?: import('svelte').Snippet
|
children?: import('svelte').Snippet
|
||||||
class?: string
|
class?: string
|
||||||
icon?: import('svelte').Snippet
|
icon?: import('svelte').Snippet
|
||||||
@@ -23,48 +22,22 @@
|
|||||||
let {
|
let {
|
||||||
href,
|
href,
|
||||||
highlight = false,
|
highlight = false,
|
||||||
nowrap = false,
|
|
||||||
children,
|
children,
|
||||||
class: clazz = '',
|
class: clazz = '',
|
||||||
icon,
|
icon,
|
||||||
...rest
|
...rest
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let richURL = $derived(children ? undefined : parseURL(href))
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<a
|
<a
|
||||||
{...rest}
|
{...rest}
|
||||||
{href}
|
{href}
|
||||||
class="{highlight
|
class={[
|
||||||
? 'text-sky-500'
|
'hover:underline max-w-full inline-flex items-center gap-1',
|
||||||
: ''} hover:underline max-w-full inline-flex items-center gap-1 {clazz}"
|
highlight && 'text-blue-600 dark:text-blue-400',
|
||||||
|
clazz,
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
{@render icon?.()}
|
{@render icon?.()}
|
||||||
{#if children}{@render children()}{:else}
|
{@render children?.()}
|
||||||
<span
|
|
||||||
class="flex relative gap-0 {nowrap
|
|
||||||
? 'w-full whitespace-nowrap overflow-hidden text-ellipsis text-xs'
|
|
||||||
: ''} {clazz}"
|
|
||||||
>
|
|
||||||
{#if richURL}
|
|
||||||
<span class="text-blue-300 dark:text-blue-800">
|
|
||||||
{richURL.protocol}//
|
|
||||||
</span>
|
|
||||||
<span class="font-medium">
|
|
||||||
{richURL.hostname}
|
|
||||||
</span>
|
|
||||||
<span
|
|
||||||
class="text-transparent bg-clip-text bg-linear-to-r
|
|
||||||
from-blue-300 via-blue-300 to-blue-300/0 w-full
|
|
||||||
dark:from-blue-800 dark:via-blue-800 dark:to-blue-800/0
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{richURL.pathname}
|
|
||||||
</span>
|
|
||||||
{:else}
|
|
||||||
{href}
|
|
||||||
{/if}
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</a>
|
</a>
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { profile } from '$lib/auth.svelte.js'
|
import { profile } from '$lib/auth.svelte.js'
|
||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
|
||||||
import LabelStat from '$lib/components/ui/LabelStat.svelte'
|
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
|
||||||
import { t } from '$lib/i18n/translations'
|
|
||||||
import { client } from '$lib/client/lemmy.svelte'
|
import { client } from '$lib/client/lemmy.svelte'
|
||||||
import { addSubscription } from '$lib/lemmy/user.js'
|
|
||||||
import { settings } from '$lib/settings.svelte'
|
|
||||||
import { fullCommunityName } from '$lib/util.svelte.js'
|
|
||||||
import type { CommunityView } from '$lib/client/types'
|
import type { CommunityView } from '$lib/client/types'
|
||||||
|
import CommonItem from '$lib/components/ui/layout/CommonItem.svelte'
|
||||||
|
import { locale, t } from '$lib/i18n/translations'
|
||||||
|
import { addSubscription } from '$lib/lemmy/user.js'
|
||||||
|
import { fullCommunityName } from '$lib/util.svelte.js'
|
||||||
import { Button, modal } from 'mono-svelte'
|
import { Button, modal } from 'mono-svelte'
|
||||||
import type { Snippet } from 'svelte'
|
import type { Snippet } from 'svelte'
|
||||||
import {
|
import {
|
||||||
@@ -21,29 +18,23 @@
|
|||||||
Plus,
|
Plus,
|
||||||
Trash,
|
Trash,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
import { SvelteURL } from 'svelte/reactivity'
|
||||||
import { CommunityCard } from '.'
|
import { CommunityCard } from '.'
|
||||||
|
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
community: CommunityView
|
community: CommunityView
|
||||||
view?: 'cozy' | 'compact'
|
view?: 'cozy' | 'compact'
|
||||||
showCounts?: boolean
|
showCounts?: boolean
|
||||||
class?: string
|
|
||||||
icon?: import('svelte').Snippet
|
|
||||||
children?: Snippet
|
children?: Snippet
|
||||||
resolveObject?: boolean
|
resolveObject?: boolean
|
||||||
actions?: boolean
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
community = $bindable(),
|
community = $bindable(),
|
||||||
view = 'compact',
|
view = 'compact',
|
||||||
showCounts = true,
|
showCounts = true,
|
||||||
class: clazz = 'flex flex-col gap-4 text-sm max-w-full relative',
|
|
||||||
icon,
|
|
||||||
children,
|
|
||||||
resolveObject,
|
resolveObject,
|
||||||
actions = true,
|
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -51,46 +42,18 @@
|
|||||||
<CommunityCard community_view={community} />
|
<CommunityCard community_view={community} />
|
||||||
{/snippet}
|
{/snippet}
|
||||||
|
|
||||||
<div class={clazz}>
|
<CommonItem
|
||||||
<div
|
icon={community.community.icon}
|
||||||
class={[
|
|
||||||
view == 'cozy' ? 'flex-col gap-2' : 'flex-row',
|
|
||||||
'flex max-w-full w-full',
|
|
||||||
]}
|
|
||||||
>
|
|
||||||
<a
|
|
||||||
href="/c/{fullCommunityName(
|
href="/c/{fullCommunityName(
|
||||||
community.community.name,
|
community.community.name,
|
||||||
community.community.actor_id,
|
community.community.actor_id,
|
||||||
)}"
|
)}"
|
||||||
class="flex-1 w-full overflow-hidden group"
|
title={community.community.title}
|
||||||
data-sveltekit-preload-data="tap"
|
detail="{new SvelteURL(community.community.actor_id).hostname}{!showCounts
|
||||||
|
? ` • ${Intl.NumberFormat($locale, { notation: 'compact' }).format(community.counts.subscribers)}`
|
||||||
|
: ''}"
|
||||||
|
orientation={view == 'cozy' ? 'vertical' : 'horizontal'}
|
||||||
>
|
>
|
||||||
<div class="flex flex-row gap-2 items-center">
|
|
||||||
{#if icon}
|
|
||||||
{@render icon()}
|
|
||||||
{:else if community.community.nsfw && settings.nsfwBlur}
|
|
||||||
<div class="w-8 h-8 rounded-xl bg-red-400"></div>
|
|
||||||
{:else}
|
|
||||||
<Avatar
|
|
||||||
url={community.community.icon}
|
|
||||||
width={32}
|
|
||||||
circle={false}
|
|
||||||
alt={community.community.name}
|
|
||||||
class={[
|
|
||||||
community.community.nsfw && settings.nsfwBlur && 'blur-3xl',
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
<div
|
|
||||||
class="flex flex-col overflow-hidden whitespace-nowrap flex-1 min-w-0 shrink"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="font-medium text-base overflow-hidden text-ellipsis leading-5"
|
|
||||||
>
|
|
||||||
<h3 class="group-hover:underline text-left">
|
|
||||||
{community.community.title}
|
|
||||||
</h3>
|
|
||||||
{#if community.community.deleted}
|
{#if community.community.deleted}
|
||||||
<Icon
|
<Icon
|
||||||
src={Trash}
|
src={Trash}
|
||||||
@@ -127,25 +90,6 @@
|
|||||||
title={$t('routes.admin.config.listingType.local')}
|
title={$t('routes.admin.config.listingType.local')}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
|
||||||
<div class="text-sm text-slate-500 dark:text-zinc-500 flex gap-0.5">
|
|
||||||
<span class="overflow-hidden text-ellipsis">
|
|
||||||
{new URL(community.community.actor_id).hostname}
|
|
||||||
</span>
|
|
||||||
<span class="overflow-hidden text-ellipsis">
|
|
||||||
{#if !showCounts}
|
|
||||||
•
|
|
||||||
<FormattedNumber number={community.counts.subscribers} />
|
|
||||||
{/if}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
{#if children || !actions}
|
|
||||||
{@render children?.()}
|
|
||||||
{:else}
|
|
||||||
<div class="flex flex-row items-center gap-2">
|
|
||||||
<Button
|
<Button
|
||||||
rounding="xl"
|
rounding="xl"
|
||||||
color="ghost"
|
color="ghost"
|
||||||
@@ -182,10 +126,7 @@
|
|||||||
: 'NotSubscribed'
|
: 'NotSubscribed'
|
||||||
|
|
||||||
community.subscribed = newSubscribed
|
community.subscribed = newSubscribed
|
||||||
addSubscription(
|
addSubscription(community.community, newSubscribed == 'Subscribed')
|
||||||
community.community,
|
|
||||||
newSubscribed == 'Subscribed',
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
size="custom"
|
size="custom"
|
||||||
@@ -213,32 +154,4 @@
|
|||||||
</Button>
|
</Button>
|
||||||
{/snippet}
|
{/snippet}
|
||||||
</Subscribe>
|
</Subscribe>
|
||||||
</div>
|
</CommonItem>
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{#if showCounts}
|
|
||||||
<div class="flex flex-row gap-3 items-center justify-center">
|
|
||||||
{#if community.counts.posts}
|
|
||||||
<LabelStat
|
|
||||||
content={community.counts.posts.toString()}
|
|
||||||
formatted
|
|
||||||
label="Posts"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
{#if community.counts.subscribers}
|
|
||||||
<LabelStat
|
|
||||||
content={community.counts.subscribers.toString()}
|
|
||||||
formatted
|
|
||||||
label="Members"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
{#if community.counts.comments}
|
|
||||||
<LabelStat
|
|
||||||
content={community.counts.comments.toString()}
|
|
||||||
formatted
|
|
||||||
label="Comments"
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
@@ -7,13 +7,28 @@
|
|||||||
icon?: string
|
icon?: string
|
||||||
title: string
|
title: string
|
||||||
detail?: string
|
detail?: string
|
||||||
|
orientation: 'vertical' | 'horizontal'
|
||||||
children?: Snippet
|
children?: Snippet
|
||||||
}
|
}
|
||||||
|
|
||||||
let { href, icon, title, detail, children }: Props = $props()
|
let {
|
||||||
|
href,
|
||||||
|
icon,
|
||||||
|
title,
|
||||||
|
detail,
|
||||||
|
children,
|
||||||
|
orientation = 'horizontal',
|
||||||
|
}: Props = $props()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-row gap-2 items-center">
|
<div
|
||||||
|
class={[
|
||||||
|
'flex gap-2 p-5',
|
||||||
|
orientation == 'horizontal'
|
||||||
|
? 'flex-row items-center'
|
||||||
|
: 'flex-col items-staRT',
|
||||||
|
]}
|
||||||
|
>
|
||||||
<Avatar url={icon} alt={title} width={detail ? 32 : 24} circle={false} />
|
<Avatar url={icon} alt={title} width={detail ? 32 : 24} circle={false} />
|
||||||
<a class="flex-1 flex flex-col group" {href}>
|
<a class="flex-1 flex flex-col group" {href}>
|
||||||
<h3
|
<h3
|
||||||
@@ -25,5 +40,7 @@
|
|||||||
{detail}
|
{detail}
|
||||||
</p>
|
</p>
|
||||||
</a>
|
</a>
|
||||||
|
<div class="flex flex-row gap-2 items-center">
|
||||||
{@render children?.()}
|
{@render children?.()}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
@@ -28,6 +28,7 @@
|
|||||||
import ProfileSelection from './ProfileSelection.svelte'
|
import ProfileSelection from './ProfileSelection.svelte'
|
||||||
import Logo from '../Logo.svelte'
|
import Logo from '../Logo.svelte'
|
||||||
import { env } from '$env/dynamic/public'
|
import { env } from '$env/dynamic/public'
|
||||||
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
style?: string
|
style?: string
|
||||||
@@ -181,18 +182,12 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{#if env.PUBLIC_XYLIGHT_MODE?.toLowerCase() == 'true'}
|
{#if env.PUBLIC_XYLIGHT_MODE?.toLowerCase() == 'true'}
|
||||||
<a
|
<Link highlight href="https://github.com/xyphyn/photon">
|
||||||
href="https://github.com/xyphyn/photon"
|
|
||||||
class="text-blue-600 dark:text-blue-400/60 hover:underline"
|
|
||||||
>
|
|
||||||
{$t('nav.menu.source')}
|
{$t('nav.menu.source')}
|
||||||
</a>
|
</Link>
|
||||||
<a
|
<Link highlight href="https://buymeacoffee.com/xylight">
|
||||||
href="https://buymeacoffee.com/xylight"
|
|
||||||
class="text-blue-600 dark:text-blue-400/60 hover:underline"
|
|
||||||
>
|
|
||||||
{$t('nav.menu.donate')}
|
{$t('nav.menu.donate')}
|
||||||
</a>
|
</Link>
|
||||||
{/if}
|
{/if}
|
||||||
</footer>
|
</footer>
|
||||||
</nav>
|
</nav>
|
||||||
@@ -18,6 +18,8 @@
|
|||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (data.filters.value.sort)
|
if (data.filters.value.sort)
|
||||||
settings.defaultSort.sort = data.filters.value.sort
|
settings.defaultSort.sort = data.filters.value.sort
|
||||||
|
if (data.filters.value.type_)
|
||||||
|
settings.defaultSort.feed = data.filters.value.type_
|
||||||
})
|
})
|
||||||
|
|
||||||
const FeedComponent = $derived(
|
const FeedComponent = $derived(
|
||||||
|
|||||||
@@ -116,7 +116,12 @@
|
|||||||
<CommentForm
|
<CommentForm
|
||||||
postId={post.post.id}
|
postId={post.post.id}
|
||||||
oncomment={(comment) => {
|
oncomment={(comment) => {
|
||||||
comments.unshift(comment.comment_view)
|
tree.unshift({
|
||||||
|
children: [],
|
||||||
|
depth: 1,
|
||||||
|
expanded: true,
|
||||||
|
comment_view: comment.comment_view,
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
onfocus={() => (commenting = true)}
|
onfocus={() => (commenting = true)}
|
||||||
tools={commenting}
|
tools={commenting}
|
||||||
|
|||||||
Reference in new issue
Block a user