feat: add crossposting
This commit is contained in:
1 parent
1168338458
commit
e02abec9d0
5 files changed
+45
-5
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "0.9.20",
|
"version": "0.9.21",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import PostVote from './PostVote.svelte'
|
import PostVote from './PostVote.svelte'
|
||||||
import { getClient, getInstance } from '$lib/lemmy.js'
|
import { getClient, getInstance } from '$lib/lemmy.js'
|
||||||
import {
|
import {
|
||||||
|
ArrowTopRightOnSquare,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
BookmarkSlash,
|
BookmarkSlash,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
@@ -34,6 +35,8 @@
|
|||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
import Spinner from '$lib/components/ui/loader/Spinner.svelte'
|
||||||
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
|
import { deleteItem, markAsRead, save } from '$lib/lemmy/contentview.js'
|
||||||
|
import { setSessionStorage } from '$lib/session.js'
|
||||||
|
import { goto } from '$app/navigation'
|
||||||
|
|
||||||
export let post: PostView
|
export let post: PostView
|
||||||
|
|
||||||
@@ -94,7 +97,11 @@
|
|||||||
{#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))}
|
{#if $profile?.user && (amMod($profile.user, post.community) || isAdmin($profile.user))}
|
||||||
<ModerationMenu bind:item={post} community={post.community} />
|
<ModerationMenu bind:item={post} community={post.community} />
|
||||||
{/if}
|
{/if}
|
||||||
<Menu alignment="bottom-right" class="overflow-auto" let:toggleOpen>
|
<Menu
|
||||||
|
alignment="bottom-right"
|
||||||
|
containerClass="overflow-auto max-h-[400px]"
|
||||||
|
let:toggleOpen
|
||||||
|
>
|
||||||
<Button
|
<Button
|
||||||
slot="button"
|
slot="button"
|
||||||
aria-label="Post actions"
|
aria-label="Post actions"
|
||||||
@@ -122,12 +129,14 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
<hr class="w-[90%] mx-auto opacity-100 dark:opacity-10 my-2" />
|
<hr class="w-[90%] mx-auto opacity-100 dark:opacity-10 my-2" />
|
||||||
<li class="mx-4 text-xs opacity-80 text-left my-1 py-1">Actions</li>
|
<li class="mx-4 text-xs opacity-80 text-left my-1 py-1">Actions</li>
|
||||||
{#if $profile?.user && $profile.user.local_user_view.person.id == post.creator.id}
|
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
||||||
<MenuButton on:click={() => (editing = true)}>
|
<MenuButton on:click={() => (editing = true)}>
|
||||||
<Icon src={PencilSquare} width={16} mini />
|
<Icon src={PencilSquare} width={16} mini />
|
||||||
Edit
|
Edit
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}<MenuButton
|
{/if}
|
||||||
|
{#if $profile?.jwt}
|
||||||
|
<MenuButton
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
if ($profile?.jwt)
|
if ($profile?.jwt)
|
||||||
post.read = await markAsRead(post.post, !post.read, $profile.jwt)
|
post.read = await markAsRead(post.post, !post.read, $profile.jwt)
|
||||||
@@ -136,6 +145,7 @@
|
|||||||
<Icon src={post.read ? EyeSlash : Eye} width={16} mini />
|
<Icon src={post.read ? EyeSlash : Eye} width={16} mini />
|
||||||
Mark as {post.read ? 'Unread' : 'Read'}
|
Mark as {post.read ? 'Unread' : 'Read'}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
{/if}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={() =>
|
on:click={() =>
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
@@ -155,6 +165,28 @@
|
|||||||
<Icon src={post.saved ? BookmarkSlash : Bookmark} width={16} mini />
|
<Icon src={post.saved ? BookmarkSlash : Bookmark} width={16} mini />
|
||||||
{post.saved ? 'Unsave' : 'Save'}
|
{post.saved ? 'Unsave' : 'Save'}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
|
<MenuButton
|
||||||
|
on:click={() => {
|
||||||
|
setSessionStorage('postDraft', {
|
||||||
|
body: `cross-posted from: ${post.post.ap_id}\n${
|
||||||
|
post.post.body
|
||||||
|
? '>' + post.post.body.split('\n').join('\n> ')
|
||||||
|
: ''
|
||||||
|
}`,
|
||||||
|
url: post.post.url,
|
||||||
|
title: post.post.name,
|
||||||
|
loading: false,
|
||||||
|
nsfw: post.post.nsfw,
|
||||||
|
community: null,
|
||||||
|
image: null,
|
||||||
|
})
|
||||||
|
|
||||||
|
goto('/create/post?crosspost=true')
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Icon src={ArrowTopRightOnSquare} width={16} mini />
|
||||||
|
Crosspost
|
||||||
|
</MenuButton>
|
||||||
{#if $profile.user && post.creator.id == $profile.user.local_user_view.person.id}
|
{#if $profile.user && post.creator.id == $profile.user.local_user_view.person.id}
|
||||||
<MenuButton
|
<MenuButton
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
}
|
}
|
||||||
| undefined = undefined
|
| undefined = undefined
|
||||||
|
|
||||||
let data: {
|
export let data: {
|
||||||
community: number | null
|
community: number | null
|
||||||
title: string
|
title: string
|
||||||
body: string
|
body: string
|
||||||
|
|||||||
@@ -6,6 +6,8 @@
|
|||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
|
||||||
|
|
||||||
|
export let data
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (!$profile?.jwt) {
|
if (!$profile?.jwt) {
|
||||||
goto('/login')
|
goto('/login')
|
||||||
@@ -17,6 +19,8 @@
|
|||||||
| undefined
|
| undefined
|
||||||
|
|
||||||
setSessionStorage('lastSeenCommunity', undefined)
|
setSessionStorage('lastSeenCommunity', undefined)
|
||||||
|
|
||||||
|
let draft = getSessionStorage('postDraft') as any
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@@ -25,6 +29,7 @@
|
|||||||
|
|
||||||
<div class="w-full max-w-5xl mx-auto h-full">
|
<div class="w-full max-w-5xl mx-auto h-full">
|
||||||
<PostForm
|
<PostForm
|
||||||
|
data={data.crosspost ? draft : undefined}
|
||||||
passedCommunity={community}
|
passedCommunity={community}
|
||||||
on:submit={(e) => goto(`/post/${e.detail.post.id}`)}
|
on:submit={(e) => goto(`/post/${e.detail.post.id}`)}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
export const load = ({ url }) => ({
|
||||||
|
crosspost: Boolean(url.searchParams.get('crosspost')) ?? false,
|
||||||
|
})
|
||||||
Reference in new issue
Block a user