Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net committed Nov 3, 2024
1 parent e32a95d commit a072167
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
4 changes: 4 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,10 @@ export interface Locale extends ILocale {
* このリアクションで検索
*/
"searchThisReaction": string;
/**
* 部分一致
*/
"partialMatch": string;
/**
* 返信
*/
Expand Down
1 change: 1 addition & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ copyProfileUrl: "プロフィールURLをコピー"
searchUser: "ユーザーを検索"
searchThisUsersNotes: "ユーザーのノートを検索"
searchThisReaction: "このリアクションで検索"
partialMatch: "部分一致"
reply: "返信"
loadMore: "もっと見る"
showMore: "もっと見る"
Expand Down
45 changes: 24 additions & 21 deletions packages/frontend/src/components/MkReactionsViewer.reaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ SPDX-License-Identifier: AGPL-3.0-only
class="_button"
:class="[$style.root, { [$style.reacted]: note.myReaction == reaction, [$style.canToggle]: (canToggle || alternative), [$style.small]: defaultStore.state.reactionsDisplaySize === 'small', [$style.large]: defaultStore.state.reactionsDisplaySize === 'large' }]"
@click.stop="(ev) => { canToggle || alternative ? toggleReaction(ev) : stealReaction(ev) }"
@contextmenu.stop="onContextmenu"
@contextmenu.prevent.stop="menu"
>
<MkReactionIcon :class="defaultStore.state.limitWidthOfReaction ? $style.limitWidth : ''" :reaction="reaction" :emojiUrl="note.reactionEmojis[reaction.substring(1, reaction.length - 1)]" @click.stop="(ev) => { canToggle || alternative ? toggleReaction(ev) : stealReaction(ev) }"/>
Expand Down Expand Up @@ -74,19 +73,6 @@ const router = useRouter();

const alternative: ComputedRef<string | null> = computed(() => defaultStore.state.reactableRemoteReactionEnabled ? (customEmojis.value.find(it => it.name === reactionName.value)?.name ?? null) : null);

function onContextmenu(ev: MouseEvent) {
if (!advanccedNotesSearchAvailable) return;
let menu: MenuItem[];
menu = [{
text: i18n.ts.searchThisReaction,
icon: 'ti ti-search',
action: () => {
router.push(`/search?type=anote&reactions=${encodeURIComponent(props.reaction)}`);
},
}];
os.contextMenu(menu, ev);
}

async function toggleReaction(ev: MouseEvent) {
if (!canToggle.value) {
chooseAlternative(ev);
Expand Down Expand Up @@ -171,31 +157,48 @@ function stealReaction(ev: MouseEvent) {
}

async function menu(ev) {
if (!canGetInfo.value) return;

os.popupMenu([{
const isCustomEmoji = props.reaction.endsWith(':');
let menu = [isCustomEmoji ? {
type: 'label',
text: `:${reactionName.value}:`,
}, {
} : undefined, isCustomEmoji ? {
text: i18n.ts.info,
icon: 'ti ti-info-circle',
action: async () => {
const { dispose } = os.popup(MkCustomEmojiDetailedDialog, {
emoji: await misskeyApiGet('emoji', {
name: props.reaction.replace(/:/g, '').replace(/@\./, ''),
name: props.reaction.replace(/:/g, '').replace(/@.+/, ''),
...(!props.reaction.endsWith('@.:') && { host: props.reaction.split('@')[1].replace(':', '') }),
}),
}, {
closed: () => dispose(),
});
},
}, customEmojis.value.find(it => it.name === reactionName.value)?.name ? {
} : undefined, customEmojis.value.find(it => it.name === reactionName.value)?.name ? {
text: i18n.ts.copy,
icon: 'ti ti-copy',
action: () => {
copyToClipboard(`:${reactionName.value}:`);
os.toast(i18n.ts.copied, 'copied');
},
} : undefined], ev.currentTarget ?? ev.target);
} : undefined,
];
if (advanccedNotesSearchAvailable) {
menu.push({
text: i18n.ts.searchThisReaction,
icon: 'ti ti-search',
action: () => {
router.push(`/search?type=anote&reactions=${encodeURIComponent(isCustomEmoji ? props.reaction.endsWith('@.:') ? props.reaction.replace('@.', '') : props.reaction : props.reaction)}`);
},
}, isCustomEmoji ? {
text: `${i18n.ts.searchThisReaction}(${i18n.ts.partialMatch})`,
icon: 'ti ti-search',
action: () => {
router.push(`/search?type=anote&reactions=${encodeURIComponent(`${ props.reaction.endsWith('@.:') ? props.reaction.replace('@.:', '') : props.reaction.split('@')[0]}*`)}`);
},
} : undefined );
}
os.popupMenu(menu, ev.currentTarget ?? ev.target);
}

function anime() {
Expand Down

0 comments on commit a072167

Please sign in to comment.