Compare commits
38 Commits
develop
...
12.119.0-s
Author | SHA1 | Date | |
---|---|---|---|
272a4f9b81 | |||
a6ec46fe65 | |||
23c0fe7fe2 | |||
424bdfa9bf | |||
62e461e02c | |||
94c362cbb6 | |||
f1ef1d83d8 | |||
b730f49652 | |||
e07272b1de | |||
9fcb205364 | |||
a3862af515 | |||
e8385487ed | |||
f676bd069d | |||
13ff53e3a5 | |||
ab13bb419b | |||
7ffc58ccd8 | |||
58fbe015be | |||
c2f4b08c1b | |||
d9c04a1df3 | |||
cfc1016ac7 | |||
8624730752 | |||
3e5feaee3d | |||
d7e9ed7301 | |||
7ff4f3d30f | |||
52c06b5b2a | |||
ebcd23ba0c | |||
7e24765ccf | |||
03ac1c18a7 | |||
4c1104241a | |||
d304f94cdd | |||
fbe2d7dc69 | |||
b10be4ee89 | |||
df5c410295 | |||
c38c0bd6b0 | |||
cab9229e45 | |||
2aa081423e | |||
b6357750b0 | |||
70267e2a9f |
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "misskey",
|
"name": "misskey",
|
||||||
"version": "12.119.0-simkey-v10111",
|
"version": "12.119.0-simkey-v8",
|
||||||
"codename": "indigo",
|
"codename": "indigo",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
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): Promise<void> {
|
export async function openReactionImportMenu(ev: MouseEvent, reaction: string) {
|
||||||
if (!reaction) return;
|
|
||||||
|
|
||||||
const host = reaction.match(/(?<=@).*\.*(?=:)/g)?.[0];
|
const getEmojiObject = emojiId => new Promise<Record<string, any> | null>(async resolve => {
|
||||||
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,
|
||||||
@ -37,9 +33,14 @@ export async function openReactionImportMenu(ev: MouseEvent, reaction: string):
|
|||||||
resolve(id[0]);
|
resolve(id[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
const getEmojiId = async (): Promise<string | null> => {
|
const getEmojiId = async (emojiName: string) => {
|
||||||
|
|
||||||
|
const isLocal = (emojiName.match(/(?<=@).*\.*(?=:)/g) == null || emojiName.match(/(?<=@).*\.*(?=:)/g)[0] == '.');
|
||||||
if (isLocal) return null;
|
if (isLocal) return null;
|
||||||
if (!host || !name) return null;
|
const host = emojiName.match(/(?<=@).*\.*(?=:)/g)[0];
|
||||||
|
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,
|
||||||
@ -47,13 +48,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 (): Promise<void> => {
|
const importEmoji = async (emojiName: string) => {
|
||||||
const emojiId = await getEmojiId();
|
const emojiId = await getEmojiId(emojiName);
|
||||||
if (!await emojiId) return;
|
if (!await emojiId) return;
|
||||||
os.api('admin/emoji/copy', {
|
os.api('admin/emoji/copy', {
|
||||||
emojiId: emojiId,
|
emojiId: emojiId,
|
||||||
@ -62,6 +63,9 @@ 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,
|
||||||
@ -69,19 +73,18 @@ 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: (): void => {
|
action: () => {
|
||||||
copyToClipboard(isCustom ? `:${name}:` : reaction);
|
copyToClipboard(reaction => {
|
||||||
|
if (reaction.startsWith(':')) {
|
||||||
|
return `:${reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]}:` || reaction;
|
||||||
|
} else {
|
||||||
|
return reaction;
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
}];
|
}];
|
||||||
|
const emojiId = await getEmojiId(reaction) ? await getEmojiId(reaction) : reaction;
|
||||||
const emojiId = await getEmojiId() ? await getEmojiId() : reaction;
|
if (reaction.startsWith(':') && emojiId) {
|
||||||
|
|
||||||
if (
|
|
||||||
isCustom &&
|
|
||||||
emojiId &&
|
|
||||||
($i?.isAdmin || $i?.isModerator) &&
|
|
||||||
!isLocal
|
|
||||||
) {
|
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
type: 'button',
|
type: 'button',
|
||||||
icon: 'fas fa-download',
|
icon: 'fas fa-download',
|
||||||
@ -90,7 +93,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 === name);
|
return (emoji.name === reaction.match(/(?<=:).*(?=@.*\.*(?=:))/g)[0]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -100,15 +103,17 @@ 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(reaction);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
importEmoji();
|
importEmoji(reaction);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
os.contextMenu(menuItems, ev);
|
os.contextMenu(menuItems, ev);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user