feat(page-editor.el.note): also add delayed load

This commit is contained in:
Outvi V 2025-06-03 00:33:41 +08:00
parent b83123003e
commit fd22f5770d
2 changed files with 16 additions and 3 deletions

View file

@ -36,6 +36,7 @@ import { i18n } from '@/i18n.js';
const props = defineProps<{
modelValue: Misskey.entities.PageBlock & { type: 'note' };
index: number;
}>();
const emit = defineEmits<{
@ -59,7 +60,13 @@ watch(id, async () => {
...props.modelValue,
note: id.value,
});
note.value = await retryOnThrottled(() => misskeyApi('notes/show', { noteId: id.value }));
const timeoutId = window.setTimeout(async () => {
note.value = await retryOnThrottled(() => misskeyApi('notes/show', { noteId: id.value }));
}, 500 * props.index); // rate limit is 2 reqs per sec
return () => {
window.clearTimeout(timeoutId);
}
}, {
immediate: true,
});

View file

@ -5,10 +5,16 @@ SPDX-License-Identifier: AGPL-3.0-only
<template>
<Sortable :modelValue="modelValue" tag="div" itemKey="id" handle=".drag-handle" :group="{ name: 'blocks' }" :animation="150" :swapThreshold="0.5" @update:modelValue="v => emit('update:modelValue', v)">
<template #item="{element}">
<template #item="{element, index}">
<div :class="$style.item">
<!-- divが無いとエラーになる https://github.com/SortableJS/vue.draggable.next/issues/189 -->
<component :is="getComponent(element.type)" :modelValue="element" @update:modelValue="updateItem" @remove="() => removeItem(element)"/>
<component
:is="getComponent(element.type)"
:modelValue="element"
:index="index"
@update:modelValue="updateItem"
@remove="() => removeItem(element)"
/>
</div>
</template>
</Sortable>