summaryrefslogtreecommitdiff
path: root/packages/frontend/src/components/MkAutocomplete.vue
diff options
context:
space:
mode:
authortamaina <tamaina@hotmail.co.jp>2023-01-16 09:39:58 +0000
committertamaina <tamaina@hotmail.co.jp>2023-01-16 09:39:58 +0000
commit21e4c3dfe9b439a76782ab86be93298de2878ab9 (patch)
treeb8684d49b8b8e17f4199133b4a7ec76affc6fede /packages/frontend/src/components/MkAutocomplete.vue
parent13.0.0 (diff)
downloadmisskey-21e4c3dfe9b439a76782ab86be93298de2878ab9.tar.gz
misskey-21e4c3dfe9b439a76782ab86be93298de2878ab9.tar.bz2
misskey-21e4c3dfe9b439a76782ab86be93298de2878ab9.zip
wip
Diffstat (limited to 'packages/frontend/src/components/MkAutocomplete.vue')
-rw-r--r--packages/frontend/src/components/MkAutocomplete.vue80
1 files changed, 40 insertions, 40 deletions
diff --git a/packages/frontend/src/components/MkAutocomplete.vue b/packages/frontend/src/components/MkAutocomplete.vue
index 702fba9796..ab4bf4f793 100644
--- a/packages/frontend/src/components/MkAutocomplete.vue
+++ b/packages/frontend/src/components/MkAutocomplete.vue
@@ -33,7 +33,7 @@
</template>
<script lang="ts">
-import { markRaw, ref, shallowRef, onUpdated, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
+import { markRaw, ref, shallowRef, computed, onUpdated, onMounted, onBeforeUnmount, nextTick, watch } from 'vue';
import sanitizeHtml from 'sanitize-html';
import contains from '@/scripts/contains';
import { char2twemojiFilePath, char2fluentEmojiFilePath } from '@/scripts/emoji-base';
@@ -61,59 +61,59 @@ type EmojiDef = {
const lib = emojilist.filter(x => x.category !== 'flags');
-const char2path = defaultStore.state.emojiStyle === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath;
+const emojiDb = computed(() => {
+ const char2path = defaultStore.reactiveState.emojiStyle.value === 'twemoji' ? char2twemojiFilePath : char2fluentEmojiFilePath;
-const emjdb: EmojiDef[] = lib.map(x => ({
- emoji: x.char,
- name: x.name,
- url: char2path(x.char),
-}));
+ const unicodeEmojiDB: EmojiDef[] = lib.map(x => ({
+ emoji: x.char,
+ name: x.name,
+ url: char2path(x.char),
+ }));
-for (const x of lib) {
- if (x.keywords) {
- for (const k of x.keywords) {
- emjdb.push({
- emoji: x.char,
- name: k,
- aliasOf: x.name,
- url: char2path(x.char),
- });
+ for (const x of lib) {
+ if (x.keywords) {
+ for (const k of x.keywords) {
+ unicodeEmojiDB.push({
+ emoji: x.char,
+ name: k,
+ aliasOf: x.name,
+ url: char2path(x.char),
+ });
+ }
}
}
-}
-emjdb.sort((a, b) => a.name.length - b.name.length);
+ unicodeEmojiDB.sort((a, b) => a.name.length - b.name.length);
-//#region Construct Emoji DB
-const emojiDefinitions: EmojiDef[] = [];
+ //#region Construct Emoji DB
+ const customEmojiDB: EmojiDef[] = [];
-for (const x of customEmojis) {
- emojiDefinitions.push({
- name: x.name,
- emoji: `:${x.name}:`,
- isCustomEmoji: true,
- });
+ for (const x of customEmojis.value) {
+ customEmojiDB.push({
+ name: x.name,
+ emoji: `:${x.name}:`,
+ isCustomEmoji: true,
+ });
- if (x.aliases) {
- for (const alias of x.aliases) {
- emojiDefinitions.push({
- name: alias,
- aliasOf: x.name,
- emoji: `:${x.name}:`,
- isCustomEmoji: true,
- });
+ if (x.aliases) {
+ for (const alias of x.aliases) {
+ customEmojiDB.push({
+ name: alias,
+ aliasOf: x.name,
+ emoji: `:${x.name}:`,
+ isCustomEmoji: true,
+ });
+ }
}
}
-}
-emojiDefinitions.sort((a, b) => a.name.length - b.name.length);
+ customEmojiDB.sort((a, b) => a.name.length - b.name.length);
-const emojiDb = markRaw(emojiDefinitions.concat(emjdb));
-//#endregion
+ return markRaw([ ...customEmojiDB, ...unicodeEmojiDB ]);
+});
export default {
emojiDb,
- emojiDefinitions,
emojilist,
};
</script>
@@ -230,7 +230,7 @@ function exec() {
} else if (props.type === 'emoji') {
if (!props.q || props.q === '') {
// 最近使った絵文字をサジェスト
- emojis.value = defaultStore.state.recentlyUsedEmojis.map(emoji => emojiDb.find(dbEmoji => dbEmoji.emoji === emoji)).filter(x => x) as EmojiDef[];
+ emojis.value = defaultStore.state.recentlyUsedEmojis.map(emoji => emojiDb.value.find(dbEmoji => dbEmoji.emoji === emoji)).filter(x => x) as EmojiDef[];
return;
}