Skip to content

Commit

Permalink
Merge branch 'yojo-art:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
penginn-net authored Jun 23, 2024
2 parents b52f334 + 92f3032 commit 77fd67b
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 77fd67b

Please sign in to comment.