カスタム絵文字一覧情報をmetaから分離

This commit is contained in:
syuilo
2023-01-09 15:50:25 +09:00
parent e4144a17a4
commit 462acc9eee
17 changed files with 212 additions and 151 deletions

View File

@@ -5,11 +5,11 @@ import { miLocalStorage } from './local-storage';
// TODO: 他のタブと永続化されたstateを同期
const instanceData = miLocalStorage.getItem('instance');
const cached = miLocalStorage.getItem('instance');
// TODO: instanceをリアクティブにするかは再考の余地あり
export const instance: Misskey.entities.InstanceMetadata = reactive(instanceData ? JSON.parse(instanceData) : {
export const instance: Misskey.entities.InstanceMetadata = reactive(cached ? JSON.parse(cached) : {
// TODO: set default values
});
@@ -24,23 +24,3 @@ export async function fetchInstance() {
miLocalStorage.setItem('instance', JSON.stringify(instance));
}
export const emojiCategories = computed(() => {
if (instance.emojis == null) return [];
const categories = new Set();
for (const emoji of instance.emojis) {
categories.add(emoji.category);
}
return Array.from(categories);
});
export const emojiTags = computed(() => {
if (instance.emojis == null) return [];
const tags = new Set();
for (const emoji of instance.emojis) {
for (const tag of emoji.aliases) {
tags.add(tag);
}
}
return Array.from(tags);
});