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

View File

@ -72,7 +72,6 @@
"aws-crt": "^1.20.0",
"buffer": "^6.0.3",
"crypto-browserify": "^3.12.0",
"delay": "^6.0.0",
"dropbox": "^10.34.0",
"emoji-regex": "^10.3.0",
"http-status-codes": "^2.3.0",

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");

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));
}
}
}