fix: prevent authors from reacting to their pas6te

This commit is contained in:
2026-04-24 22:01:56 -04:00
parent 77f6623fcf
commit 3da7f99feb
+22 -21
View File
@@ -366,7 +366,7 @@
}
async function reactToPaste(target: 1 | 2) {
if (!data?.paste || reactingToPaste) return;
if (!data?.paste || reactingToPaste || $user?.uuid === data.paste.author?.uuid) return;
const token = getToken();
if (!token) {
@@ -816,31 +816,32 @@
? 's'
: ''}</span
>
<button
type="button"
class="ml-4 rounded border px-2 py-0.5 text-sm transition-colors disabled:opacity-60 {data
.paste.userReaction === 1
? 'border-green-700 bg-green-900 text-green-200'
: 'border-neutral-700 bg-neutral-700 text-neutral-300 hover:bg-neutral-600'}
{$user?.uuid === data.paste.author?.uuid || !$user ? '' : 'cursor-not-allowed'}"
onclick={() => reactToPaste(1)}
disabled={reactingToPaste}
type="button"
class="ml-4 rounded border px-2 py-0.5 text-sm transition-colors disabled:opacity-60 {data
.paste.userReaction === 1
? 'border-green-700 bg-green-900 text-green-200'
: 'border-neutral-700 bg-neutral-700 text-neutral-300 hover:bg-neutral-600'}"
onclick={() => reactToPaste(1)}
disabled={reactingToPaste || !$user || $user?.uuid === data.paste.author?.uuid}
aria-disabled={reactingToPaste || !$user || $user?.uuid === data.paste.author?.uuid}
>
<ThumbsUp class="mr-1 inline-block h-4 w-4 text-green-400" />
<span>{formatNumber(data.paste.likes)}</span>
<ThumbsUp class="mr-1 inline-block h-4 w-4 text-green-400" />
<span>{formatNumber(data.paste.likes)}</span>
</button>
<button
type="button"
class="rounded border px-2 py-0.5 text-sm transition-colors disabled:opacity-60 {data
.paste.userReaction === 2
? 'border-red-700 bg-red-900 text-red-200'
: 'border-neutral-700 bg-neutral-700 text-neutral-300 hover:bg-neutral-600'}
{$user?.uuid === data.paste.author?.uuid || !$user ? '' : 'cursor-not-allowed'}"
onclick={() => reactToPaste(2)}
disabled={reactingToPaste}
type="button"
class="rounded border px-2 py-0.5 text-sm transition-colors disabled:opacity-60 {data
.paste.userReaction === 2
? 'border-red-700 bg-red-900 text-red-200'
: 'border-neutral-700 bg-neutral-700 text-neutral-300 hover:bg-neutral-600'}"
onclick={() => reactToPaste(2)}
disabled={reactingToPaste || !$user || $user?.uuid === data.paste.author?.uuid}
aria-disabled={reactingToPaste || !$user || $user?.uuid === data.paste.author?.uuid}
>
<ThumbsDown class="mr-1 inline-block h-4 w-4 text-red-400" />
<span>{formatNumber(data.paste.dislikes)}</span>
<ThumbsDown class="mr-1 inline-block h-4 w-4 text-red-400" />
<span>{formatNumber(data.paste.dislikes)}</span>
</button>
</div>
{:else}