better category null handling
This commit is contained in:
		@@ -60,7 +60,15 @@
 | 
			
		||||
		</div>
 | 
			
		||||
		<div v-once class="group">
 | 
			
		||||
			<header class="_acrylic">{{ i18n.ts.customEmojis }}</header>
 | 
			
		||||
			<XSection v-for="category in customEmojiCategories" :key="'custom:' + category" :initial-shown="false" :emojis="computed(() => customEmojis.filter(e => e.category === category).map(e => ':' + e.name + ':'))" @chosen="chosen">{{ category || i18n.ts.other }}</XSection>
 | 
			
		||||
			<XSection
 | 
			
		||||
				v-for="category in customEmojiCategories"
 | 
			
		||||
				:key="`custom:${category}`"
 | 
			
		||||
				:initial-shown="false"
 | 
			
		||||
				:emojis="computed(() => customEmojis.filter(e => category === null ? e.category == null || e.category === 'null' : e.category === category).map(e => `:${e.name}:`))"
 | 
			
		||||
				@chosen="chosen"
 | 
			
		||||
			>
 | 
			
		||||
				{{ category || i18n.ts.other }}
 | 
			
		||||
			</XSection>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div v-once class="group">
 | 
			
		||||
			<header class="_acrylic">{{ i18n.ts.emoji }}</header>
 | 
			
		||||
 
 | 
			
		||||
@@ -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 => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user