From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Sat, 17 Jun 2023 12:44:47 +0000 (-0400) Subject: Merge branch 'main' into breakout-role-utils X-Git-Url: http://these/git/%22%7Burl%7D/%22https:/image.com/%7B%60%24%7BghostArchiveUrl%7D/%7Brss%7D?a=commitdiff_plain;h=7f48a38b721295417717b6e903d03e2c0736a44f;p=lemmy-ui.git Merge branch 'main' into breakout-role-utils --- 7f48a38b721295417717b6e903d03e2c0736a44f diff --cc src/shared/components/community/sidebar.tsx index 997fe11,720e596..508e5a0 --- a/src/shared/components/community/sidebar.tsx +++ b/src/shared/components/community/sidebar.tsx @@@ -21,11 -24,8 +21,11 @@@ import 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"; diff --cc src/shared/components/home/home.tsx index 9f7c322,4d79bc6..54378f3 --- a/src/shared/components/home/home.tsx +++ b/src/shared/components/home/home.tsx @@@ -71,8 -74,10 +71,9 @@@ import mdToHtml, myAuth, postToCommentSortType, - QueryParams, relTags, restoreScrollPosition, + RouteDataResponse, saveScrollPosition, setIsoData, setupTippy, diff --cc src/shared/components/person/reports.tsx index 187fe4c,99a0333..0be7537 --- a/src/shared/components/person/reports.tsx +++ b/src/shared/components/person/reports.tsx @@@ -23,6 -23,8 +23,7 @@@ import { HttpService, UserService } fro import { FirstLoadService } from "../../services/FirstLoadService"; import { RequestState } from "../../services/HttpService"; import { + RouteDataResponse, - amAdmin, editCommentReport, editPostReport, editPrivateMessageReport, diff --cc src/shared/components/post/create-post.tsx index 63ee390,2789779..7df628b --- a/src/shared/components/post/create-post.tsx +++ b/src/shared/components/post/create-post.tsx @@@ -16,6 -17,8 +17,7 @@@ import } from "../../services/HttpService"; import { Choice, - QueryParams, + RouteDataResponse, enableDownvotes, enableNsfw, getIdFromString, diff --cc src/shared/components/search.tsx index d32e408,054cab0..e56056a --- a/src/shared/components/search.tsx +++ b/src/shared/components/search.tsx @@@ -26,6 -26,8 +26,7 @@@ import { FirstLoadService } from "../se import { HttpService, RequestState } from "../services/HttpService"; import { Choice, - QueryParams, + RouteDataResponse, capitalizeFirstLetter, commentsToFlatNodes, communityToChoice, diff --cc src/shared/utils.ts index 6f6e61c,c7fbca6..be461dc --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@@ -41,11 -43,15 +41,18 @@@ import tippy from "tippy.js" 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()) { @@@ -1011,7 -1153,11 +1023,7 @@@ export function siteBannerCss(banner: s `; } - export function setIsoData(context: any): IsoData { -export function isBrowser() { - return typeof window !== "undefined"; -} - + export function setIsoData(context: any): IsoData { // If its the browser, you need to deserialize the data from the window if (isBrowser()) { return window.isoData; @@@ -1264,3 -1486,22 +1276,7 @@@ export function newVote(voteType: VoteT return myVote == -1 ? 0 : -1; } } + + 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); -}