From f2a9194c79524298a23f7fcba7abe8ef1f6077c7 Mon Sep 17 00:00:00 2001 From: tamaina Date: Mon, 16 Jan 2023 10:13:19 +0000 Subject: [PATCH] :v: --- packages/frontend/src/custom-emojis.ts | 1 + .../src/pages/custom-emojis-manager.vue | 21 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/custom-emojis.ts b/packages/frontend/src/custom-emojis.ts index 6d20187ab4..8fd5078bde 100644 --- a/packages/frontend/src/custom-emojis.ts +++ b/packages/frontend/src/custom-emojis.ts @@ -6,6 +6,7 @@ import * as Misskey from 'misskey-js'; const storageCache = miLocalStorage.getItem('emojis'); export const customEmojis = shallowRef(storageCache ? JSON.parse(storageCache) : []); +fetchCustomEmojis(); window.setInterval(fetchCustomEmojis, 1000 * 60 * 10); export async function fetchCustomEmojis() { diff --git a/packages/frontend/src/pages/custom-emojis-manager.vue b/packages/frontend/src/pages/custom-emojis-manager.vue index e113c38a19..00c736a6a2 100644 --- a/packages/frontend/src/pages/custom-emojis-manager.vue +++ b/packages/frontend/src/pages/custom-emojis-manager.vue @@ -79,7 +79,7 @@ import { selectFile, selectFiles } from '@/scripts/select-file'; import * as os from '@/os'; import { i18n } from '@/i18n'; import { definePageMetadata } from '@/scripts/page-metadata'; -import { fetchCustomEmojis } from '@/custom-emojis'; +import { fetchCustomEmojis, customEmojis } from '@/custom-emojis'; const emojisPaginationComponent = shallowRef>(); @@ -146,10 +146,27 @@ const edit = (emoji) => { ...oldEmoji, ...result.updated, })); + + if (customEmojis.value.some(e => e.name === emoji.name)) { + customEmojis.value = [ + { + name: result.updated.name, + aliases: result.updated.aliases, + category: result.updated.category, + }, + ...customEmojis.value, + ]; + } else { + customEmojis.value = customEmojis.value.map(e => e.name !== emoji.name ? e : { + name: result.updated.name, + aliases: result.updated.aliases, + category: result.updated.category, + }); + } } else if (result.deleted) { emojisPaginationComponent.value.removeItem((item) => item.id === emoji.id); + customEmojis.value = customEmojis.value.filter(e => e.name !== emoji.name); } - fetchCustomEmojis(); }, }, 'closed'); };