better category null handling

This commit is contained in:
tamaina
2023-01-22 17:33:20 +00:00
parent 0d44129ae3
commit 93dd0638ad
2 changed files with 15 additions and 5 deletions

View File

@@ -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<Misskey.entities.CustomEmoji[]>(storageCache ? JSON.parse(storageCache) : []);
export const customEmojiCategories = computed<string[]>(() => {
export const customEmojiCategories = computed<[ ...string[], null ]>(() => {
const categories = new Set<string>();
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 => {