i forgot whatever i've been doing, i think i added an inbox
This commit is contained in:
1 parent
ef037349f0
commit
04704749b7
24 files changed
+307
-86
No files matched your search
+26
-14
@@ -10,6 +10,12 @@ function buildUrl(inputUrl: URL): URL {
|
|||||||
return new URL(`${withoutCors}?${inputUrl.searchParams.toString()}`)
|
return new URL(`${withoutCors}?${inputUrl.searchParams.toString()}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function handleError() {
|
||||||
|
return {
|
||||||
|
message: 'The proxy failed to fetch from that URL',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export async function handle({ event, resolve }) {
|
export async function handle({ event, resolve }) {
|
||||||
// annoying hack to fix lemmy's CORS
|
// annoying hack to fix lemmy's CORS
|
||||||
if (event.url.pathname.startsWith('/cors')) {
|
if (event.url.pathname.startsWith('/cors')) {
|
||||||
@@ -27,10 +33,20 @@ export async function handle({ event, resolve }) {
|
|||||||
// @ts-ignore this works, idk why typescript complains
|
// @ts-ignore this works, idk why typescript complains
|
||||||
duplex: 'half',
|
duplex: 'half',
|
||||||
signal: AbortSignal.timeout(20 * 1000),
|
signal: AbortSignal.timeout(20 * 1000),
|
||||||
})
|
}).catch((_) => undefined)
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
return new Response(
|
||||||
|
JSON.stringify({
|
||||||
|
message: 'proxy failed to fetch',
|
||||||
|
}),
|
||||||
|
{
|
||||||
|
status: 500,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if (!data.ok) {
|
if (!data.ok) {
|
||||||
await resolve(event)
|
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
message: await data.text(),
|
message: await data.text(),
|
||||||
@@ -44,23 +60,18 @@ export async function handle({ event, resolve }) {
|
|||||||
try {
|
try {
|
||||||
const json = await data.json()
|
const json = await data.json()
|
||||||
|
|
||||||
await resolve(event)
|
|
||||||
return new Response(JSON.stringify(json), {
|
return new Response(JSON.stringify(json), {
|
||||||
status: data.status,
|
status: data.status,
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
await resolve(event)
|
console.log('Caught the thing')
|
||||||
return new Response(
|
|
||||||
JSON.stringify({
|
return new Response(JSON.stringify({ message: 'i hate everything' }), {
|
||||||
message: 'Failed to fetch',
|
status: 500,
|
||||||
}),
|
})
|
||||||
{
|
|
||||||
status: data.status,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await resolve(event)
|
console.log('caught it')
|
||||||
return new Response(
|
return new Response(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
message: 'the proxy failed to fetch from server',
|
message: 'the proxy failed to fetch from server',
|
||||||
@@ -71,6 +82,7 @@ export async function handle({ event, resolve }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await resolve(event)
|
const response = await resolve(event)
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
@@ -19,6 +19,8 @@
|
|||||||
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
||||||
import { isImage } from '$lib/ui/image.js'
|
import { isImage } from '$lib/ui/image.js'
|
||||||
import { authData, getClient } from '$lib/lemmy.js'
|
import { authData, getClient } from '$lib/lemmy.js'
|
||||||
|
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
||||||
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
|
||||||
let postRes: PostView
|
let postRes: PostView
|
||||||
export { postRes as post }
|
export { postRes as post }
|
||||||
@@ -96,55 +98,22 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row gap-2 pb-4 px-4">
|
<div class="flex flex-row gap-2 pb-4 px-4">
|
||||||
<div
|
<PostVote
|
||||||
class="flex flex-row items-center gap-1 rounded-md transition-colors cursor-pointer
|
post={postRes.post}
|
||||||
{// upvote
|
vote={postRes.my_vote}
|
||||||
vote == 1
|
score={postRes.counts.score}
|
||||||
? 'bg-orange-600/20 text-orange-500'
|
/>
|
||||||
: // downvote
|
|
||||||
vote == -1
|
|
||||||
? 'bg-blue-600/40 text-blue-400'
|
|
||||||
: // no vote
|
|
||||||
'bg-slate-100 dark:bg-zinc-800 hover:bg-slate-200 dark:hover:bg-zinc-700'}"
|
|
||||||
>
|
|
||||||
<button
|
|
||||||
aria-label="Upvote"
|
|
||||||
class="p-1 px-1.5"
|
|
||||||
on:click={() => {
|
|
||||||
vote = vote == 1 ? 0 : 1
|
|
||||||
upvote()
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon src={ChevronUp} mini width={20} height={20} />
|
|
||||||
</button>
|
|
||||||
<span class="text-sm">
|
|
||||||
{Intl.NumberFormat('en', { notation: 'compact' }).format(
|
|
||||||
postRes.counts.score
|
|
||||||
)}
|
|
||||||
</span>
|
|
||||||
<button
|
|
||||||
aria-label="Downvote"
|
|
||||||
class="p-1 px-1.5"
|
|
||||||
on:click={() => {
|
|
||||||
vote = vote == -1 ? 0 : -1
|
|
||||||
downvote()
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Icon src={ChevronDown} mini width={20} height={20} />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<a
|
<a
|
||||||
class="flex flex-row items-center gap-1 p-1.5 px-3 rounded-md
|
class="flex flex-row items-center gap-1 p-1.5 px-3 rounded-md
|
||||||
bg-slate-100 dark:bg-zinc-800 hover:bg-slate-200
|
bg-slate-100 dark:bg-zinc-900 hover:bg-slate-200
|
||||||
dark:hover:bg-zinc-700 transition-colors"
|
dark:hover:bg-zinc-700 transition-colors border border-slate-200
|
||||||
|
dark:border-zinc-800"
|
||||||
href="/post/{postRes.post.id}"
|
href="/post/{postRes.post.id}"
|
||||||
>
|
>
|
||||||
<Icon src={ChatBubbleOvalLeft} mini width={16} height={16} />
|
<Icon src={ChatBubbleOvalLeft} mini width={16} height={16} />
|
||||||
<span class="text-sm">
|
<span class="text-sm">
|
||||||
{Intl.NumberFormat('en', { notation: 'compact' }).format(
|
<FormattedNumber number={postRes.counts.comments} />
|
||||||
postRes.counts.comments
|
|
||||||
)}
|
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
|
import { authData, getClient } from '$lib/lemmy'
|
||||||
|
import type { Post } from 'lemmy-js-client'
|
||||||
|
import { ChevronDown, ChevronUp, Icon } from 'svelte-hero-icons'
|
||||||
|
|
||||||
|
export let post: Post
|
||||||
|
export let vote: number | undefined
|
||||||
|
export let score: number
|
||||||
|
|
||||||
|
async function upvote() {
|
||||||
|
if (!$authData) return
|
||||||
|
|
||||||
|
const upvoted = vote == 1
|
||||||
|
|
||||||
|
await getClient()
|
||||||
|
.likePost({
|
||||||
|
score: upvoted ? 0 : 1,
|
||||||
|
auth: $authData.token,
|
||||||
|
post_id: post.id,
|
||||||
|
})
|
||||||
|
.catch((_) => undefined)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function downvote() {
|
||||||
|
if (!$authData) return
|
||||||
|
|
||||||
|
const upvoted = vote == -1
|
||||||
|
|
||||||
|
await getClient()
|
||||||
|
.likePost({
|
||||||
|
score: upvoted ? 0 : -1,
|
||||||
|
auth: $authData.token,
|
||||||
|
post_id: post.id,
|
||||||
|
})
|
||||||
|
.catch((_) => undefined)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="flex flex-row items-center gap-1 rounded-md transition-colors
|
||||||
|
cursor-pointer border border-slate-200 dark:border-zinc-800
|
||||||
|
{// upvote
|
||||||
|
vote == 1
|
||||||
|
? 'bg-orange-600/20 text-orange-500'
|
||||||
|
: // downvote
|
||||||
|
vote == -1
|
||||||
|
? 'bg-blue-600/40 text-blue-400'
|
||||||
|
: // no vote
|
||||||
|
'bg-slate-100 dark:bg-zinc-900 hover:bg-slate-200 dark:hover:bg-zinc-700'}"
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
aria-label="Upvote"
|
||||||
|
class="p-1 px-1.5"
|
||||||
|
on:click={() => {
|
||||||
|
vote = vote == 1 ? 0 : 1
|
||||||
|
upvote()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon src={ChevronUp} mini width={20} height={20} />
|
||||||
|
</button>
|
||||||
|
<span class="text-sm">
|
||||||
|
<FormattedNumber number={score} />
|
||||||
|
</span>
|
||||||
|
<button
|
||||||
|
aria-label="Downvote"
|
||||||
|
class="p-1 px-1.5"
|
||||||
|
on:click={() => {
|
||||||
|
vote = vote == -1 ? 0 : -1
|
||||||
|
downvote()
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon src={ChevronDown} mini width={20} height={20} />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
+14
-6
@@ -7,13 +7,14 @@
|
|||||||
Minus,
|
Minus,
|
||||||
Plus,
|
Plus,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Avatar from '../../../../lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import type { CommentNodeI } from '../comments.js'
|
import type { CommentNodeI } from './comments'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
import { getClient, authData } from '$lib/lemmy.js'
|
import { getClient, authData } from '$lib/lemmy.js'
|
||||||
import { Color } from '$lib/ui/colors.js'
|
import { Color } from '$lib/ui/colors.js'
|
||||||
import CommentForm from './CommentForm.svelte'
|
import CommentForm from './CommentForm.svelte'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
|
||||||
export let node: CommentNodeI
|
export let node: CommentNodeI
|
||||||
|
|
||||||
@@ -55,7 +56,12 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<li class="py-3">
|
<li
|
||||||
|
class="py-3 {$page.url.hash == `#${node.comment_view.comment.id}`
|
||||||
|
? 'bg-slate-300 dark:bg-zinc-800'
|
||||||
|
: ''}"
|
||||||
|
id="#{node.comment_view.comment.id.toString()}"
|
||||||
|
>
|
||||||
<details bind:open class="flex flex-col gap-1">
|
<details bind:open class="flex flex-col gap-1">
|
||||||
<summary
|
<summary
|
||||||
class="flex flex-row cursor-pointer arrow gap-2 items-center group"
|
class="flex flex-row cursor-pointer arrow gap-2 items-center group"
|
||||||
@@ -66,7 +72,7 @@
|
|||||||
width={24}
|
width={24}
|
||||||
/>
|
/>
|
||||||
<span class="text-sm">{node.comment_view.creator.name}</span>
|
<span class="text-sm">{node.comment_view.creator.name}</span>
|
||||||
<span class="text-sm opacity-60">
|
<span class="text-sm opacity-60 md:inline hidden">
|
||||||
{node.comment_view.counts.score} point{node.comment_view.counts.score ==
|
{node.comment_view.counts.score} point{node.comment_view.counts.score ==
|
||||||
1
|
1
|
||||||
? ''
|
? ''
|
||||||
@@ -139,12 +145,14 @@
|
|||||||
{postId}
|
{postId}
|
||||||
parentId={node.comment_view.comment.id}
|
parentId={node.comment_view.comment.id}
|
||||||
on:comment={(e) => {
|
on:comment={(e) => {
|
||||||
node.children.unshift(e.detail)
|
node.children = [e.detail, ...node.children]
|
||||||
replying = false
|
replying = false
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<slot />
|
<div class="bg-transparent dark:bg-transparent">
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
</details>
|
</details>
|
||||||
</li>
|
</li>
|
||||||
+1
-1
@@ -50,7 +50,7 @@
|
|||||||
focus:dark:border-white transition-colors rounded-md"
|
focus:dark:border-white transition-colors rounded-md"
|
||||||
bind:value={newComment}
|
bind:value={newComment}
|
||||||
/>
|
/>
|
||||||
<div class="w-24 ml-auto">
|
<div class="w-24 ml-auto flex flex-row gap-2">
|
||||||
<Button
|
<Button
|
||||||
large
|
large
|
||||||
on:click={submit}
|
on:click={submit}
|
||||||
+11
-1
@@ -1,13 +1,23 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Comment from './Comment.svelte'
|
import Comment from './Comment.svelte'
|
||||||
import type { CommentNodeI } from '../comments.js'
|
import type { CommentNodeI } from './comments'
|
||||||
import type { Post } from 'lemmy-js-client'
|
import type { Post } from 'lemmy-js-client'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
const maxComments = 250
|
const maxComments = 250
|
||||||
|
|
||||||
export let nodes: CommentNodeI[]
|
export let nodes: CommentNodeI[]
|
||||||
export let isParent: boolean
|
export let isParent: boolean
|
||||||
export let post: Post
|
export let post: Post
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (isParent && $page.url.hash) {
|
||||||
|
document.getElementById($page.url.hash)?.scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<ul
|
<ul
|
||||||
File renamed without changes.
@@ -6,7 +6,7 @@
|
|||||||
<div
|
<div
|
||||||
class="bg-white border border-slate-200
|
class="bg-white border border-slate-200
|
||||||
dark:border-zinc-800 dark:bg-zinc-900 break-words
|
dark:border-zinc-800 dark:bg-zinc-900 break-words
|
||||||
flex-col gap-4 p-4 max-w-lg rounded-md {clazz}"
|
flex-col gap-4 p-4 rounded-md {clazz}"
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
ArrowRightOnRectangle,
|
ArrowRightOnRectangle,
|
||||||
Cog6Tooth,
|
Cog6Tooth,
|
||||||
Icon,
|
Icon,
|
||||||
|
Inbox,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -64,6 +65,9 @@
|
|||||||
<Icon src={ArrowLeftOnRectangle} mini width={16} /> Log in
|
<Icon src={ArrowLeftOnRectangle} mini width={16} /> Log in
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{:else}
|
{:else}
|
||||||
|
<MenuButton link href="/inbox">
|
||||||
|
<Icon src={Inbox} mini width={16} /> Inbox
|
||||||
|
</MenuButton>
|
||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
localStorage.removeItem('user')
|
localStorage.removeItem('user')
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
{top ? 'bottom-[100%] origin-bottom-left' : 'top-[100%]'}
|
{top ? 'bottom-[100%] origin-bottom-left' : 'top-[100%]'}
|
||||||
rounded-md py-2 min-w-[16rem] my-2 flex flex-col shadow-lg {itemsClass
|
rounded-md py-2 min-w-[16rem] my-2 flex flex-col shadow-lg {itemsClass
|
||||||
? itemsClass
|
? itemsClass
|
||||||
: 'bg-white dark:bg-zinc-900'}"
|
: 'bg-white dark:bg-zinc-900 border border-slate-200 dark:border-zinc-800'}"
|
||||||
>
|
>
|
||||||
{#if open}
|
{#if open}
|
||||||
<slot />
|
<slot />
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ import {
|
|||||||
import { get, writable } from 'svelte/store'
|
import { get, writable } from 'svelte/store'
|
||||||
import { PUBLIC_PROXY_URL } from '$env/static/public'
|
import { PUBLIC_PROXY_URL } from '$env/static/public'
|
||||||
|
|
||||||
export const DEFAULT_INSTANCE_URL = 'lemmy.world'
|
export const DEFAULT_INSTANCE_URL = 'lemm.ee'
|
||||||
export let instance_url = writable(DEFAULT_INSTANCE_URL)
|
export let instance_url = writable(DEFAULT_INSTANCE_URL)
|
||||||
|
|
||||||
export function getClient(instance?: string): LemmyHttp {
|
export function getClient(instance?: string): LemmyHttp {
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import type {
|
||||||
|
CommentReplyView,
|
||||||
|
PersonMentionView,
|
||||||
|
PrivateMessageView,
|
||||||
|
} from 'lemmy-js-client'
|
||||||
|
|
||||||
|
export type InboxItemView =
|
||||||
|
| PersonMentionView
|
||||||
|
| CommentReplyView
|
||||||
|
| PrivateMessageView
|
||||||
|
|
||||||
|
export function getInboxItemPublished(item: InboxItemView): string {
|
||||||
|
if ('comment_reply' in item) {
|
||||||
|
return item.comment_reply.published
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('private_message' in item) {
|
||||||
|
return item.private_message.published
|
||||||
|
}
|
||||||
|
|
||||||
|
return item.person_mention.published
|
||||||
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
import Link from '$lib/components/input/Link.svelte'
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
import { addToast } from '$lib/components/ui/toasts/toasts.js'
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col mx-auto gap-4 justify-center items-center">
|
<div class="flex flex-col mx-auto gap-4 justify-center items-center">
|
||||||
@@ -10,7 +9,7 @@
|
|||||||
Failed to fetch page. The lemmy servers are having quite a lot of issues
|
Failed to fetch page. The lemmy servers are having quite a lot of issues
|
||||||
right now, this is likely on their end.
|
right now, this is likely on their end.
|
||||||
</p>
|
</p>
|
||||||
<code class="bg-zinc-800 px-2 py-1 rounded-md">
|
<code class="bg-slate-100 dark:bg-zinc-800 px-2 py-1 rounded-md">
|
||||||
{JSON.stringify($page.error)}
|
{JSON.stringify($page.error)}
|
||||||
</code>
|
</code>
|
||||||
<Link href={$page.url.toString()}>Retry</Link>
|
<Link href={$page.url.toString()}>Retry</Link>
|
||||||
|
|||||||
@@ -14,8 +14,8 @@
|
|||||||
PencilSquare,
|
PencilSquare,
|
||||||
UserGroup,
|
UserGroup,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
import Avatar from '../lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import Post from './post/[id]/Post.svelte'
|
import Post from '$lib/components/lemmy/Post.svelte'
|
||||||
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
|
||||||
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
import Markdown from '$lib/components/markdown/Markdown.svelte'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import { authData, getClient } from '$lib/lemmy.js'
|
|||||||
import type { ListingType, SortType } from 'lemmy-js-client'
|
import type { ListingType, SortType } from 'lemmy-js-client'
|
||||||
import { get } from 'svelte/store'
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
export async function load({ url }) {
|
export async function load({ url, params }) {
|
||||||
const page = Number(url.searchParams.get('page') || 1) || 1
|
const page = Number(url.searchParams.get('page') || 1) || 1
|
||||||
|
|
||||||
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'Active'
|
const sort: SortType = (url.searchParams.get('sort') as SortType) || 'Active'
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
import Avatar from '../../../lib/components/ui/Avatar.svelte'
|
import Avatar from '../../../lib/components/ui/Avatar.svelte'
|
||||||
import Post from '../../post/[id]/Post.svelte'
|
import Post from '../../../lib/components/lemmy/Post.svelte'
|
||||||
import { goto } from '$app/navigation'
|
import { goto } from '$app/navigation'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ export function load(req: any) {
|
|||||||
(req.url.searchParams.get('sort') as SortType) || 'Active'
|
(req.url.searchParams.get('sort') as SortType) || 'Active'
|
||||||
|
|
||||||
return {
|
return {
|
||||||
posts: getClient().getPosts({
|
posts: getClient(req.params).getPosts({
|
||||||
limit: 40,
|
limit: 40,
|
||||||
community_name: req.params.name,
|
community_name: req.params.name,
|
||||||
page: page,
|
page: page,
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import InboxItem from './InboxItem.svelte'
|
||||||
|
|
||||||
|
export let data
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 class="font-bold text-3xl">Inbox</h1>
|
||||||
|
<div class="flex flex-col gap-4 list-none my-4">
|
||||||
|
{#if !data.data || (data.data?.length ?? 0) == 0}
|
||||||
|
<p class="text-center opacity-60 text-lg mx-4">
|
||||||
|
Wow, it's quite empty in here.
|
||||||
|
</p>
|
||||||
|
{:else}
|
||||||
|
{#each data.data as item}
|
||||||
|
<InboxItem {item} />
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { authData, getClient } from '$lib/lemmy.js'
|
||||||
|
import { getInboxItemPublished } from '$lib/lemmy/inbox.js'
|
||||||
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
|
export async function load() {
|
||||||
|
const auth = get(authData)
|
||||||
|
if (!auth) return
|
||||||
|
|
||||||
|
const client = getClient()
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
limit: 50,
|
||||||
|
page: 1,
|
||||||
|
auth: auth.token,
|
||||||
|
}
|
||||||
|
|
||||||
|
const [replies, mentions, privateMessages] = await Promise.all([
|
||||||
|
client.getReplies({
|
||||||
|
...params,
|
||||||
|
sort: 'New',
|
||||||
|
}),
|
||||||
|
client.getPersonMentions({
|
||||||
|
...params,
|
||||||
|
sort: 'New',
|
||||||
|
}),
|
||||||
|
client.getPrivateMessages(params),
|
||||||
|
])
|
||||||
|
|
||||||
|
const data = [...replies.replies, ...mentions.mentions].sort(
|
||||||
|
(a, b) =>
|
||||||
|
Date.parse(getInboxItemPublished(b)) -
|
||||||
|
Date.parse(getInboxItemPublished(a))
|
||||||
|
)
|
||||||
|
|
||||||
|
return { data: data }
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Link from '$lib/components/input/Link.svelte'
|
||||||
|
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
|
||||||
|
import Card from '$lib/components/ui/Card.svelte'
|
||||||
|
import type { CommentReplyView, PersonMentionView } from 'lemmy-js-client'
|
||||||
|
|
||||||
|
export let item: CommentReplyView | PersonMentionView
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Card class="flex flex-col bg-white rounded-md p-4 max-w-full">
|
||||||
|
<div class="flex flex-row items-center">
|
||||||
|
<div
|
||||||
|
class="text-sm max-w-[80ch] whitespace-nowrap text-ellipsis overflow-hidden"
|
||||||
|
>
|
||||||
|
<span class="font-bold">
|
||||||
|
{item.creator.display_name ?? item.creator.name}
|
||||||
|
</span>
|
||||||
|
replied to you in
|
||||||
|
<a
|
||||||
|
href="/post/{item.post.id}"
|
||||||
|
class="font-bold max-w-[48ch] overflow-hidden text-ellipsis
|
||||||
|
whitespace-nowrap inline hover:underline"
|
||||||
|
>
|
||||||
|
{item.post.name}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="w-max ml-auto">
|
||||||
|
<Link href="/post/{item.post.id}#{item.comment.id}">Jump</Link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Comment
|
||||||
|
postId={item.post.id}
|
||||||
|
node={{ children: [], comment_view: item, depth: 1 }}
|
||||||
|
replying={false}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { DEFAULT_INSTANCE_URL, authData } from '$lib/lemmy.js'
|
||||||
|
import { error, redirect } from '@sveltejs/kit'
|
||||||
|
import { get } from 'svelte/store'
|
||||||
|
|
||||||
|
export function load({ params, url }) {
|
||||||
|
if (Number(params.instance)) {
|
||||||
|
const split = url.pathname.split('/')
|
||||||
|
|
||||||
|
split.splice(2, 0, `${get(authData)?.instance ?? DEFAULT_INSTANCE_URL}`)
|
||||||
|
|
||||||
|
const newUrl = new URL(url)
|
||||||
|
newUrl.pathname = split.join('/')
|
||||||
|
|
||||||
|
throw redirect(300, newUrl.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error(404, 'Not found')
|
||||||
|
}
|
||||||
@@ -1,18 +1,16 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
import MultiSelect from '$lib/components/input/MultiSelect.svelte'
|
||||||
import type {
|
import type { Comment, CommentView } from 'lemmy-js-client'
|
||||||
GetCommentsResponse,
|
import type { CommentNodeI } from '$lib/components/lemmy/comment/comments.js'
|
||||||
GetPostResponse,
|
import Comments from '$lib/components/lemmy/comment/Comments.svelte'
|
||||||
Comment,
|
|
||||||
CommentView,
|
|
||||||
} from 'lemmy-js-client'
|
|
||||||
import type { CommentNodeI } from './comments.js'
|
|
||||||
import Comments from './comment/Comments.svelte'
|
|
||||||
import SvelteMarkdown from 'svelte-markdown'
|
import SvelteMarkdown from 'svelte-markdown'
|
||||||
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
import CommunityLink from '$lib/components/community/CommunityLink.svelte'
|
||||||
import { isImage } from '$lib/ui/image.js'
|
import { isImage } from '$lib/ui/image.js'
|
||||||
import { user } from '$lib/lemmy.js'
|
import { user } from '$lib/lemmy.js'
|
||||||
import CommentForm from './comment/CommentForm.svelte'
|
import CommentForm from '$lib/components/lemmy/comment/CommentForm.svelte'
|
||||||
|
import PostVote from '$lib/components/lemmy/PostVote.svelte'
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -117,6 +115,13 @@
|
|||||||
<SvelteMarkdown source={post.body} />
|
<SvelteMarkdown source={post.body} />
|
||||||
</p>
|
</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="w-max">
|
||||||
|
<PostVote
|
||||||
|
post={data.post.post_view.post}
|
||||||
|
score={data.post.post_view.counts.score}
|
||||||
|
vote={data.post.post_view.my_vote}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-4 flex flex-col gap-2">
|
<div class="mt-4 flex flex-col gap-2">
|
||||||
<div class="font-bold text-lg">
|
<div class="font-bold text-lg">
|
||||||
@@ -141,7 +146,8 @@
|
|||||||
{#if $user}
|
{#if $user}
|
||||||
<CommentForm
|
<CommentForm
|
||||||
postId={post.id}
|
postId={post.id}
|
||||||
on:comment={(comment) => comments.comments.unshift(comment.detail)}
|
on:comment={(comment) =>
|
||||||
|
(comments.comments = [...comment.detail, comments.comments])}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
<MultiSelect
|
<MultiSelect
|
||||||
@@ -3,12 +3,12 @@ import { get } from 'svelte/store'
|
|||||||
|
|
||||||
export async function load({ params }) {
|
export async function load({ params }) {
|
||||||
return {
|
return {
|
||||||
post: getClient().getPost({
|
post: getClient(params.instance).getPost({
|
||||||
id: Number(params.id),
|
id: Number(params.id),
|
||||||
auth: get(authData)?.token,
|
auth: get(authData)?.token,
|
||||||
}),
|
}),
|
||||||
streamed: {
|
streamed: {
|
||||||
comments: getClient().getComments({
|
comments: getClient(params.instance).getComments({
|
||||||
post_id: Number(params.id),
|
post_id: Number(params.id),
|
||||||
type_: 'All',
|
type_: 'All',
|
||||||
limit: 250,
|
limit: 250,
|
||||||
@@ -26,6 +26,11 @@ pre {
|
|||||||
border-slate-200 border dark:bg-zinc-900 dark:border-zinc-800 text-sm;
|
border-slate-200 border dark:bg-zinc-900 dark:border-zinc-800 text-sm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
code {
|
||||||
|
@apply bg-slate-200 border border-slate-300 dark:bg-zinc-800
|
||||||
|
dark:border-zinc-700 rounded-md px-1 py-0.5;
|
||||||
|
}
|
||||||
|
|
||||||
ol {
|
ol {
|
||||||
@apply list-decimal;
|
@apply list-decimal;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user