From 93dd0638ade0ba896365f5f9cc1acba103db386e Mon Sep 17 00:00:00 2001 From: tamaina Date: Sun, 22 Jan 2023 17:33:20 +0000 Subject: [PATCH] better category null handling --- packages/frontend/src/components/MkEmojiPicker.vue | 10 +++++++++- packages/frontend/src/custom-emojis.ts | 10 ++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/frontend/src/components/MkEmojiPicker.vue b/packages/frontend/src/components/MkEmojiPicker.vue index b288cb22fe..479d8eb7fb 100644 --- a/packages/frontend/src/components/MkEmojiPicker.vue +++ b/packages/frontend/src/components/MkEmojiPicker.vue @@ -60,7 +60,15 @@
{{ i18n.ts.customEmojis }}
- {{ category || i18n.ts.other }} + + {{ category || i18n.ts.other }} +
{{ i18n.ts.emoji }}
diff --git a/packages/frontend/src/custom-emojis.ts b/packages/frontend/src/custom-emojis.ts index 2cd088993d..4dd2e0909f 100644 --- a/packages/frontend/src/custom-emojis.ts +++ b/packages/frontend/src/custom-emojis.ts @@ -1,17 +1,19 @@ import { apiGet } from './os'; import { miLocalStorage } from './local-storage'; -import { shallowRef, computed, markRaw, watch } from 'vue'; +import { shallowRef, computed, markRaw } from 'vue'; import * as Misskey from 'misskey-js'; import { stream } from '@/stream'; const storageCache = miLocalStorage.getItem('emojis'); export const customEmojis = shallowRef(storageCache ? JSON.parse(storageCache) : []); -export const customEmojiCategories = computed(() => { +export const customEmojiCategories = computed<[ ...string[], null ]>(() => { const categories = new Set(); for (const emoji of customEmojis.value) { - categories.add(emoji.category); + if (emoji.category && emoji.category !== 'null') { + categories.add(emoji.category); + } } - return markRaw(Array.from(categories)); + return markRaw([ ...Array.from(categories), null ]); }); stream.on('emojiAdded', emojiData => {