This commit is contained in:
tamaina
2023-01-16 09:39:58 +00:00
parent 9d64ac6d6f
commit 21e4c3dfe9
8 changed files with 74 additions and 61 deletions

View File

@@ -41,11 +41,12 @@ import MkTab from '@/components/MkTab.vue';
import * as os from '@/os';
import { customEmojis, getCustomEmojiCategories, getCustomEmojiTags } from '@/custom-emojis';
import { i18n } from '@/i18n';
import * as Misskey from 'misskey-js';
const customEmojiCategories = getCustomEmojiCategories();
const customEmojiTags = getCustomEmojiTags();
let q = $ref('');
let searchEmojis = $ref(null);
let searchEmojis = $ref<Misskey.entities.CustomEmoji[]>(null);
let selectedTags = $ref(new Set());
function search() {
@@ -55,9 +56,9 @@ function search() {
}
if (selectedTags.size === 0) {
searchEmojis = customEmojis.filter(emoji => emoji.name.includes(q) || emoji.aliases.includes(q));
searchEmojis = customEmojis.value.filter(emoji => emoji.name.includes(q) || emoji.aliases.includes(q));
} else {
searchEmojis = customEmojis.filter(emoji => (emoji.name.includes(q) || emoji.aliases.includes(q)) && [...selectedTags].every(t => emoji.aliases.includes(t)));
searchEmojis = customEmojis.value.filter(emoji => (emoji.name.includes(q) || emoji.aliases.includes(q)) && [...selectedTags].every(t => emoji.aliases.includes(t)));
}
}

View File

@@ -79,6 +79,7 @@ import { selectFile, selectFiles } from '@/scripts/select-file';
import * as os from '@/os';
import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata';
import { fetchCustomEmojis } from '@/custom-emojis';
const emojisPaginationComponent = shallowRef<InstanceType<typeof MkPagination>>();
@@ -130,6 +131,7 @@ const add = async (ev: MouseEvent) => {
})));
promise.then(() => {
emojisPaginationComponent.value.reload();
fetchCustomEmojis();
});
os.promiseDialog(promise);
};
@@ -147,6 +149,7 @@ const edit = (emoji) => {
} else if (result.deleted) {
emojisPaginationComponent.value.removeItem((item) => item.id === emoji.id);
}
fetchCustomEmojis();
},
}, 'closed');
};
@@ -220,6 +223,7 @@ const setCategoryBulk = async () => {
category: result,
});
emojisPaginationComponent.value.reload();
fetchCustomEmojis();
};
const addTagBulk = async () => {
@@ -232,6 +236,7 @@ const addTagBulk = async () => {
aliases: result.split(' '),
});
emojisPaginationComponent.value.reload();
fetchCustomEmojis();
};
const removeTagBulk = async () => {
@@ -244,6 +249,7 @@ const removeTagBulk = async () => {
aliases: result.split(' '),
});
emojisPaginationComponent.value.reload();
fetchCustomEmojis();
};
const setTagBulk = async () => {
@@ -256,6 +262,7 @@ const setTagBulk = async () => {
aliases: result.split(' '),
});
emojisPaginationComponent.value.reload();
fetchCustomEmojis();
};
const delBulk = async () => {
@@ -268,6 +275,7 @@ const delBulk = async () => {
ids: selectedEmojis.value,
});
emojisPaginationComponent.value.reload();
fetchCustomEmojis();
};
const headerActions = $computed(() => [{

View File

@@ -313,7 +313,7 @@ let preview_mention = $ref('@example');
let preview_hashtag = $ref('#test');
let preview_url = $ref('https://example.com');
let preview_link = $ref(`[${i18n.ts._mfm.dummy}](https://example.com)`);
let preview_emoji = $ref(customEmojis.length ? `:${customEmojis[0].name}:` : ':emojiname:');
let preview_emoji = $ref(customEmojis.value.length ? `:${customEmojis.value[0].name}:` : ':emojiname:');
let preview_bold = $ref(`**${i18n.ts._mfm.dummy}**`);
let preview_small = $ref(`<small>${i18n.ts._mfm.dummy}</small>`);
let preview_center = $ref(`<center>${i18n.ts._mfm.dummy}</center>`);