feat: copy link action for comments (#56)

This adds a comment link action to each comment action menu so that
users can link directly to a comment.  It uses the existing single
thread view mechanism to display the single command (and its children).
This commit is contained in:
Peter Bui authored and GitHub committed 2023-08-01 18:42:10 -07:00
1 parent 2f8e39b884
commit 8d6135a8fb
1 file changed
+13 -1
@@ -1,6 +1,7 @@
<script lang="ts"> <script lang="ts">
import type { CommentView } from 'lemmy-js-client' import type { CommentView } from 'lemmy-js-client'
import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte' import CommentVote from '$lib/components/lemmy/comment/CommentVote.svelte'
import { page } from '$app/stores'
import { userSettings } from '$lib/settings.js' import { userSettings } from '$lib/settings.js'
import { Color } from '$lib/ui/colors.js' import { Color } from '$lib/ui/colors.js'
import { import {
@@ -13,9 +14,10 @@
Flag, Flag,
Icon, Icon,
PencilSquare, PencilSquare,
Square2Stack,
Trash, Trash,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import { getClient } from '$lib/lemmy.js' import { getClient, getInstance } from '$lib/lemmy.js'
import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js' import { ToastType, toast } from '$lib/components/ui/toasts/toasts.js'
import Menu from '$lib/components/ui/menu/Menu.svelte' import Menu from '$lib/components/ui/menu/Menu.svelte'
import MenuButton from '$lib/components/ui/menu/MenuButton.svelte' import MenuButton from '$lib/components/ui/menu/MenuButton.svelte'
@@ -90,6 +92,16 @@
<Icon src={EllipsisHorizontal} width={16} height={16} mini slot="icon" /> <Icon src={EllipsisHorizontal} width={16} height={16} mini slot="icon" />
</Button> </Button>
<span class="text-xs opacity-80 py-1 my-1 px-4">Comment actions</span> <span class="text-xs opacity-80 py-1 my-1 px-4">Comment actions</span>
<MenuButton
on:click={() => {
navigator.clipboard.writeText(
`${$page.url.origin}/post/${getInstance()}/${comment.post.id}?thread=${comment.comment.path}#${comment.comment.id}`
)
}}
>
<Icon src={Square2Stack} mini size="16" />
<span>Copy Link</span>
</MenuButton>
{#if $profile?.jwt} {#if $profile?.jwt}
{#if comment.creator.id == $profile.user?.local_user_view.person.id} {#if comment.creator.id == $profile.user?.local_user_view.person.id}
<MenuButton on:click={() => dispatcher('edit', comment)}> <MenuButton on:click={() => dispatcher('edit', comment)}>