From: abias Date: Fri, 16 Jun 2023 02:11:19 +0000 (-0400) Subject: Merge branch 'main' into route-data-refactor X-Git-Url: http://these/git/%7B%60/feeds/front/static/%7BpictrsAvatarThumbnail%28this.props.site.site.icon%29%7D?a=commitdiff_plain;h=88842a52c081ca0c84014f4f92f160590b1dca18;p=lemmy-ui.git Merge branch 'main' into route-data-refactor --- 88842a52c081ca0c84014f4f92f160590b1dca18 diff --cc src/shared/utils.ts index 83cc6f1,067b78a..cf59086 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@@ -1494,6 -1495,17 +1498,21 @@@ export function newVote(voteType: VoteT } } +export type RouteDataResponse> = { + [K in keyof T]: RequestState>; +}; ++ + function sleep(millis: number): Promise { + return new Promise(resolve => setTimeout(resolve, millis)); + } + + /** + * Polls / repeatedly runs a promise, every X milliseconds + */ + export async function poll(promiseFn: any, millis: number) { + if (window.document.visibilityState !== "hidden") { + await promiseFn(); + } + await sleep(millis); + return poll(promiseFn, millis); + }