Fixed visibility display

This commit is contained in:
Natty 2023-11-07 16:28:15 +01:00
parent 0ed23fe68e
commit 2173ee452f
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 39 additions and 13 deletions

View File

@ -1,22 +1,32 @@
<template> <template>
<span v-if="note.visibility !== 'public'" :class="$style.visibility"> <span
v-if="note.visibility !== 'public' && note.visibility !== 'Public'"
:class="$style.visibility"
>
<i <i
v-if="note.visibility === 'home'" v-if="note.visibility === 'home' || note.visibility === 'Home'"
class="ph-house ph-bold ph-lg" class="ph-house ph-bold ph-lg"
v-tooltip="i18n.ts._visibility.home" v-tooltip="i18n.ts._visibility.home"
></i> ></i>
<i <i
v-else-if="note.visibility === 'followers'" v-else-if="
note.visibility === 'followers' ||
note.visibility === 'Followers'
"
class="ph-lock ph-bold ph-lg" class="ph-lock ph-bold ph-lg"
v-tooltip="i18n.ts._visibility.followers" v-tooltip="i18n.ts._visibility.followers"
></i> ></i>
<i <i
v-else-if="note.visibility === 'specified'" v-else-if="
note.visibility === 'specified' || note.visibility === 'Direct'
"
ref="specified" ref="specified"
class="ph-envelope-simple-open ph-bold ph-lg" class="ph-envelope-simple-open ph-bold ph-lg"
></i> ></i>
</span> </span>
<span v-if="note.localOnly" :class="$style.localOnly" <span
v-if="magTransProperty(note, 'localOnly', 'local_only')"
:class="$style.localOnly"
><i ><i
class="ph-hand-fist ph-bold ph-lg" class="ph-hand-fist ph-bold ph-lg"
v-tooltip="i18n.ts._visibility.localOnly" v-tooltip="i18n.ts._visibility.localOnly"
@ -25,18 +35,24 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue";
import XDetails from "@/components/MkUsersTooltip.vue"; import XDetails from "@/components/MkUsersTooltip.vue";
import * as os from "@/os"; import * as os from "@/os";
import { useTooltip } from "@/scripts/use-tooltip"; import { useTooltip } from "@/scripts/use-tooltip";
import { i18n } from "@/i18n"; import { i18n } from "@/i18n";
import * as Misskey from "calckey-js";
import { packed } from "magnetar-common";
import { magTransProperty } from "@/scripts-mag/mag-util";
const props = defineProps<{ const props = defineProps<{
note: { note:
visibility: string; | Pick<
localOnly?: boolean; Misskey.entities.Note,
visibleUserIds?: string[]; "visibility" | "localOnly" | "visibleUserIds"
}; >
| Pick<
packed.PackNoteBase,
"visibility" | "local_only" | "visible_user_ids"
>;
}>(); }>();
const specified = $ref<HTMLElement>(); const specified = $ref<HTMLElement>();
@ -44,7 +60,12 @@ const specified = $ref<HTMLElement>();
if (props.note.visibility === "specified") { if (props.note.visibility === "specified") {
useTooltip($$(specified), async (showing) => { useTooltip($$(specified), async (showing) => {
const users = await os.api("users/show", { const users = await os.api("users/show", {
userIds: props.note.visibleUserIds, userIds:
magTransProperty(
props.note,
"visibleUserIds",
"visible_user_ids"
) ?? [],
limit: 10, limit: 10,
}); });
@ -53,7 +74,12 @@ if (props.note.visibility === "specified") {
{ {
showing, showing,
users, users,
count: props.note.visibleUserIds.length, count:
magTransProperty(
props.note,
"visibleUserIds",
"visible_user_ids"
)?.length ?? 0,
targetElement: specified, targetElement: specified,
}, },
{}, {},