From c7b6e0cbf949bd586bb1b68393111f1e8f26345c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=91=E3=81=A3=E3=81=A1?= Date: Sun, 18 Sep 2022 16:39:35 +0900 Subject: [PATCH 1/3] fix copy --- .../client/src/scripts/reactionImportMenu.ts | 43 +++++++------------ 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/packages/client/src/scripts/reactionImportMenu.ts b/packages/client/src/scripts/reactionImportMenu.ts index 222fec22c..d7f24a099 100644 --- a/packages/client/src/scripts/reactionImportMenu.ts +++ b/packages/client/src/scripts/reactionImportMenu.ts @@ -1,15 +1,14 @@ +import { defineAsyncComponent } from 'vue'; import { $i } from '@/account'; import { i18n } from '@/i18n'; import * as os from '@/os'; import copyToClipboard from '@/scripts/copy-to-clipboard'; -import { defineAsyncComponent } from 'vue'; -import { entities } from 'misskey-js'; import { MenuItem } from '@/types/menu'; -import { CustomEmoji } from 'misskey-js/built/entities'; -export async function openReactionImportMenu(ev: MouseEvent, reaction: string) { +export async function openReactionImportMenu(ev: MouseEvent, reaction: string): Promise { + if (!reaction) return; - const getEmojiObject = emojiId => new Promise | null>(async resolve => { + const getEmojiObject = (emojiId): Promise | null> => new Promise | null>(async resolve => { const sinceId = await os.api('admin/emoji/list', { limit: 1, untilId: emojiId.id, @@ -33,14 +32,12 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) { resolve(id[0]); }); - const getEmojiId = async (emojiName: string) => { - - const isLocal = (emojiName.match(/(?<=@).*\.*(?=:)/g) == null || emojiName.match(/(?<=@).*\.*(?=:)/g)[0] == '.'); + const getEmojiId = async (emojiName: string): Promise => { + const isLocal = (emojiName.match(/(?<=@).*\.*(?=:)/g) === null || emojiName.match(/(?<=@).*\.*(?=:)/g)[0] === '.'); if (isLocal) return null; const host = emojiName.match(/(?<=@).*\.*(?=:)/g)[0]; const name = emojiName.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]; - if (!host || !name) return; - + if (!host || !name) return null; const resList: Record[] = await os.api('admin/emoji/list-remote', { host, @@ -48,12 +45,12 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) { limit: 100, }); - const emojiId = await resList.find(emoji => emoji.name == name && emoji.host == host)?.id; + const emojiId = await resList.find(emoji => emoji.name === name && emoji.host === host)?.id; return emojiId; - } + }; - const importEmoji = async (emojiName: string) => { + const importEmoji = async (emojiName: string): Promise => { const emojiId = await getEmojiId(emojiName); if (!await emojiId) return; os.api('admin/emoji/copy', { @@ -63,9 +60,6 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) { })); }; - if (!($i?.isAdmin || $i?.isModerator)) return; - if (!reaction) return; - const menuItems: MenuItem[] = [{ type: 'label', text: reaction, @@ -73,18 +67,15 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) { type: 'button', icon: 'fas fa-copy', text: i18n.ts.copy, - action: () => { - copyToClipboard(reaction => { - if (reaction.startsWith(':')) { - return `:${reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]}:` || reaction; - } else { - return reaction; - } - }); + action: (): void => { + console.log('copy'); + copyToClipboard(reaction.startsWith(':') ? `:${reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]}:` : reaction); }, - }]; + }]; + const emojiId = await getEmojiId(reaction) ? await getEmojiId(reaction) : reaction; if (reaction.startsWith(':') && emojiId) { + if (!($i?.isAdmin || $i?.isModerator)) return; menuItems.push({ type: 'button', icon: 'fas fa-download', @@ -113,7 +104,5 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) { } os.contextMenu(menuItems, ev); - - } From fbc1ec67cf51ed38d19a262621e17d4b2803a98d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=91=E3=81=A3=E3=81=A1?= Date: Sun, 18 Sep 2022 16:41:37 +0900 Subject: [PATCH 2/3] remove debug log --- packages/client/src/scripts/reactionImportMenu.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/client/src/scripts/reactionImportMenu.ts b/packages/client/src/scripts/reactionImportMenu.ts index d7f24a099..ea2f71bb6 100644 --- a/packages/client/src/scripts/reactionImportMenu.ts +++ b/packages/client/src/scripts/reactionImportMenu.ts @@ -68,7 +68,6 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string): icon: 'fas fa-copy', text: i18n.ts.copy, action: (): void => { - console.log('copy'); copyToClipboard(reaction.startsWith(':') ? `:${reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]}:` : reaction); }, }]; From 6cc945b53c9766e32097e08cf85f1d863001344e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=93=E3=81=91=E3=81=A3=E3=81=A1?= Date: Sun, 18 Sep 2022 16:42:24 +0900 Subject: [PATCH 3/3] 12.119.0-simkey-v9 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66fce8927..1bd172055 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "misskey", - "version": "12.119.0-simkey-v8", + "version": "12.119.0-simkey-v9", "codename": "indigo", "repository": { "type": "git",