From 4a0e9686625a399529879ea92f51d93bd7204340 Mon Sep 17 00:00:00 2001
From: syuilo <4439005+syuilo@users.noreply.github.com>
Date: Mon, 1 Sep 2025 16:23:05 +0900
Subject: refactor

---
 packages/frontend/src/pages/admin-file.vue | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

(limited to 'packages/frontend/src/pages/admin-file.vue')

diff --git a/packages/frontend/src/pages/admin-file.vue b/packages/frontend/src/pages/admin-file.vue
index 63d3640f9c..608a77c06b 100644
--- a/packages/frontend/src/pages/admin-file.vue
+++ b/packages/frontend/src/pages/admin-file.vue
@@ -4,9 +4,9 @@ SPDX-License-Identifier: AGPL-3.0-only
 -->
 
 <template>
-<XRoot v-if="file != null && info != null" :file="file" :info="info"/>
-<div v-else-if="error != null">Error: {{ error }}</div>
-<MkLoading v-else/>
+<MkSuspense v-slot="{ result }" :p="_fetch_" @resolved="(result) => file = result.file">
+	<XRoot v-if="result.file != null && result.info != null" :file="result.file" :info="result.info"/>
+</MkSuspense>
 </template>
 
 <script lang="ts" setup>
@@ -17,27 +17,21 @@ import { misskeyApi } from '@/utility/misskey-api.js';
 import { i18n } from '@/i18n.js';
 import { definePage } from '@/page.js';
 
-const file = ref<Misskey.entities.DriveFile | null>(null);
-const info = ref<Misskey.entities.AdminDriveShowFileResponse | null>(null);
-
-const error = ref<string | null>(null);
-
 const props = defineProps<{
 	fileId: string,
 }>();
 
-async function _fetch_() {
-	try {
-		file.value = await misskeyApi('drive/files/show', { fileId: props.fileId });
-	} catch (err: any) {
-		error.value = err.message + ' ' + err.id;
-		return;
-	}
-
-	info.value = await misskeyApi('admin/drive/show-file', { fileId: props.fileId });
+function _fetch_() {
+	return Promise.all([
+		misskeyApi('drive/files/show', { fileId: props.fileId }),
+		misskeyApi('admin/drive/show-file', { fileId: props.fileId }),
+	]).then((result) => ({
+		file: result[0],
+		info: result[1],
+	}));
 }
 
-_fetch_();
+const file = ref<Misskey.entities.DriveFile | null>(null);
 
 definePage(() => ({
 	title: file.value ? `${i18n.ts.file}: ${file.value.name}` : i18n.ts.file,
-- 
cgit v1.2.3-freya

