chore: lint

This commit is contained in:
Outvi V 2025-05-31 10:09:46 +08:00
parent 85bc401e47
commit 5e6c6fccc4

View file

@ -25,19 +25,19 @@ const props = defineProps<{
const note = ref<Misskey.entities.Note | null>(null);
let timeoutId = null;
// eslint-disable-next-line id-denylist
let timeoutId: ReturnType<typeof window.setTimeout> | null = null;
async function sleep(ms: number): Promise<void> {
return new Promise((resolve) => {
setTimeout(() => {
resolve()
window.setTimeout(() => {
resolve();
}, ms);
});
}
async function retryOnThrottle<T>(f: ()=>Promise<T>, retryCount: number = 5): Promise<T> {
let lastResult: T = undefined!;
const r = Math.random();
async function retryOnThrottle<T>(f: ()=>Promise<T>, retryCount = 5): Promise<T> {
let lastResult: T;
for (let i = 0; i < retryCount; i++) {
const [ok, resultOrError] = await f()
.then(result => [true, result])
@ -50,7 +50,7 @@ async function retryOnThrottle<T>(f: ()=>Promise<T>, retryCount: number = 5): Pr
}
// RATE_LIMIT_EXCEEDED
if (resultOrError?.id === "d5826d14-3982-4d2e-8011-b9e9f02499ef") {
if (resultOrError?.id === 'd5826d14-3982-4d2e-8011-b9e9f02499ef') {
await sleep(resultOrError?.info?.fullResetMs ?? 1000);
continue;
}
@ -62,7 +62,7 @@ async function retryOnThrottle<T>(f: ()=>Promise<T>, retryCount: number = 5): Pr
onMounted(() => {
if (props.block.note == null) return;
timeoutId = setTimeout(() => {
timeoutId = window.setTimeout(() => {
retryOnThrottle(() => misskeyApi('notes/show', { noteId: props.block.note })).then(result => {
note.value = result;
});
@ -70,7 +70,9 @@ onMounted(() => {
});
onUnmounted(() => {
if (timeoutId !== null) clearTimeout(timeoutId);
if (timeoutId !== null) {
window.clearTimeout(timeoutId);
}
});
</script>