feat: Add notification for unreads
This commit is contained in:
1 parent
28d9820b1e
commit
1a0881f9ce
13 files changed
+215
-105
No files matched your search
@@ -43,8 +43,15 @@
|
|||||||
<FormattedNumber number={community_view.counts.comments} />
|
<FormattedNumber number={community_view.counts.comments} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="font-bold text-lg">
|
<div>
|
||||||
{community_view.community.name}
|
<h1 class="font-bold text-lg">
|
||||||
</h1>
|
{community_view.community.title}
|
||||||
|
</h1>
|
||||||
|
<span class="opacity-80 text-sm">
|
||||||
|
!{community_view.community.name}@{new URL(
|
||||||
|
community_view.community.actor_id
|
||||||
|
).hostname}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<Markdown source={community_view.community.description} />
|
<Markdown source={community_view.community.description} />
|
||||||
</StickyCard>
|
</StickyCard>
|
||||||
@@ -25,6 +25,7 @@
|
|||||||
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
|
||||||
import { Color } from '$lib/ui/colors.js'
|
import { Color } from '$lib/ui/colors.js'
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
|
|
||||||
let postRes: PostView
|
let postRes: PostView
|
||||||
export { postRes as post }
|
export { postRes as post }
|
||||||
@@ -49,16 +50,22 @@
|
|||||||
<Card class="bg-white flex flex-col overflow-hidden w-full relative">
|
<Card class="bg-white flex flex-col overflow-hidden w-full relative">
|
||||||
<div class="flex flex-col gap-2 bg-white dark:bg-zinc-900 p-4 rounded-md">
|
<div class="flex flex-col gap-2 bg-white dark:bg-zinc-900 p-4 rounded-md">
|
||||||
<span class="flex flex-row gap-2 text-xs items-center">
|
<span class="flex flex-row gap-2 text-xs items-center">
|
||||||
<CommunityLink avatarSize={20} avatar community={postRes.community} />
|
<Avatar url={postRes.community.icon ?? ''} alt="" width={24} />
|
||||||
<span class="opacity-60">
|
<div class="flex flex-col">
|
||||||
<UserLink user={postRes.creator} />
|
<CommunityLink community={postRes.community} />
|
||||||
</span>
|
<span class="opacity-60 flex flex-row gap-1">
|
||||||
|
<UserLink user={postRes.creator} />
|
||||||
|
<span>•</span>
|
||||||
|
<RelativeDate date={new Date(postRes.post.published)} />
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div class="ml-auto" />
|
<div class="ml-auto" />
|
||||||
<span class="opacity-50 capitalize">
|
<span class="opacity-50 capitalize" />
|
||||||
<RelativeDate date={new Date(postRes.post.published)} />
|
|
||||||
</span>
|
|
||||||
</span>
|
</span>
|
||||||
<a href="/post/{postRes.post.id}" class="font-bold">
|
<a
|
||||||
|
href="/post/{postRes.post.id}"
|
||||||
|
class="font-bold {postRes.read ? 'opacity-50' : ''}"
|
||||||
|
>
|
||||||
{postRes.post.name}
|
{postRes.post.name}
|
||||||
</a>
|
</a>
|
||||||
{#if postRes.post.url}
|
{#if postRes.post.url}
|
||||||
@@ -115,7 +122,7 @@
|
|||||||
<FormattedNumber number={postRes.counts.comments} />
|
<FormattedNumber number={postRes.counts.comments} />
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<Menu top absolute class="bottom-0 right-0 m-5 z-40">
|
<Menu top absolute class="bottom-0 right-0 m-5 z-10">
|
||||||
<Button slot="button">
|
<Button slot="button">
|
||||||
<Icon src={EllipsisHorizontal} width={16} mini />
|
<Icon src={EllipsisHorizontal} width={16} mini />
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -120,14 +120,16 @@
|
|||||||
class="flex flex-col gap-1 whitespace-pre-wrap
|
class="flex flex-col gap-1 whitespace-pre-wrap
|
||||||
max-w-full"
|
max-w-full"
|
||||||
>
|
>
|
||||||
<div class="max-w-full break-words">
|
<div class="max-w-full break-words text-sm leading-6">
|
||||||
<Markdown source={node.comment_view.comment.content} />
|
<Markdown source={node.comment_view.comment.content} />
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-2 items-center">
|
<div class="flex flex-row gap-2 items-center">
|
||||||
<div class="flex flex-row gap-2 items-center">
|
<div class="flex flex-row items-center">
|
||||||
<button
|
<button
|
||||||
on:click={upvote}
|
on:click={upvote}
|
||||||
class={node.comment_view.my_vote == 1 ? 'text-orange-500' : ''}
|
class="pr-1.5 {node.comment_view.my_vote == 1
|
||||||
|
? 'text-orange-500'
|
||||||
|
: ''}"
|
||||||
>
|
>
|
||||||
<Icon src={ArrowUp} width={16} mini />
|
<Icon src={ArrowUp} width={16} mini />
|
||||||
</button>
|
</button>
|
||||||
@@ -136,7 +138,9 @@
|
|||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
on:click={downvote}
|
on:click={downvote}
|
||||||
class={node.comment_view.my_vote == -1 ? 'text-blue-500' : ''}
|
class="pl-1.5 {node.comment_view.my_vote == -1
|
||||||
|
? 'text-blue-500'
|
||||||
|
: ''}"
|
||||||
>
|
>
|
||||||
<Icon src={ArrowDown} width={16} mini />
|
<Icon src={ArrowDown} width={16} mini />
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import MarkdownHeader from '$lib/components/markdown/MarkdownHeader.svelte'
|
import MarkdownHeader from '$lib/components/markdown/MarkdownHeader.svelte'
|
||||||
|
import MarkdownHr from '$lib/components/markdown/MarkdownHr.svelte'
|
||||||
import MarkdownLink from '$lib/components/markdown/MarkdownLink.svelte'
|
import MarkdownLink from '$lib/components/markdown/MarkdownLink.svelte'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
|
|
||||||
@@ -11,5 +12,6 @@
|
|||||||
renderers={{
|
renderers={{
|
||||||
link: MarkdownLink,
|
link: MarkdownLink,
|
||||||
heading: MarkdownHeader,
|
heading: MarkdownHeader,
|
||||||
|
hr: MarkdownHr,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<hr class="w-[90%] mx-auto my-4 opacity-80" />
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="bg-white shadow-lg border-slate-200
|
class="bg-white shadow-md border border-slate-100
|
||||||
dark:border-zinc-800 dark:bg-zinc-900 break-words
|
dark:border-zinc-800 dark:bg-zinc-900 break-words
|
||||||
flex-col p-1 rounded-md {clazz}"
|
flex-col p-1 rounded-md {clazz}"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -26,84 +26,100 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<nav
|
<nav
|
||||||
class="flex top-0 z-20 flex-row gap-4 items-center mt-2 w-full h-16
|
class="sticky bg-slate-50/70 dark:bg-zinc-950/70 backdrop-blur-3xl top-0
|
||||||
max-w-5xl mx-auto px-6"
|
z-20 mt-2"
|
||||||
>
|
>
|
||||||
<div class="flex flex-row gap-2 items-center mr-auto">
|
<div
|
||||||
<a href="/" class="flex flex-row items-center gap-2">
|
class="flex z-20 flex-row gap-4 items-center w-full h-16 max-w-5xl mx-auto px-6"
|
||||||
<Logo width={40} />
|
>
|
||||||
<div class="sm:flex flex-col hidden">
|
<div class="flex flex-row gap-2 items-center mr-auto">
|
||||||
<span class="font-bold">Xylemmy</span>
|
<a href="/" class="flex flex-row items-center gap-2">
|
||||||
<span
|
<Logo width={40} />
|
||||||
class="text-xs opacity-50
|
<div class="sm:flex flex-col hidden">
|
||||||
|
<span class="font-bold">Xylemmy</span>
|
||||||
|
<span
|
||||||
|
class="text-xs opacity-50
|
||||||
transition-opacity"
|
transition-opacity"
|
||||||
>
|
>
|
||||||
{#if $authData?.instance}
|
{#if $authData?.instance}
|
||||||
{$authData.instance}
|
{$authData.instance}
|
||||||
{:else}
|
{:else}
|
||||||
{DEFAULT_INSTANCE_URL}
|
{DEFAULT_INSTANCE_URL}
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
<Link href="/communities">
|
<Link href="/communities">
|
||||||
<Icon src={GlobeAlt} width={16} />
|
<Icon src={GlobeAlt} width={16} />
|
||||||
<span class="hidden sm:inline ml-1">Communities</span>
|
<span class="hidden sm:inline ml-1">Communities</span>
|
||||||
</Link>
|
</Link>
|
||||||
|
<Menu>
|
||||||
|
<Button color={Color.accent} slot="button">
|
||||||
|
<Icon src={Plus} width={16} />
|
||||||
|
<span class="hidden sm:inline">Create</span>
|
||||||
|
</Button>
|
||||||
|
<span class="text-xs opacity-80 text-left mx-4 my-2">Create</span>
|
||||||
|
<MenuButton link href="/create/post">
|
||||||
|
<Icon src={PencilSquare} mini width={16} />
|
||||||
|
Post
|
||||||
|
</MenuButton>
|
||||||
|
</Menu>
|
||||||
|
</div>
|
||||||
<Menu>
|
<Menu>
|
||||||
<Button color={Color.accent} slot="button">
|
<button
|
||||||
<Icon src={Plus} width={16} />
|
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100
|
||||||
<span class="hidden sm:inline">Create</span>
|
dark:bg-zinc-800 relative"
|
||||||
</Button>
|
aria-label="Profile"
|
||||||
<span class="text-xs opacity-80 text-left mx-4 my-2">Create</span>
|
slot="button"
|
||||||
<MenuButton link href="/create/post">
|
>
|
||||||
<Icon src={PencilSquare} mini width={16} />
|
{#if $user}
|
||||||
Post
|
<img
|
||||||
</MenuButton>
|
src={$user.person_view.person.avatar ??
|
||||||
|
'https://xylo.xylight.dev/img/logo-background.svg'}
|
||||||
|
alt=""
|
||||||
|
width={32}
|
||||||
|
height={32}
|
||||||
|
/>
|
||||||
|
{#if $user.unreads > 0}
|
||||||
|
<div
|
||||||
|
class="rounded-full w-2 h-2 bg-red-500 absolute top-0 left-0"
|
||||||
|
/>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
<span class="text-xs opacity-80 text-left mx-4 my-2">Profile</span>
|
||||||
|
{#if !$user}
|
||||||
|
<MenuButton link href="/login">
|
||||||
|
<Icon src={ArrowLeftOnRectangle} mini width={16} /> Log in
|
||||||
|
</MenuButton>
|
||||||
|
{:else}
|
||||||
|
<MenuButton link href="/u/{$user.person_view.person.name}">
|
||||||
|
<Icon src={UserCircle} mini width={16} /> Profile
|
||||||
|
</MenuButton>
|
||||||
|
<MenuButton link href="/inbox">
|
||||||
|
<div class="relative">
|
||||||
|
{#if $user.unreads > 0}
|
||||||
|
<div
|
||||||
|
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
|
||||||
|
/>
|
||||||
|
{/if}<Icon src={Inbox} mini width={16} />
|
||||||
|
</div>
|
||||||
|
Inbox
|
||||||
|
</MenuButton>
|
||||||
|
<MenuButton
|
||||||
|
on:click={() => {
|
||||||
|
localStorage.removeItem('user')
|
||||||
|
goto('/', {
|
||||||
|
invalidateAll: true,
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
color={Color.dangerSecondary}
|
||||||
|
>
|
||||||
|
<Icon src={ArrowRightOnRectangle} mini width={16} />Log out
|
||||||
|
</MenuButton>
|
||||||
|
{/if}
|
||||||
</Menu>
|
</Menu>
|
||||||
</div>
|
</div>
|
||||||
<Menu>
|
|
||||||
<button
|
|
||||||
class="w-8 h-8 rounded-full ring-1 ring-slate-300 bg-slate-100
|
|
||||||
dark:bg-zinc-800"
|
|
||||||
aria-label="Profile"
|
|
||||||
slot="button"
|
|
||||||
>
|
|
||||||
{#if $user}
|
|
||||||
<img
|
|
||||||
src={$user.person_view.person.avatar ??
|
|
||||||
'https://xylo.xylight.dev/img/logo-background.svg'}
|
|
||||||
alt=""
|
|
||||||
width={32}
|
|
||||||
height={32}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</button>
|
|
||||||
<span class="text-xs opacity-80 text-left mx-4 my-2">Profile</span>
|
|
||||||
{#if !$user}
|
|
||||||
<MenuButton link href="/login">
|
|
||||||
<Icon src={ArrowLeftOnRectangle} mini width={16} /> Log in
|
|
||||||
</MenuButton>
|
|
||||||
{:else}
|
|
||||||
<MenuButton link href="/u/{$user.person_view.person.name}">
|
|
||||||
<Icon src={UserCircle} mini width={16} /> Profile
|
|
||||||
</MenuButton>
|
|
||||||
<MenuButton link href="/inbox">
|
|
||||||
<Icon src={Inbox} mini width={16} /> Inbox
|
|
||||||
</MenuButton>
|
|
||||||
<MenuButton
|
|
||||||
on:click={() => {
|
|
||||||
localStorage.removeItem('user')
|
|
||||||
goto('/', {
|
|
||||||
invalidateAll: true,
|
|
||||||
})
|
|
||||||
}}
|
|
||||||
color={Color.dangerSecondary}
|
|
||||||
>
|
|
||||||
<Icon src={ArrowRightOnRectangle} mini width={16} />Log out
|
|
||||||
</MenuButton>
|
|
||||||
{/if}
|
|
||||||
</Menu>
|
|
||||||
</nav>
|
</nav>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<div
|
<div
|
||||||
class="sticky top-4 bg-white shadow-lg border-slate-200
|
class="sticky top-20 bg-white shadow-md border-slate-200
|
||||||
dark:border-zinc-800 dark:bg-zinc-900 break-words hidden lg:flex
|
dark:border-zinc-800 dark:bg-zinc-900 break-words hidden lg:flex
|
||||||
flex-col gap-4 p-8 max-w-sm rounded-md h-max max-h-[calc(100vh-2rem)] overflow-auto"
|
flex-col gap-4 p-8 max-w-sm rounded-md h-max max-h-[calc(100vh-6rem)] overflow-auto"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
+20
-2
@@ -31,8 +31,26 @@ export interface AuthData {
|
|||||||
instance: string
|
instance: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface UserData {
|
||||||
|
unreads: number
|
||||||
|
}
|
||||||
|
|
||||||
export const authData = writable<AuthData | undefined>()
|
export const authData = writable<AuthData | undefined>()
|
||||||
export const user = writable<GetPersonDetailsResponse>()
|
export const user = writable<GetPersonDetailsResponse & UserData>()
|
||||||
|
|
||||||
|
setInterval(async () => {
|
||||||
|
// check for unread messages
|
||||||
|
if (!get(authData)) return
|
||||||
|
|
||||||
|
const response = await getClient().getUnreadCount({
|
||||||
|
auth: get(authData)!.token,
|
||||||
|
})
|
||||||
|
|
||||||
|
const u = get(user)
|
||||||
|
u.unreads = response.mentions + response.private_messages + response.replies
|
||||||
|
|
||||||
|
user.set(u)
|
||||||
|
}, 60 * 1000)
|
||||||
|
|
||||||
if (typeof localStorage != 'undefined') {
|
if (typeof localStorage != 'undefined') {
|
||||||
if (localStorage.getItem('user')) {
|
if (localStorage.getItem('user')) {
|
||||||
@@ -52,7 +70,7 @@ authData.subscribe(async (data) => {
|
|||||||
username: `${data?.username}@${data?.instance}`,
|
username: `${data?.username}@${data?.instance}`,
|
||||||
})
|
})
|
||||||
|
|
||||||
user.set(person)
|
user.set({ ...person, unreads: 0 })
|
||||||
|
|
||||||
if (typeof localStorage != 'undefined') {
|
if (typeof localStorage != 'undefined') {
|
||||||
localStorage.setItem('user', JSON.stringify(data))
|
localStorage.setItem('user', JSON.stringify(data))
|
||||||
|
|||||||
@@ -92,6 +92,8 @@
|
|||||||
'My cat just invented a time machine, what do I do?',
|
'My cat just invented a time machine, what do I do?',
|
||||||
'Unpopular opinion: world peace and global happiness would be beneficial to humanity',
|
'Unpopular opinion: world peace and global happiness would be beneficial to humanity',
|
||||||
'LPT: The smaller weights are easier to lift than the bigger weights in a gym',
|
'LPT: The smaller weights are easier to lift than the bigger weights in a gym',
|
||||||
|
'javascript bad',
|
||||||
|
'ELI5: What is 4 + 8?',
|
||||||
]
|
]
|
||||||
|
|
||||||
const placeholder =
|
const placeholder =
|
||||||
@@ -123,7 +125,7 @@
|
|||||||
<title>Create post</title>
|
<title>Create post</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<Card class="p-6 max-w-xl mx-auto">
|
<Card class="p-6 max-w-2xl mx-auto">
|
||||||
<form on:submit|preventDefault={submit} class="flex flex-col gap-4">
|
<form on:submit|preventDefault={submit} class="flex flex-col gap-4">
|
||||||
<h1 class="font-bold text-xl">Create Post</h1>
|
<h1 class="font-bold text-xl">Create Post</h1>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -1,14 +1,53 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import type { CommentReplyView, PersonMentionView } from 'lemmy-js-client'
|
||||||
import InboxItem from './InboxItem.svelte'
|
import InboxItem from './InboxItem.svelte'
|
||||||
|
import Button from '$lib/components/input/Button.svelte'
|
||||||
|
import { Check, Icon } from 'svelte-hero-icons'
|
||||||
|
import { authData, getClient } from '$lib/lemmy.js'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
|
||||||
export let data
|
export let data: {
|
||||||
|
data: PersonMentionView[] | CommentReplyView[]
|
||||||
|
}
|
||||||
|
|
||||||
|
function isRead(item: PersonMentionView | CommentReplyView) {
|
||||||
|
console.log('running...')
|
||||||
|
if ('person_mention' in item) {
|
||||||
|
return (item as PersonMentionView).person_mention.read
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('comment_reply' in item) {
|
||||||
|
return (item as CommentReplyView).comment_reply.read
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
async function markAllAsRead() {
|
||||||
|
const response = await getClient().markAllAsRead({
|
||||||
|
auth: $authData!.token,
|
||||||
|
})
|
||||||
|
|
||||||
|
goto($page.url, {
|
||||||
|
invalidateAll: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
return response.replies
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Inbox</title>
|
<title>Inbox</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<h1 class="font-bold text-3xl">Inbox</h1>
|
<div class="flex flex-row justify-between">
|
||||||
|
<h1 class="font-bold text-3xl">Inbox</h1>
|
||||||
|
<Button on:click={markAllAsRead}>
|
||||||
|
<Icon src={Check} width={16} mini />
|
||||||
|
Mark all as read
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
<div class="flex flex-col gap-4 list-none my-4">
|
<div class="flex flex-col gap-4 list-none my-4">
|
||||||
{#if !data.data || (data.data?.length ?? 0) == 0}
|
{#if !data.data || (data.data?.length ?? 0) == 0}
|
||||||
<p class="text-center opacity-60 text-lg mx-4">
|
<p class="text-center opacity-60 text-lg mx-4">
|
||||||
@@ -16,7 +55,7 @@
|
|||||||
</p>
|
</p>
|
||||||
{:else}
|
{:else}
|
||||||
{#each data.data as item}
|
{#each data.data as item}
|
||||||
<InboxItem {item} />
|
<InboxItem {item} read={isRead(item)} />
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
@@ -2,15 +2,21 @@
|
|||||||
import Link from '$lib/components/input/Link.svelte'
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
import Card from '$lib/components/ui/Card.svelte'
|
import Card from '$lib/components/ui/Card.svelte'
|
||||||
import type { CommentReplyView, PersonMentionView } from 'lemmy-js-client'
|
import type {
|
||||||
|
CommentReplyView,
|
||||||
|
PersonMentionView,
|
||||||
|
PrivateMessageView,
|
||||||
|
} from 'lemmy-js-client'
|
||||||
|
|
||||||
export let item: CommentReplyView | PersonMentionView
|
export let item: CommentReplyView | PersonMentionView
|
||||||
|
export let read: boolean
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Card class="flex flex-col bg-white rounded-md p-4 max-w-full">
|
<Card class="flex flex-col bg-white rounded-md p-4 max-w-full">
|
||||||
<div class="flex flex-row items-center">
|
<div class="flex flex-row items-center">
|
||||||
<div
|
<div
|
||||||
class="text-sm max-w-[80ch] whitespace-nowrap text-ellipsis overflow-hidden"
|
class="text-sm max-w-[80ch] whitespace-nowrap text-ellipsis
|
||||||
|
overflow-hidden {read ? 'opacity-50' : ''}"
|
||||||
>
|
>
|
||||||
<span class="font-bold">
|
<span class="font-bold">
|
||||||
{item.creator.display_name ?? item.creator.name}
|
{item.creator.display_name ?? item.creator.name}
|
||||||
|
|||||||
@@ -3,13 +3,11 @@
|
|||||||
import type { Comment, CommentView } from 'lemmy-js-client'
|
import type { Comment, CommentView } from 'lemmy-js-client'
|
||||||
import type { CommentNodeI } from '$lib/components/lemmy/comment/comments.js'
|
import type { CommentNodeI } from '$lib/components/lemmy/comment/comments.js'
|
||||||
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
|
||||||
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
||||||
import { isImage, isVideo } from '$lib/ui/image.js'
|
import { isImage, isVideo } from '$lib/ui/image.js'
|
||||||
import { user } from '$lib/lemmy.js'
|
import { authData, getClient, user } from '$lib/lemmy.js'
|
||||||
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
||||||
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
||||||
import { page } from '$app/stores'
|
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import UserLink from '$lib/components/user/UserLink.svelte'
|
import UserLink from '$lib/components/user/UserLink.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
@@ -19,6 +17,16 @@
|
|||||||
const postData = data.post.post_view
|
const postData = data.post.post_view
|
||||||
const post = postData.post
|
const post = postData.post
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
if (!postData.read && $authData) {
|
||||||
|
getClient().markPostAsRead({
|
||||||
|
auth: $authData.token,
|
||||||
|
read: true,
|
||||||
|
post_id: post.id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function getCommentParentId(comment?: Comment): number | undefined {
|
function getCommentParentId(comment?: Comment): number | undefined {
|
||||||
const split = comment?.path.split('.')
|
const split = comment?.path.split('.')
|
||||||
// remove the 0
|
// remove the 0
|
||||||
|
|||||||
Reference in new issue
Block a user