fix: Hide unmute option when the user is blocked

This commit is contained in:
Daniel Hernández 2023-02-09 13:46:32 -04:00
parent 135860cc68
commit 569136b87c
No known key found for this signature in database
GPG Key ID: 1FE6E4A6C61D7B31
3 changed files with 7 additions and 4 deletions

View File

@ -26,7 +26,7 @@
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
<span v-if="item.indicate" class="indicator"><i class="ph-circle-fill"></i></span> <span v-if="item.indicate" class="indicator"><i class="ph-circle-fill"></i></span>
</a> </a>
<button v-else-if="item.type === 'user'" :tabindex="i" class="_button item" :class="{ active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)"> <button v-else-if="item.type === 'user' && !items.hidden" :tabindex="i" class="_button item" :class="{ active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<MkAvatar :user="item.user" class="avatar"/><MkUserName :user="item.user"/> <MkAvatar :user="item.user" class="avatar"/><MkUserName :user="item.user"/>
<span v-if="item.indicate" class="indicator"><i class="ph-circle-fill"></i></span> <span v-if="item.indicate" class="indicator"><i class="ph-circle-fill"></i></span>
</button> </button>
@ -38,7 +38,7 @@
<span>{{ item.text }}</span> <span>{{ item.text }}</span>
<span class="caret"><i class="ph-caret-right-bold ph-lg ph-fw ph-lg"></i></span> <span class="caret"><i class="ph-caret-right-bold ph-lg ph-fw ph-lg"></i></span>
</button> </button>
<button v-else :tabindex="i" class="_button item" :class="{ danger: item.danger, active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)"> <button v-else-if="!item.hidden" :tabindex="i" class="_button item" :class="{ danger: item.danger, active: item.active }" :disabled="item.active" @click="clicked(item.action, $event)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
<i v-if="item.icon" class="ph-fw ph-lg" :class="item.icon"></i> <i v-if="item.icon" class="ph-fw ph-lg" :class="item.icon"></i>
<MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/> <MkAvatar v-if="item.avatar" :user="item.avatar" class="avatar"/>
<span>{{ item.text }}</span> <span>{{ item.text }}</span>

View File

@ -128,7 +128,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
await os.apiWithDialog(user.isBlocking ? "blocking/delete" : "blocking/create", { await os.apiWithDialog(user.isBlocking ? "blocking/delete" : "blocking/create", {
userId: user.id, userId: user.id,
}) })
user.isBlocking = !user.isBlocking; user.isBlocking = !user.isBlocking;
await os.api(user.isBlocking ? "mute/create" : "mute/delete", { await os.api(user.isBlocking ? "mute/create" : "mute/delete", {
userId: user.id, userId: user.id,
}) })
@ -136,7 +136,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
if (user.isBlocking) { if (user.isBlocking) {
await os.api('following/delete', { await os.api('following/delete', {
userId: user.id, userId: user.id,
}); });
user.isFollowing = false user.isFollowing = false
} }
} }
@ -261,6 +261,7 @@ export function getUserMenu(user, router: Router = mainRouter) {
{ {
icon: user.isMuted ? "ph-eye-bold ph-lg" : "ph-eye-slash-bold ph-lg", icon: user.isMuted ? "ph-eye-bold ph-lg" : "ph-eye-slash-bold ph-lg",
text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute, text: user.isMuted ? i18n.ts.unmute : i18n.ts.mute,
hidden: user.isBlocking === true,
action: toggleMute, action: toggleMute,
}, },
{ {

View File

@ -28,6 +28,7 @@ export type MenuUser = {
user: Misskey.entities.User; user: Misskey.entities.User;
active?: boolean; active?: boolean;
indicate?: boolean; indicate?: boolean;
hidden?: boolean;
action: MenuAction; action: MenuAction;
}; };
export type MenuSwitch = { export type MenuSwitch = {
@ -43,6 +44,7 @@ export type MenuButton = {
indicate?: boolean; indicate?: boolean;
danger?: boolean; danger?: boolean;
active?: boolean; active?: boolean;
hidden?: boolean;
avatar?: Misskey.entities.User; avatar?: Misskey.entities.User;
action: MenuAction; action: MenuAction;
}; };