feat: add community name in crosspost draft

This commit is contained in:
Xyphyn committed 2023-10-07 18:56:41 -07:00
1 parent 4fbf0a876b
commit de8a01e522
4 files changed
+60 -60

No files matched your search

-5
View File
@@ -5,11 +5,6 @@
<link rel="icon" href="%sveltekit.assets%/img/logo-background.svg" /> <link rel="icon" href="%sveltekit.assets%/img/logo-background.svg" />
<link rel="manifest" href="/manifest.json" /> <link rel="manifest" href="/manifest.json" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta
name="description"
content="Photon: An alternative lemmy client with a sleek design."
/>
<meta name="keywords" content="lemmy, client" />
<script defer type=""> <script defer type="">
const dark = () => const dark = () =>
localStorage.theme == 'dark' || localStorage.theme == 'dark' ||
@@ -185,7 +185,9 @@
<MenuButton <MenuButton
on:click={() => { on:click={() => {
setSessionStorage('postDraft', { setSessionStorage('postDraft', {
body: `cross-posted from: ${post.post.ap_id}\n${ body: `cross-posted from: ${post.post.ap_id} (!${
post.community.name
}@${new URL(post.community.actor_id).hostname})\n${
post.post.body post.post.body
? '>' + post.post.body.split('\n').join('\n> ') ? '>' + post.post.body.split('\n').join('\n> ')
: '' : ''
+4
View File
@@ -14,6 +14,10 @@
name="og:description" name="og:description"
content={data.community.community_view.community.description} content={data.community.community_view.community.description}
/> />
<meta
name="description"
content={data.community.community_view.community.description}
/>
{/if} {/if}
</svelte:head> </svelte:head>
<slot /> <slot />
@@ -43,24 +43,18 @@
export let data export let data
let post = data.post $: ({ post_view } = data.post)
onMount(async () => { onMount(async () => {
if ( if (!(post_view.read && $userSettings.markPostsAsRead) && $profile?.jwt) {
!(post.post_view.read && $userSettings.markPostsAsRead) &&
$profile?.jwt
) {
getClient().markPostAsRead({ getClient().markPostAsRead({
read: $userSettings.markPostsAsRead, read: $userSettings.markPostsAsRead,
post_id: post.post_view.post.id, post_id: post_view.post.id,
}) })
} }
}) })
afterNavigate(async () => { afterNavigate(async () => {
// reactivity hack
post = data.post
if ($page.params.instance.toLowerCase() != $instance.toLowerCase()) { if ($page.params.instance.toLowerCase() != $instance.toLowerCase()) {
if (!$profile?.jwt) return if (!$profile?.jwt) return
toast({ toast({
@@ -81,7 +75,7 @@
try { try {
const res = await getClient().resolveObject({ const res = await getClient().resolveObject({
q: post.post_view.post.ap_id, q: post_view.post.ap_id,
}) })
if (res.post) { if (res.post) {
@@ -108,9 +102,9 @@
page: 1, page: 1,
limit: 25, limit: 25,
type_: 'All', type_: 'All',
post_id: post.post_view.post.id, post_id: post_view.post.id,
sort: commentSort, sort: commentSort,
max_depth: data.post.post_view.counts.comments > 100 ? 1 : 3, max_depth: post_view.counts.comments > 100 ? 1 : 3,
}) })
} }
@@ -118,14 +112,19 @@
</script> </script>
<svelte:head> <svelte:head>
<title>{post.post_view.post.name}</title> <title>{post_view.post.name}</title>
<meta property="og:title" content={post.post_view.post.name} /> <meta property="og:title" content={post_view.post.name} />
<meta property="og:url" content={$page.url.toString()} /> <meta property="og:url" content={$page.url.toString()} />
{#if isImage(post.post_view.post.url)} {#if post_view.post.thumbnail_url}
<meta property="og:image" content={post.post_view.post.url} /> <meta
property="og:image"
itemprop="image"
content={post_view.post.thumbnail_url}
/>
{/if} {/if}
{#if post.post_view.post.body} {#if post_view.post.body}
<meta property="og:description" content={post.post_view.post.body} /> <meta property="og:description" content={post_view.post.body} />
<meta property="description" content={post_view.post.body} />
{/if} {/if}
</svelte:head> </svelte:head>
@@ -152,19 +151,19 @@
<div class="flex flex-row justify-between items-center gap-2 flex-wrap"> <div class="flex flex-row justify-between items-center gap-2 flex-wrap">
<div class="w-max"> <div class="w-max">
<PostMeta <PostMeta
community={post.post_view.community} community={post_view.community}
user={post.post_view.creator} user={post_view.creator}
bind:subscribed={post.community_view.subscribed} bind:subscribed={post_view.subscribed}
upvotes={post.post_view.counts.upvotes} upvotes={post_view.counts.upvotes}
downvotes={post.post_view.counts.downvotes} downvotes={post_view.counts.downvotes}
deleted={post.post_view.post.deleted} deleted={post_view.post.deleted}
removed={post.post_view.post.removed} removed={post_view.post.removed}
locked={post.post_view.post.locked} locked={post_view.post.locked}
featured={post.post_view.post.featured_community || featured={post_view.post.featured_community ||
post.post_view.post.featured_local} post_view.post.featured_local}
nsfw={post.post_view.post.nsfw} nsfw={post_view.post.nsfw}
published={publishedToDate(post.post_view.post.published)} published={publishedToDate(post_view.post.published)}
saved={post.post_view.saved} saved={post_view.saved}
/> />
</div> </div>
<Button on:click={() => history.back()} size="square-md"> <Button on:click={() => history.back()} size="square-md">
@@ -172,37 +171,37 @@
</Button> </Button>
</div> </div>
<h1 class="font-bold text-lg"> <h1 class="font-bold text-lg">
<Markdown source={post.post_view.post.name} inline /> <Markdown source={post_view.post.name} inline />
</h1> </h1>
{#if isImage(post.post_view.post.url)} {#if isImage(post_view.post.url)}
<img <img
src={post.post_view.post.url} src={post_view.post.url}
alt={post.post_view.post.name} alt={post_view.post.name}
class="rounded-md max-w-screen max-h-[80svh] mx-auto" class="rounded-md max-w-screen max-h-[80svh] mx-auto"
/> />
{:else if isVideo(post.post_view.post.url)} {:else if isVideo(post_view.post.url)}
<!-- svelte-ignore a11y-media-has-caption --> <!-- svelte-ignore a11y-media-has-caption -->
<video class="rounded-md max-w-screen max-h-[80svh] mx-auto" controls> <video class="rounded-md max-w-screen max-h-[80svh] mx-auto" controls>
<source src={post.post_view.post.url} /> <source src={post_view.post.url} />
</video> </video>
{:else if post.post_view.post.url} {:else if post_view.post.url}
<PostLink <PostLink
url={post.post_view.post.url} url={post_view.post.url}
embed_description={post.post_view.post.embed_description} embed_description={post_view.post.embed_description}
embed_title={post.post_view.post.embed_title} embed_title={post_view.post.embed_title}
thumbnail_url={post.post_view.post.thumbnail_url} thumbnail_url={post_view.post.thumbnail_url}
/> />
{/if} {/if}
{#if post.post_view.post.body} {#if post_view.post.body}
<div <div
class="text-sm text-slate-800 dark:text-zinc-300 rounded-md leading-[22px]" class="text-sm text-slate-800 dark:text-zinc-300 rounded-md leading-[22px]"
> >
<Markdown source={post.post_view.post.body} /> <Markdown source={post_view.post.body} />
</div> </div>
{/if} {/if}
<div class="w-full relative"> <div class="w-full relative">
<PostActions <PostActions
bind:post={post.post_view} bind:post={post_view}
on:edit={() => on:edit={() =>
toast({ toast({
content: 'The post was edited successfully.', content: 'The post was edited successfully.',
@@ -210,22 +209,22 @@
})} })}
/> />
</div> </div>
{#if post.cross_posts?.length > 0} {#if data.post.cross_posts?.length > 0}
<details <details
class="text-sm font-bold mt-2 w-full cursor-pointer" class="text-sm font-bold mt-2 w-full cursor-pointer"
open={post.cross_posts?.length <= 3} open={data.post.cross_posts?.length <= 3}
> >
<summary class="inline-block w-full"> <summary class="inline-block w-full">
<SectionTitle class="text-inherit dark:text-inherit"> <SectionTitle class="text-inherit dark:text-inherit">
Crossposts <span Crossposts <span
class="text-slate-600 dark:text-zinc-400 text-xs ml-1" class="text-slate-600 dark:text-zinc-400 text-xs ml-1"
> >
{post.cross_posts.length} {data.post.cross_posts.length}
</span> </span>
</SectionTitle> </SectionTitle>
</summary> </summary>
<div class="divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col"> <div class="divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col">
{#each post.cross_posts as crosspost} {#each data.post.cross_posts as crosspost}
<div class="py-2.5 flex flex-col gap-1"> <div class="py-2.5 flex flex-col gap-1">
<span class="text-xs flex flex-col pointer-events-none"> <span class="text-xs flex flex-col pointer-events-none">
<CommunityLink <CommunityLink
@@ -265,7 +264,7 @@
color="blue-subtle" color="blue-subtle"
class="min-w-[1rem] justify-center !font-bold" class="min-w-[1rem] justify-center !font-bold"
> >
<FormattedNumber number={post.post_view.counts.comments} /> <FormattedNumber number={post_view.counts.comments} />
</Badge> </Badge>
</div> </div>
<div class="gap-2 flex items-center h-8"> <div class="gap-2 flex items-center h-8">
@@ -296,13 +295,13 @@
{#if $profile?.user} {#if $profile?.user}
{#if showCreateComment} {#if showCreateComment}
<CommentForm <CommentForm
postId={post.post_view.post.id} postId={post_view.post.id}
on:comment={(comment) => on:comment={(comment) =>
(comments.comments = [ (comments.comments = [
comment.detail.comment_view, comment.detail.comment_view,
...comments.comments, ...comments.comments,
])} ])}
locked={post.post_view.post.locked || locked={post_view.post.locked ||
$page.params.instance.toLowerCase() != $instance.toLowerCase()} $page.params.instance.toLowerCase() != $instance.toLowerCase()}
/> />
{:else} {:else}
@@ -322,10 +321,10 @@
<Spinner width={36} /> <Spinner width={36} />
</div> </div>
{:then comments} {:then comments}
<Comments post={post.post_view.post} nodes={comments} isParent={true} /> <Comments post={post_view.post} nodes={comments} isParent={true} />
{#if comments.length > 5} {#if comments.length > 5}
<EndPlaceholder> <EndPlaceholder>
You've viewed {post.post_view.counts.comments} comments. You've viewed {post_view.counts.comments} comments.
<Button <Button
color="tertiary" color="tertiary"