From 92f30320315d9934d41d496cf02a4f53e67f7795 Mon Sep 17 00:00:00 2001 From: pen <121443048+penginn-0@users.noreply.github.com> Date: Mon, 24 Jun 2024 03:08:45 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=E6=9C=AA=E3=83=AD=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E6=99=82=E3=81=AB=E3=82=A4=E3=83=B3=E3=82=B9=E3=82=BF?= =?UTF-8?q?=E3=83=B3=E3=82=B9=E7=94=BB=E9=9D=A2=E3=81=8C=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E3=81=AB=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA=E3=81=84?= =?UTF-8?q?=20(#113)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: kozakura913 <98575220+kozakura913@users.noreply.github.com> Co-authored-by: pen --- packages/frontend/src/instance.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/frontend/src/instance.ts b/packages/frontend/src/instance.ts index 9fe0da710f..8e7cfc3440 100644 --- a/packages/frontend/src/instance.ts +++ b/packages/frontend/src/instance.ts @@ -28,7 +28,7 @@ if (providedAt > cachedAt) { // TODO: instanceをリアクティブにするかは再考の余地あり -export const instance: Misskey.entities.MetaResponse = reactive(cachedMeta ?? {}); +export const instance: Misskey.entities.MetaDetailed = reactive(cachedMeta ?? {}); export const serverErrorImageUrl = computed(() => instance.serverErrorImageUrl ?? DEFAULT_SERVER_ERROR_IMAGE_URL); @@ -38,17 +38,17 @@ export const notFoundImageUrl = computed(() => instance.notFoundImageUrl ?? DEFA export const isEnabledUrlPreview = computed(() => instance.enableUrlPreview ?? true); -export async function fetchInstance(force = false): Promise { +export async function fetchInstance(force = false): Promise { if (!force) { const cachedAt = miLocalStorage.getItem('instanceCachedAt') ? parseInt(miLocalStorage.getItem('instanceCachedAt')!) : 0; if (Date.now() - cachedAt < 1000 * 60 * 60) { - return; + return instance; } } const meta = await misskeyApi('meta', { - detail: false, + detail: true, }); for (const [k, v] of Object.entries(meta)) { @@ -57,4 +57,5 @@ export async function fetchInstance(force = false): Promise { miLocalStorage.setItem('instance', JSON.stringify(instance)); miLocalStorage.setItem('instanceCachedAt', Date.now().toString()); + return instance; }