mirror of
https://github.com/sim1222/misskey.git
synced 2025-05-01 03:37:30 +09:00
feat: import to react remote emoji
This commit is contained in:
parent
ee8df83af9
commit
c39c978c27
@ -93,7 +93,7 @@ useTooltip(buttonRef, async (showing) => {
|
|||||||
|
|
||||||
const onContextmenu = (e: MouseEvent) => {
|
const onContextmenu = (e: MouseEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
openReactionImportMenu(e, props.reaction);
|
openReactionImportMenu(e, props.reaction, props.note.id);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import * as os from '@/os';
|
|||||||
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
||||||
import { MenuItem } from '@/types/menu';
|
import { MenuItem } from '@/types/menu';
|
||||||
|
|
||||||
export async function openReactionImportMenu(ev: MouseEvent, reaction: string): Promise<void> {
|
export async function openReactionImportMenu(ev: MouseEvent, reaction: string, noteId: string): Promise<void> {
|
||||||
if (!reaction) return;
|
if (!reaction) return;
|
||||||
|
|
||||||
const host = reaction.match(/(?<=@).*\.*(?=:)/g)?.[0];
|
const host = reaction.match(/(?<=@).*\.*(?=:)/g)?.[0];
|
||||||
@ -58,14 +58,17 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string):
|
|||||||
return emojiId;
|
return emojiId;
|
||||||
};
|
};
|
||||||
|
|
||||||
const importEmoji = async (): Promise<void> => {
|
const importEmoji = async (skip: boolean): Promise<void> => {
|
||||||
const emojiId = await getEmojiId();
|
const emojiId = await getEmojiId();
|
||||||
if (!await emojiId) return;
|
if (!await emojiId) return;
|
||||||
os.api('admin/emoji/copy', {
|
os.api('admin/emoji/copy', {
|
||||||
emojiId: emojiId,
|
emojiId: emojiId,
|
||||||
}).then(async emoji => os.popup(defineAsyncComponent(() => import('@/pages/admin/emoji-edit-dialog.vue')), {
|
}).then(async emoji => {
|
||||||
|
if (skip) return;
|
||||||
|
os.popup(defineAsyncComponent(() => import('@/pages/admin/emoji-edit-dialog.vue')), {
|
||||||
emoji: await getEmojiObject(emoji),
|
emoji: await getEmojiObject(emoji),
|
||||||
}));
|
});
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const menuItems: MenuItem[] = [{
|
const menuItems: MenuItem[] = [{
|
||||||
@ -89,6 +92,30 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string):
|
|||||||
!isLocal
|
!isLocal
|
||||||
) {
|
) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
|
type: 'button',
|
||||||
|
icon: 'fas fa-check',
|
||||||
|
text: 'リアクションする',
|
||||||
|
action: async () => {
|
||||||
|
const duplication: boolean = await os.api('meta').then(meta => {
|
||||||
|
const emojis = meta.emojis;
|
||||||
|
return emojis.some((emoji) => {
|
||||||
|
return (emoji === name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (duplication) {
|
||||||
|
os.api('notes/reactions/create', {
|
||||||
|
noteId: noteId,
|
||||||
|
reaction: name,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
await importEmoji(true);
|
||||||
|
os.api('notes/reactions/create', {
|
||||||
|
noteId: noteId,
|
||||||
|
reaction: name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}, {
|
||||||
type: 'button',
|
type: 'button',
|
||||||
icon: 'fas fa-download',
|
icon: 'fas fa-download',
|
||||||
text: i18n.ts.import,
|
text: i18n.ts.import,
|
||||||
@ -106,10 +133,10 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string):
|
|||||||
text: i18n.ts.duplicateEmoji,
|
text: i18n.ts.duplicateEmoji,
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
if (res.canceled) return;
|
if (res.canceled) return;
|
||||||
importEmoji();
|
importEmoji(false);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
importEmoji();
|
importEmoji(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user