mirror of
https://codeberg.org/yeentown/barkey.git
synced 2025-07-07 20:44:34 +00:00
feat(page-editor.el.note): also add delayed load
This commit is contained in:
parent
b83123003e
commit
fd22f5770d
2 changed files with 16 additions and 3 deletions
|
@ -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,
|
||||
});
|
||||
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,
|
||||
});
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue