From 0e4a111f81cceed275d9bec2695f6e401fb654d8 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 12 Nov 2021 02:02:25 +0900 Subject: refactoring Resolve #7779 --- src/client/instance.ts | 52 -------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 src/client/instance.ts (limited to 'src/client/instance.ts') diff --git a/src/client/instance.ts b/src/client/instance.ts deleted file mode 100644 index 6e912aa2e5..0000000000 --- a/src/client/instance.ts +++ /dev/null @@ -1,52 +0,0 @@ -import { computed, reactive } from 'vue'; -import * as Misskey from 'misskey-js'; -import { api } from './os'; - -// TODO: 他のタブと永続化されたstateを同期 - -const data = localStorage.getItem('instance'); - -// TODO: instanceをリアクティブにするかは再考の余地あり - -export const instance: Misskey.entities.InstanceMetadata = reactive(data ? JSON.parse(data) : { - // TODO: set default values -}); - -export async function fetchInstance() { - const meta = await api('meta', { - detail: false - }); - - for (const [k, v] of Object.entries(meta)) { - instance[k] = v; - } - - localStorage.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); -}); - -// このファイルに書きたくないけどここに書かないと何故かVeturが認識しない -declare module '@vue/runtime-core' { - interface ComponentCustomProperties { - $instance: typeof instance; - } -} -- cgit v1.2.3-freya