hostname,
mdToHtml,
myAuthRequired,
- numToSI,
} from "../../utils";
+import { amAdmin } from "../../utils/roles/am-admin";
+import { amMod } from "../../utils/roles/am-mod";
+import { amTopMod } from "../../utils/roles/am-top-mod";
+ import { Badges } from "../common/badges";
import { BannerIconHeader } from "../common/banner-icon-header";
import { Icon, PurgeWarning, Spinner } from "../common/icon";
import { CommunityForm } from "../community/community-form";
import Toastify from "toastify-js";
import { getHttpBase } from "./env";
import { i18n } from "./i18next";
- import { CommentNodeI, DataType, IsoData, VoteType } from "./interfaces";
+ import {
+ CommentNodeI,
+ DataType,
+ IsoData,
+ RouteData,
+ VoteType,
+ } from "./interfaces";
import { HttpService, UserService } from "./services";
+import { isBrowser } from "./utils/browser/is-browser";
+import { debounce } from "./utils/helpers/debounce";
+import { groupBy } from "./utils/helpers/group-by";
+ import { RequestState } from "./services/HttpService";
let Tribute: any;
if (isBrowser()) {
`;
}
- export function setIsoData(context: any): IsoData {
-export function isBrowser() {
- return typeof window !== "undefined";
-}
-
+ export function setIsoData<T extends RouteData>(context: any): IsoData<T> {
// If its the browser, you need to deserialize the data from the window
if (isBrowser()) {
return window.isoData;
return myVote == -1 ? 0 : -1;
}
}
-
-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);
-}
+
+ export type RouteDataResponse<T extends Record<string, any>> = {
+ [K in keyof T]: RequestState<T[K]>;
+ };