Skip to content

Commit b7b6f0d

Browse files
committed
fix(status): disable reblog for non-public posts
closes #870
1 parent 5075fdf commit b7b6f0d

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

components/status/StatusActionButton.vue

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
const props = defineProps<{
2+
const { as = 'button', command, disabled, content, icon } = defineProps<{
33
text?: string | number
44
content: string
55
color: string
@@ -27,10 +27,10 @@ useCommand({
2727
scope: 'Actions',
2828
2929
order: -2,
30-
visible: () => props.command && !props.disabled,
30+
visible: () => command && !disabled,
3131
32-
name: () => props.content,
33-
icon: () => props.icon,
32+
name: () => content,
33+
icon: () => icon,
3434
3535
onActivate() {
3636
if (!checkLogin())
@@ -47,18 +47,27 @@ useCommand({
4747

4848
<template>
4949
<component
50-
:is="as || 'button'"
50+
:is="as"
5151
v-bind="$attrs" ref="el"
5252
w-fit flex gap-1 items-center
53-
rounded group :hover="hover"
54-
focus:outline-none cursor-pointer
53+
rounded group
54+
:hover=" !disabled ? hover : undefined"
55+
focus:outline-none
5556
:focus-visible="hover"
56-
:class="active ? [color] : 'text-secondary'"
57+
:class="active ? color : 'text-secondary'"
5758
:aria-label="content"
59+
:disabled="disabled"
5860
>
5961
<CommonTooltip placement="bottom" :content="content">
60-
<div rounded-full p2 :group-hover="groupHover" :group-focus-visible="groupHover" group-focus-visible:ring="2 current">
61-
<div :class="[active && activeIcon ? activeIcon : icon, { 'pointer-events-none': disabled }]" />
62+
<div
63+
rounded-full p2
64+
v-bind="disabled ? {} : {
65+
'group-hover': groupHover,
66+
'group-focus-visible': groupHover,
67+
'group-focus-visible:ring': '2 current',
68+
}"
69+
>
70+
<div :class="active && activeIcon ? activeIcon : icon" />
6271
</div>
6372
</CommonTooltip>
6473

components/status/StatusActions.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const { details, command } = $(props)
1414
const {
1515
status,
1616
isLoading,
17+
canReblog,
1718
toggleBookmark,
1819
toggleFavourite,
1920
toggleReblog,
@@ -62,7 +63,7 @@ const reply = () => {
6263
icon="i-ri:repeat-line"
6364
active-icon="i-ri:repeat-fill"
6465
:active="!!status.reblogged"
65-
:disabled="isLoading.reblogged"
66+
:disabled="isLoading.reblogged || !canReblog"
6667
:command="command"
6768
@click="toggleReblog()"
6869
>

composables/masto/status.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function useStatusActions(props: StatusActionsProps) {
3131
// check login
3232
if (!checkLogin())
3333
return
34+
3435
isLoading[action] = true
3536
fetchNewStatus().then((newStatus) => {
3637
Object.assign(status, newStatus)
@@ -44,6 +45,12 @@ export function useStatusActions(props: StatusActionsProps) {
4445
if (countField)
4546
status[countField] += status[action] ? 1 : -1
4647
}
48+
49+
const canReblog = $computed(() =>
50+
status.visibility !== 'direct'
51+
&& (status.visibility !== 'private' || status.account.id === currentUser.value?.account.id),
52+
)
53+
4754
const toggleReblog = () => toggleStatusAction(
4855
'reblogged',
4956
() => masto.v1.statuses[status.reblogged ? 'unreblog' : 'reblog'](status.id).then((res) => {
@@ -79,6 +86,7 @@ export function useStatusActions(props: StatusActionsProps) {
7986
return {
8087
status: $$(status),
8188
isLoading: $$(isLoading),
89+
canReblog: $$(canReblog),
8290
toggleMute,
8391
toggleReblog,
8492
toggleFavourite,

0 commit comments

Comments
 (0)