From 5a76b7069f5120f4b1698b4c254111ad8cce78d9 Mon Sep 17 00:00:00 2001 From: HellhoundSoftware Date: Sat, 18 Jan 2025 08:28:57 -0500 Subject: [PATCH] Refactor renote tooltip text --- packages/frontend/src/components/MkNote.vue | 7 ++----- packages/frontend/src/components/MkNoteDetailed.vue | 7 ++----- packages/frontend/src/components/MkNoteSub.vue | 7 ++----- packages/frontend/src/components/SkNote.vue | 7 ++----- packages/frontend/src/components/SkNoteDetailed.vue | 7 ++----- packages/frontend/src/components/SkNoteSub.vue | 7 ++----- packages/frontend/src/scripts/boost-quote.ts | 10 +++++++++- 7 files changed, 21 insertions(+), 31 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index 2971252dbf..5c6c6f45bb 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -239,7 +239,7 @@ import { getNoteSummary } from '@/scripts/get-note-summary.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; import { showMovedDialog } from '@/scripts/show-moved-dialog.js'; import { useRouter } from '@/router/supplier.js'; -import { boostMenuItems, type Visibility } from '@/scripts/boost-quote.js'; +import { boostMenuItems, type Visibility, computeRenoteTooltip } from '@/scripts/boost-quote.js'; import { isEnabledUrlPreview } from '@/instance.js'; import { type Keymap } from '@/scripts/hotkey.js'; import { focusPrev, focusNext } from '@/scripts/focus.js'; @@ -339,10 +339,7 @@ const pleaseLoginContext = computed(() => ({ url: `https://${host}/notes/${appearNote.value.id}`, })); -const renoteTooltip = computed(() => { - if (renoted.value) return i18n.ts.unrenote; - return defaultStore.state.showVisibilitySelectorOnBoost ? i18n.ts.renote : i18n.ts.renoteShift; -}); +const renoteTooltip = computeRenoteTooltip(renoted); /* Overload FunctionにLintが対応していないのでコメントアウト function checkMute(noteToCheck: Misskey.entities.Note, mutedWords: Array | undefined | null, checkOnly: true): boolean; diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index a855b3269c..93a543dff1 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -281,7 +281,7 @@ import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkPagination, { type Paging } from '@/components/MkPagination.vue'; import MkReactionIcon from '@/components/MkReactionIcon.vue'; import MkButton from '@/components/MkButton.vue'; -import { boostMenuItems, type Visibility } from '@/scripts/boost-quote.js'; +import { boostMenuItems, type Visibility, computeRenoteTooltip } from '@/scripts/boost-quote.js'; import { isEnabledUrlPreview } from '@/instance.js'; import { getAppearNote } from '@/scripts/get-appear-note.js'; import { type Keymap } from '@/scripts/hotkey.js'; @@ -348,10 +348,7 @@ const quotes = ref([]); const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || (appearNote.value.visibility === 'followers' && appearNote.value.userId === $i?.id)); const defaultLike = computed(() => defaultStore.state.like ? defaultStore.state.like : null); -const renoteTooltip = computed(() => { - if (renoted.value) return i18n.ts.unrenote; - return defaultStore.state.showVisibilitySelectorOnBoost ? i18n.ts.renote : i18n.ts.renoteShift; -}); +const renoteTooltip = computeRenoteTooltip(renoted); watch(() => props.expandAllCws, (expandAllCws) => { if (expandAllCws !== showContent.value) showContent.value = expandAllCws; diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue index 4bdeeb7ab4..9febc1219c 100644 --- a/packages/frontend/src/components/MkNoteSub.vue +++ b/packages/frontend/src/components/MkNoteSub.vue @@ -107,7 +107,7 @@ import { reactionPicker } from '@/scripts/reaction-picker.js'; import { claimAchievement } from '@/scripts/achievements.js'; import { getNoteMenu } from '@/scripts/get-note-menu.js'; import { useNoteCapture } from '@/scripts/use-note-capture.js'; -import { boostMenuItems, type Visibility } from '@/scripts/boost-quote.js'; +import { boostMenuItems, type Visibility, computeRenoteTooltip } from '@/scripts/boost-quote.js'; const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id); @@ -136,10 +136,7 @@ const quoteButton = shallowRef(); const menuButton = shallowRef(); const likeButton = shallowRef(); -const renoteTooltip = computed(() => { - if (renoted.value) return i18n.ts.unrenote; - return defaultStore.state.showVisibilitySelectorOnBoost ? i18n.ts.renote : i18n.ts.renoteShift; -}); +const renoteTooltip = computeRenoteTooltip(computed); let appearNote = computed(() => isRenote ? props.note.renote as Misskey.entities.Note : props.note); const defaultLike = computed(() => defaultStore.state.like ? defaultStore.state.like : null); diff --git a/packages/frontend/src/components/SkNote.vue b/packages/frontend/src/components/SkNote.vue index eef6129792..7dc513ff0b 100644 --- a/packages/frontend/src/components/SkNote.vue +++ b/packages/frontend/src/components/SkNote.vue @@ -239,7 +239,7 @@ import { getNoteSummary } from '@/scripts/get-note-summary.js'; import MkRippleEffect from '@/components/MkRippleEffect.vue'; import { showMovedDialog } from '@/scripts/show-moved-dialog.js'; import { useRouter } from '@/router/supplier.js'; -import { boostMenuItems, type Visibility } from '@/scripts/boost-quote.js'; +import { boostMenuItems, type Visibility, computeRenoteTooltip } from '@/scripts/boost-quote.js'; import { isEnabledUrlPreview } from '@/instance.js'; import { type Keymap } from '@/scripts/hotkey.js'; import { focusPrev, focusNext } from '@/scripts/focus.js'; @@ -334,10 +334,7 @@ const defaultLike = computed(() => defaultStore.state.like ? defaultStore.state. const animated = computed(() => parsed.value ? checkAnimationFromMfm(parsed.value) : null); const allowAnim = ref(defaultStore.state.advancedMfm && defaultStore.state.animatedMfm ? true : false); -const renoteTooltip = computed(() => { - if (renoted.value) return i18n.ts.unrenote; - return defaultStore.state.showVisibilitySelectorOnBoost ? i18n.ts.renote : i18n.ts.renoteShift; -}); +const renoteTooltip = computeRenoteTooltip(renoted); const pleaseLoginContext = computed(() => ({ type: 'lookup', diff --git a/packages/frontend/src/components/SkNoteDetailed.vue b/packages/frontend/src/components/SkNoteDetailed.vue index e7e225304e..69e2898264 100644 --- a/packages/frontend/src/components/SkNoteDetailed.vue +++ b/packages/frontend/src/components/SkNoteDetailed.vue @@ -286,7 +286,7 @@ import MkUserCardMini from '@/components/MkUserCardMini.vue'; import MkPagination, { type Paging } from '@/components/MkPagination.vue'; import MkReactionIcon from '@/components/MkReactionIcon.vue'; import MkButton from '@/components/MkButton.vue'; -import { boostMenuItems, type Visibility } from '@/scripts/boost-quote.js'; +import { boostMenuItems, type Visibility, computeRenoteTooltip } from '@/scripts/boost-quote.js'; import { isEnabledUrlPreview } from '@/instance.js'; import { getAppearNote } from '@/scripts/get-appear-note.js'; import { type Keymap } from '@/scripts/hotkey.js'; @@ -354,10 +354,7 @@ const quotes = ref([]); const canRenote = computed(() => ['public', 'home'].includes(appearNote.value.visibility) || (appearNote.value.visibility === 'followers' && appearNote.value.userId === $i?.id)); const defaultLike = computed(() => defaultStore.state.like ? defaultStore.state.like : null); -const renoteTooltip = computed(() => { - if (renoted.value) return i18n.ts.unrenote; - return defaultStore.state.showVisibilitySelectorOnBoost ? i18n.ts.renote : i18n.ts.renoteShift; -}); +const renoteTooltip = computeRenoteTooltip(renoted); watch(() => props.expandAllCws, (expandAllCws) => { if (expandAllCws !== showContent.value) showContent.value = expandAllCws; diff --git a/packages/frontend/src/components/SkNoteSub.vue b/packages/frontend/src/components/SkNoteSub.vue index ff8af5b72b..a3d27c9e16 100644 --- a/packages/frontend/src/components/SkNoteSub.vue +++ b/packages/frontend/src/components/SkNoteSub.vue @@ -115,7 +115,7 @@ import { reactionPicker } from '@/scripts/reaction-picker.js'; import { claimAchievement } from '@/scripts/achievements.js'; import { getNoteMenu } from '@/scripts/get-note-menu.js'; import { useNoteCapture } from '@/scripts/use-note-capture.js'; -import { boostMenuItems, type Visibility } from '@/scripts/boost-quote.js'; +import { boostMenuItems, type Visibility, computeRenoteTooltip } from '@/scripts/boost-quote.js'; const canRenote = computed(() => ['public', 'home'].includes(props.note.visibility) || props.note.userId === $i.id); const hideLine = computed(() => { return props.detail ? true : false; }); @@ -150,10 +150,7 @@ const quoteButton = shallowRef(); const menuButton = shallowRef(); const likeButton = shallowRef(); -const renoteTooltip = computed(() => { - if (renoted.value) return i18n.ts.unrenote; - return defaultStore.state.showVisibilitySelectorOnBoost ? i18n.ts.renote : i18n.ts.renoteShift; -}); +const renoteTooltip = computeRenoteTooltip(renoted); let appearNote = computed(() => isRenote ? props.note.renote as Misskey.entities.Note : props.note); const defaultLike = computed(() => defaultStore.state.like ? defaultStore.state.like : null); diff --git a/packages/frontend/src/scripts/boost-quote.ts b/packages/frontend/src/scripts/boost-quote.ts index 4e025f5d4f..feb949772b 100644 --- a/packages/frontend/src/scripts/boost-quote.ts +++ b/packages/frontend/src/scripts/boost-quote.ts @@ -3,7 +3,7 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { ref, Ref } from 'vue'; +import { ref, Ref, computed, ComputedRef } from 'vue'; import * as Misskey from 'misskey-js'; import { i18n } from '@/i18n.js'; import { defaultStore } from '@/store.js'; @@ -79,3 +79,11 @@ export function boostMenuItems(appearNote: Ref, renote: ( } as MenuItem, ]; } + +export function computeRenoteTooltip(renoted: Ref): ComputedRef { + return computed(() => { + if (renoted.value) return i18n.ts.unrenote; + if (defaultStore.state.showVisibilitySelectorOnBoost) return i18n.ts.renote; + return i18n.ts.renoteShift; + }); +}