This commit is contained in:
tamaina
2023-01-22 14:53:24 +00:00
parent a5f54580a9
commit 2f6c45e118
12 changed files with 114 additions and 37 deletions

View File

@@ -2,6 +2,7 @@ import { apiGet } from './os';
import { miLocalStorage } from './local-storage';
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) : []);
@@ -14,7 +15,18 @@ export const customEmojiCategories = computed<string[]>(() => {
});
fetchCustomEmojis();
window.setInterval(fetchCustomEmojis, 1000 * 60 * 10);
stream.on('emojiAdded', emojiData => {
customEmojis.value = [ emojiData.emoji, ...customEmojis.value ]
});
stream.on('emojiUpdated', emojiData => {
customEmojis.value = customEmojis.value.map(item => emojiData.emojis.find(search => search.name === item.name) as Misskey.entities.CustomEmoji ?? item);
});
stream.on('emojiDeleted', emojiData => {
customEmojis.value = customEmojis.value.filter(item => !emojiData.emojis.some(search => search.name === item.name))
});
export async function fetchCustomEmojis() {
const now = Date.now();

View File

@@ -338,11 +338,6 @@ import { fetchCustomEmojis } from './custom-emojis';
}
});
stream.on('emojiAdded', emojiData => {
// TODO
//store.commit('instance/set', );
});
for (const plugin of ColdDeviceStorage.get('plugins').filter(p => p.active)) {
import('./plugin').then(({ install }) => {
install(plugin);