mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-08 17:44:16 +00:00
export default everything, will fix type errors next
This commit is contained in:
parent
b1b0fdf5f8
commit
f53d5db007
|
@ -53,12 +53,12 @@ import {
|
|||
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";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { isBrowser } from "./is-browser";
|
||||
import isBrowser from "./is-browser";
|
||||
|
||||
export function canShare() {
|
||||
export default function canShare() {
|
||||
return isBrowser() && !!navigator.canShare;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export function isBrowser() {
|
||||
export default function isBrowser() {
|
||||
return typeof window !== "undefined";
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export function debounce<T extends any[], R>(
|
||||
export default function debounce<T extends any[], R>(
|
||||
func: (...e: T) => R,
|
||||
wait = 1000,
|
||||
immediate = false
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
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()) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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(
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
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();
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export function sleep(millis: number): Promise<void> {
|
||||
export default function sleep(millis: number): Promise<void> {
|
||||
return new Promise(resolve => setTimeout(resolve, millis));
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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 {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { CommunityModeratorView } from "lemmy-js-client";
|
||||
import { UserService } from "../../services";
|
||||
|
||||
export function amTopMod(
|
||||
export default function amTopMod(
|
||||
mods: CommunityModeratorView[],
|
||||
myUserInfo = UserService.Instance.myUserInfo
|
||||
): boolean {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
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 {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
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[],
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
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
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { CommunityModeratorView } from "lemmy-js-client";
|
||||
|
||||
export function isMod(
|
||||
export default function isMod(
|
||||
creatorId: number,
|
||||
mods?: CommunityModeratorView[]
|
||||
): boolean {
|
||||
|
|
Loading…
Reference in a new issue