don't await in <setup>

`defineAsyncComponent` exists for exactly this purpose…
This commit is contained in:
dakkar 2024-06-21 11:41:08 +01:00
parent 513a8e5de4
commit 385ecc30a3
5 changed files with 29 additions and 23 deletions

View File

@ -32,17 +32,18 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { shallowRef, ref } from 'vue';
import { defineAsyncComponent, shallowRef, ref } from 'vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
import MkPagination, { Paging } from '@/components/MkPagination.vue';
import { i18n } from '@/i18n.js';
import { infoImageUrl } from '@/instance.js';
import { defaultStore } from '@/store.js';
const MkNote = (
(defaultStore.state.noteDesign === 'misskey') ? (await import('@/components/MkNote.vue')).default :
(defaultStore.state.noteDesign === 'sharkey') ? (await import('@/components/SkNote.vue')).default :
null);
const MkNote = defineAsyncComponent(() =>
(defaultStore.state.noteDesign === 'misskey') ? import('@/components/MkNote.vue') :
(defaultStore.state.noteDesign === 'sharkey') ? import('@/components/SkNote.vue') :
null
);
const props = defineProps<{
pagination: Paging;

View File

@ -24,7 +24,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { onUnmounted, onDeactivated, onMounted, computed, shallowRef, onActivated } from 'vue';
import { defineAsyncComponent, onUnmounted, onDeactivated, onMounted, computed, shallowRef, onActivated } from 'vue';
import MkPagination from '@/components/MkPagination.vue';
import XNotification from '@/components/MkNotification.vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
@ -36,10 +36,11 @@ import { defaultStore } from '@/store.js';
import MkPullToRefresh from '@/components/MkPullToRefresh.vue';
import * as Misskey from 'misskey-js';
const MkNote = (
(defaultStore.state.noteDesign === 'misskey') ? (await import('@/components/MkNote.vue')).default :
(defaultStore.state.noteDesign === 'sharkey') ? (await import('@/components/SkNote.vue')).default :
null);
const MkNote = defineAsyncComponent(() =>
(defaultStore.state.noteDesign === 'misskey') ? import('@/components/MkNote.vue') :
(defaultStore.state.noteDesign === 'sharkey') ? import('@/components/SkNote.vue') :
null
);
const props = defineProps<{
excludeTypes?: typeof notificationTypes[number][];

View File

@ -28,15 +28,17 @@ SPDX-License-Identifier: AGPL-3.0-only
<script lang="ts" setup>
import MkPagination from '@/components/MkPagination.vue';
import MkDateSeparatedList from '@/components/MkDateSeparatedList.vue';
import { defineAsyncComponent } from 'vue';
import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { infoImageUrl } from '@/instance.js';
import { defaultStore } from '@/store.js';
const MkNote = (
(defaultStore.state.noteDesign === 'misskey') ? (await import('@/components/MkNote.vue')).default :
(defaultStore.state.noteDesign === 'sharkey') ? (await import('@/components/SkNote.vue')).default :
null);
const MkNote = defineAsyncComponent(() =>
(defaultStore.state.noteDesign === 'misskey') ? import('@/components/MkNote.vue') :
(defaultStore.state.noteDesign === 'sharkey') ? import('@/components/SkNote.vue') :
null
);
const pagination = {
endpoint: 'i/favorites' as const,

View File

@ -48,7 +48,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { computed, watch, ref } from 'vue';
import { defineAsyncComponent, computed, watch, ref } from 'vue';
import * as Misskey from 'misskey-js';
import type { Paging } from '@/components/MkPagination.vue';
import MkNotes from '@/components/MkNotes.vue';
@ -61,10 +61,11 @@ import { dateString } from '@/filters/date.js';
import MkClipPreview from '@/components/MkClipPreview.vue';
import { defaultStore } from '@/store.js';
const MkNoteDetailed = (
(defaultStore.state.noteDesign === 'misskey') ? (await import('@/components/MkNoteDetailed.vue')).default :
(defaultStore.state.noteDesign === 'sharkey') ? (await import('@/components/SkNoteDetailed.vue')).default :
null);
const MkNote = defineAsyncComponent(() =>
(defaultStore.state.noteDesign === 'misskey') ? import('@/components/MkNote.vue') :
(defaultStore.state.noteDesign === 'sharkey') ? import('@/components/SkNote.vue') :
null
);
const props = defineProps<{
noteId: string;

View File

@ -189,10 +189,11 @@ import { misskeyApi } from '@/scripts/misskey-api.js';
import { isFollowingVisibleForMe, isFollowersVisibleForMe } from '@/scripts/isFfVisibleForMe.js';
import { useRouter } from '@/router/supplier.js';
const MkNote = (
(defaultStore.state.noteDesign === 'misskey') ? (await import('@/components/MkNote.vue')).default :
(defaultStore.state.noteDesign === 'sharkey') ? (await import('@/components/SkNote.vue')).default :
null);
const MkNote = defineAsyncComponent(() =>
(defaultStore.state.noteDesign === 'misskey') ? import('@/components/MkNote.vue') :
(defaultStore.state.noteDesign === 'sharkey') ? import('@/components/SkNote.vue') :
null
);
function calcAge(birthdate: string): number {
const date = new Date(birthdate);