]> Untitled Git - lemmy-ui.git/commitdiff
Merge branch 'main' into route-data-refactor
authorabias <abias1122@gmail.com>
Fri, 16 Jun 2023 02:11:19 +0000 (22:11 -0400)
committerabias <abias1122@gmail.com>
Fri, 16 Jun 2023 02:11:19 +0000 (22:11 -0400)
1  2 
src/server/index.tsx
src/shared/components/home/home.tsx
src/shared/utils.ts

Simple merge
Simple merge
index 83cc6f1adf645b4389d70b7f5367ebcb646af9f9,067b78ac2a6f5a82974bf91c78ef88c0367737c3..cf59086b8596e56540763048173e6c745b44b660
@@@ -1494,6 -1495,17 +1498,21 @@@ export function newVote(voteType: VoteT
    }
  }
  
 +export type RouteDataResponse<T extends Record<string, any>> = {
 +  [K in keyof T]: RequestState<Exclude<T[K], undefined>>;
 +};
++
+ function sleep(millis: number): Promise<void> {
+   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);
+ }