remove dep on delay lib

This commit is contained in:
fyears
2024-04-04 21:58:52 +08:00
parent cfe316f690
commit 83e0073134
3 changed files with 12 additions and 4 deletions
+9 -1
View File
@@ -513,6 +513,14 @@ export const stringToFragment = (string: string) => {
return wrapper.content;
};
/**
* https://stackoverflow.com/questions/39538473/using-settimeout-on-promise-chain
* @param ms
* @returns
*/
export const delay = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms));
/**
* https://forum.obsidian.md/t/css-to-show-status-bar-on-mobile-devices/77185
* @param op
@@ -550,7 +558,7 @@ export const changeMobileStatusBar = (
k.className.contains("mobile-toolbar")
) {
// have to wait, otherwise the height is not correct??
await new Promise((resolve) => setTimeout(resolve, 300));
await delay(300);
const height = window
.getComputedStyle(k as Element)
.getPropertyValue("height");
+3 -2
View File
@@ -1,4 +1,3 @@
import { rangeDelay } from "delay";
import { Dropbox, DropboxAuth } from "dropbox";
import type { files, DropboxResponseError, DropboxResponse } from "dropbox";
import { Vault } from "obsidian";
@@ -12,6 +11,7 @@ import {
} from "./baseTypes";
import {
bufferToArrayBuffer,
delay,
fixEntityListCasesInplace,
getFolderLevels,
hasEmojiInText,
@@ -19,6 +19,7 @@ import {
mkdirpInVault,
} from "./misc";
import { Cipher } from "./encryptUnified";
import { random } from "lodash";
export { Dropbox } from "dropbox";
@@ -292,7 +293,7 @@ async function retryReq<T>(
2
)}`
);
await rangeDelay(secMin * 1000, secMax * 1000);
await delay(random(secMin * 1000, secMax * 1000));
}
}
}