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<{
|
const props = defineProps<{
|
||||||
modelValue: Misskey.entities.PageBlock & { type: 'note' };
|
modelValue: Misskey.entities.PageBlock & { type: 'note' };
|
||||||
|
index: number;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const emit = defineEmits<{
|
||||||
|
@ -59,7 +60,13 @@ watch(id, async () => {
|
||||||
...props.modelValue,
|
...props.modelValue,
|
||||||
note: id.value,
|
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,
|
immediate: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -5,10 +5,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<template>
|
<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)">
|
<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 :class="$style.item">
|
||||||
<!-- divが無いとエラーになる https://github.com/SortableJS/vue.draggable.next/issues/189 -->
|
<!-- 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>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Sortable>
|
</Sortable>
|
||||||
|
|
Loading…
Add table
Reference in a new issue