setupTippy,
showScores,
} from "../../utils";
-import { amCommunityCreator } from "../../utils/roles/am-community-creator";
-import { canAdmin } from "../../utils/roles/can-admin";
-import { canMod } from "../../utils/roles/can-mod";
-import { isAdmin } from "../../utils/roles/is-admin";
-import { isBanned } from "../../utils/roles/is-banned";
-import { isMod } from "../../utils/roles/is-mod";
+import amCommunityCreator from "../../utils/roles/am-community-creator";
+import canAdmin from "../../utils/roles/can-admin";
+import canMod from "../../utils/roles/can-mod";
+import isAdmin from "../../utils/roles/is-admin";
+import isBanned from "../../utils/roles/is-banned";
+import isMod from "../../utils/roles/is-mod";
import { Icon, PurgeWarning, Spinner } from "../common/icon";
import { MomentTime } from "../common/moment-time";
import { CommunityLink } from "../community/community-link";
-import { isBrowser } from "./is-browser";
+import isBrowser from "./is-browser";
-export function canShare() {
+export default function canShare() {
return isBrowser() && !!navigator.canShare;
}
-export function isBrowser() {
+export default function isBrowser() {
return typeof window !== "undefined";
}
-import { isBrowser } from "./is-browser";
+import isBrowser from "./is-browser";
-export function share(shareData: ShareData) {
+export default function share(shareData: ShareData) {
if (isBrowser()) {
navigator.share(shareData);
}
-export function debounce<T extends any[], R>(
+export default function debounce<T extends any[], R>(
func: (...e: T) => R,
wait = 1000,
immediate = false
-import { isBrowser } from "../browser/is-browser";
+import isBrowser from "../browser/is-browser";
-export function getQueryParams<T extends Record<string, any>>(processors: {
+export default function getQueryParams<
+ T extends Record<string, any>
+>(processors: {
[K in keyof T]: (param: string) => T[K];
}): T {
if (isBrowser()) {
-export function getQueryString<T extends Record<string, string | undefined>>(
- obj: T
-) {
+export default function getQueryString<
+ T extends Record<string, string | undefined>
+>(obj: T) {
return Object.entries(obj)
.filter(([, val]) => val !== undefined && val !== null)
.reduce(
-import { sleep } from "./sleep";
+import sleep from "./sleep";
/**
* Polls / repeatedly runs a promise, every X milliseconds
*/
-export async function poll(promiseFn: any, millis: number) {
+export default async function poll(promiseFn: any, millis: number) {
if (window.document.visibilityState !== "hidden") {
await promiseFn();
}
-export function sleep(millis: number): Promise<void> {
+export default function sleep(millis: number): Promise<void> {
return new Promise(resolve => setTimeout(resolve, millis));
}
import { UserService } from "../../services";
-export function amAdmin(myUserInfo = UserService.Instance.myUserInfo): boolean {
+export default function amAdmin(
+ myUserInfo = UserService.Instance.myUserInfo
+): boolean {
return myUserInfo?.local_user_view.person.admin ?? false;
}
import { CommunityModeratorView } from "lemmy-js-client";
import { UserService } from "../../services";
-export function amCommunityCreator(
+export default function amCommunityCreator(
creator_id: number,
mods?: CommunityModeratorView[],
myUserInfo = UserService.Instance.myUserInfo
import { CommunityModeratorView } from "lemmy-js-client";
import { UserService } from "../../services";
-import { isMod } from "./is-mod";
+import isMod from "./is-mod";
-export function amMod(
+export default function amMod(
mods?: CommunityModeratorView[],
myUserInfo = UserService.Instance.myUserInfo
): boolean {
import { PersonView } from "lemmy-js-client";
import { UserService } from "../../services";
-export function amSiteCreator(
+export default function amSiteCreator(
creator_id: number,
admins?: PersonView[],
myUserInfo = UserService.Instance.myUserInfo
import { CommunityModeratorView } from "lemmy-js-client";
import { UserService } from "../../services";
-export function amTopMod(
+export default function amTopMod(
mods: CommunityModeratorView[],
myUserInfo = UserService.Instance.myUserInfo
): boolean {
import { PersonView } from "lemmy-js-client";
import { UserService } from "../../services";
-import { canMod } from "./can-mod";
+import canMod from "./can-mod";
-export function canAdmin(
+export default function canAdmin(
creatorId: number,
admins?: PersonView[],
myUserInfo = UserService.Instance.myUserInfo,
import { GetSiteResponse } from "lemmy-js-client";
import { UserService } from "../../services";
-import { amAdmin } from "./am-admin";
+import amAdmin from "./am-admin";
-export function canCreateCommunity(
+export default function canCreateCommunity(
siteRes: GetSiteResponse,
myUserInfo = UserService.Instance.myUserInfo
): boolean {
import { CommunityModeratorView, PersonView } from "lemmy-js-client";
import { UserService } from "../../services";
-export function canMod(
+export default function canMod(
creator_id: number,
mods?: CommunityModeratorView[],
admins?: PersonView[],
import { PersonView } from "lemmy-js-client";
-export function isAdmin(creatorId: number, admins?: PersonView[]): boolean {
+export default function isAdmin(
+ creatorId: number,
+ admins?: PersonView[]
+): boolean {
return admins?.map(a => a.person.id).includes(creatorId) ?? false;
}
import { Person } from "lemmy-js-client";
-export function isBanned(ps: Person): boolean {
+export default function isBanned(ps: Person): boolean {
const expires = ps.ban_expires;
// Add Z to convert from UTC date
// TODO this check probably isn't necessary anymore
import { CommunityModeratorView } from "lemmy-js-client";
-export function isMod(
+export default function isMod(
creatorId: number,
mods?: CommunityModeratorView[]
): boolean {