Skip to content

Commit

Permalink
Fix:未ログイン時にインスタンス画面が正常に表示されない (yojo-art#113)
Browse files Browse the repository at this point in the history
Co-authored-by: kozakura913 <98575220+kozakura913@users.noreply.github.com>
Co-authored-by: pen <pen@penginn.net>
  • Loading branch information
3 people authored Jun 23, 2024
1 parent 5f3f0f1 commit 92f3032
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/frontend/src/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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<void> {
export async function fetchInstance(force = false): Promise<Misskey.entities.MetaDetailed> {
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)) {
Expand All @@ -57,4 +57,5 @@ export async function fetchInstance(force = false): Promise<void> {

miLocalStorage.setItem('instance', JSON.stringify(instance));
miLocalStorage.setItem('instanceCachedAt', Date.now().toString());
return instance;
}

0 comments on commit 92f3032

Please sign in to comment.