Compare commits
9 Commits
12.119.0-s
...
develop
Author | SHA1 | Date | |
---|---|---|---|
5e529eb605 | |||
890bef35eb | |||
8aa3787ffc | |||
2b05de0204 | |||
6cc945b53c | |||
c60db40175 | |||
fbc1ec67cf | |||
f66626e6e6 | |||
c7b6e0cbf9 |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"version": "12.119.0-simkey-v8",
|
"version": "12.119.0-simkey-v10111",
|
||||||
"codename": "indigo",
|
"codename": "indigo",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
|
import { defineAsyncComponent } from 'vue';
|
||||||
import { $i } from '@/account';
|
import { $i } from '@/account';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import * as os from '@/os';
|
import * as os from '@/os';
|
||||||
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
import copyToClipboard from '@/scripts/copy-to-clipboard';
|
||||||
import { defineAsyncComponent } from 'vue';
|
|
||||||
import { entities } from 'misskey-js';
|
|
||||||
import { MenuItem } from '@/types/menu';
|
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<void> {
|
||||||
|
if (!reaction) return;
|
||||||
|
|
||||||
const getEmojiObject = emojiId => new Promise<Record<string, any> | null>(async resolve => {
|
const host = reaction.match(/(?<=@).*\.*(?=:)/g)?.[0];
|
||||||
|
const name = reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)?.[0];
|
||||||
|
const isLocal = (host === null || host === '.');
|
||||||
|
const isCustom = reaction.startsWith(':');
|
||||||
|
|
||||||
|
const getEmojiObject = (emojiId): Promise<Record<string, any> | null> => new Promise<Record<string, any> | null>(async resolve => {
|
||||||
const sinceId = await os.api('admin/emoji/list', {
|
const sinceId = await os.api('admin/emoji/list', {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
untilId: emojiId.id,
|
untilId: emojiId.id,
|
||||||
@ -33,14 +37,9 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) {
|
|||||||
resolve(id[0]);
|
resolve(id[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const getEmojiId = async (emojiName: string) => {
|
const getEmojiId = async (): Promise<string | null> => {
|
||||||
|
|
||||||
const isLocal = (emojiName.match(/(?<=@).*\.*(?=:)/g) == null || emojiName.match(/(?<=@).*\.*(?=:)/g)[0] == '.');
|
|
||||||
if (isLocal) return null;
|
if (isLocal) return null;
|
||||||
const host = emojiName.match(/(?<=@).*\.*(?=:)/g)[0];
|
if (!host || !name) return null;
|
||||||
const name = emojiName.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0];
|
|
||||||
if (!host || !name) return;
|
|
||||||
|
|
||||||
|
|
||||||
const resList: Record<string, any>[] = await os.api('admin/emoji/list-remote', {
|
const resList: Record<string, any>[] = await os.api('admin/emoji/list-remote', {
|
||||||
host,
|
host,
|
||||||
@ -48,13 +47,13 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) {
|
|||||||
limit: 100,
|
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;
|
return emojiId;
|
||||||
}
|
};
|
||||||
|
|
||||||
const importEmoji = async (emojiName: string) => {
|
const importEmoji = async (): Promise<void> => {
|
||||||
const emojiId = await getEmojiId(emojiName);
|
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,
|
||||||
@ -63,9 +62,6 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!($i?.isAdmin || $i?.isModerator)) return;
|
|
||||||
if (!reaction) return;
|
|
||||||
|
|
||||||
const menuItems: MenuItem[] = [{
|
const menuItems: MenuItem[] = [{
|
||||||
type: 'label',
|
type: 'label',
|
||||||
text: reaction,
|
text: reaction,
|
||||||
@ -73,18 +69,19 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) {
|
|||||||
type: 'button',
|
type: 'button',
|
||||||
icon: 'fas fa-copy',
|
icon: 'fas fa-copy',
|
||||||
text: i18n.ts.copy,
|
text: i18n.ts.copy,
|
||||||
action: () => {
|
action: (): void => {
|
||||||
copyToClipboard(reaction => {
|
copyToClipboard(isCustom ? `:${name}:` : reaction);
|
||||||
if (reaction.startsWith(':')) {
|
|
||||||
return `:${reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]}:` || reaction;
|
|
||||||
} else {
|
|
||||||
return reaction;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
const emojiId = await getEmojiId(reaction) ? await getEmojiId(reaction) : reaction;
|
|
||||||
if (reaction.startsWith(':') && emojiId) {
|
const emojiId = await getEmojiId() ? await getEmojiId() : reaction;
|
||||||
|
|
||||||
|
if (
|
||||||
|
isCustom &&
|
||||||
|
emojiId &&
|
||||||
|
($i?.isAdmin || $i?.isModerator) &&
|
||||||
|
!isLocal
|
||||||
|
) {
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
type: 'button',
|
type: 'button',
|
||||||
icon: 'fas fa-download',
|
icon: 'fas fa-download',
|
||||||
@ -93,7 +90,7 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string) {
|
|||||||
const duplication: boolean = await os.api('meta').then(meta => {
|
const duplication: boolean = await os.api('meta').then(meta => {
|
||||||
const emojis = meta.emojis;
|
const emojis = meta.emojis;
|
||||||
return emojis.some((emoji) => {
|
return emojis.some((emoji) => {
|
||||||
return (emoji.name === reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]);
|
return (emoji.name === name);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -103,17 +100,15 @@ 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(reaction);
|
importEmoji();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
importEmoji(reaction);
|
importEmoji();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
os.contextMenu(menuItems, ev);
|
os.contextMenu(menuItems, ev);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user