From: Alec Armbruster <35377827+alectrocute@users.noreply.github.com> Date: Tue, 20 Jun 2023 01:12:42 +0000 (-0400) Subject: export default everything, will fix type errors next X-Git-Url: http://these/git/ui/assets/static/%7Biframely.thumbnail_url%7D?a=commitdiff_plain;h=f53d5db0073c1ee8439365b1ec21f484dc5a2611;p=lemmy-ui.git export default everything, will fix type errors next --- diff --git a/src/shared/components/comment/comment-node.tsx b/src/shared/components/comment/comment-node.tsx index ebf7cb2..bcbd605 100644 --- a/src/shared/components/comment/comment-node.tsx +++ b/src/shared/components/comment/comment-node.tsx @@ -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"; diff --git a/src/shared/utils/browser/can-share.ts b/src/shared/utils/browser/can-share.ts index bec7e80..f141fe5 100644 --- a/src/shared/utils/browser/can-share.ts +++ b/src/shared/utils/browser/can-share.ts @@ -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; } diff --git a/src/shared/utils/browser/is-browser.ts b/src/shared/utils/browser/is-browser.ts index 4139b25..cc6ba88 100644 --- a/src/shared/utils/browser/is-browser.ts +++ b/src/shared/utils/browser/is-browser.ts @@ -1,3 +1,3 @@ -export function isBrowser() { +export default function isBrowser() { return typeof window !== "undefined"; } diff --git a/src/shared/utils/browser/share.ts b/src/shared/utils/browser/share.ts index b1d1b5b..9ae9497 100644 --- a/src/shared/utils/browser/share.ts +++ b/src/shared/utils/browser/share.ts @@ -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); } diff --git a/src/shared/utils/helpers/debounce.ts b/src/shared/utils/helpers/debounce.ts index d5cd701..7e3b6f0 100644 --- a/src/shared/utils/helpers/debounce.ts +++ b/src/shared/utils/helpers/debounce.ts @@ -1,4 +1,4 @@ -export function debounce( +export default function debounce( func: (...e: T) => R, wait = 1000, immediate = false diff --git a/src/shared/utils/helpers/get-query-params.ts b/src/shared/utils/helpers/get-query-params.ts index 213d352..5488c6e 100644 --- a/src/shared/utils/helpers/get-query-params.ts +++ b/src/shared/utils/helpers/get-query-params.ts @@ -1,6 +1,8 @@ -import { isBrowser } from "../browser/is-browser"; +import isBrowser from "../browser/is-browser"; -export function getQueryParams>(processors: { +export default function getQueryParams< + T extends Record +>(processors: { [K in keyof T]: (param: string) => T[K]; }): T { if (isBrowser()) { diff --git a/src/shared/utils/helpers/get-query-string.ts b/src/shared/utils/helpers/get-query-string.ts index a66b5af..4b7bdbb 100644 --- a/src/shared/utils/helpers/get-query-string.ts +++ b/src/shared/utils/helpers/get-query-string.ts @@ -1,6 +1,6 @@ -export function getQueryString>( - obj: T -) { +export default function getQueryString< + T extends Record +>(obj: T) { return Object.entries(obj) .filter(([, val]) => val !== undefined && val !== null) .reduce( diff --git a/src/shared/utils/helpers/poll.ts b/src/shared/utils/helpers/poll.ts index 055f17f..8f30e91 100644 --- a/src/shared/utils/helpers/poll.ts +++ b/src/shared/utils/helpers/poll.ts @@ -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(); } diff --git a/src/shared/utils/helpers/sleep.ts b/src/shared/utils/helpers/sleep.ts index 5b7c538..6529b52 100644 --- a/src/shared/utils/helpers/sleep.ts +++ b/src/shared/utils/helpers/sleep.ts @@ -1,3 +1,3 @@ -export function sleep(millis: number): Promise { +export default function sleep(millis: number): Promise { return new Promise(resolve => setTimeout(resolve, millis)); } diff --git a/src/shared/utils/roles/am-admin.ts b/src/shared/utils/roles/am-admin.ts index aadf52c..69139d3 100644 --- a/src/shared/utils/roles/am-admin.ts +++ b/src/shared/utils/roles/am-admin.ts @@ -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; } diff --git a/src/shared/utils/roles/am-community-creator.ts b/src/shared/utils/roles/am-community-creator.ts index 20f9b1d..3671ef2 100644 --- a/src/shared/utils/roles/am-community-creator.ts +++ b/src/shared/utils/roles/am-community-creator.ts @@ -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 diff --git a/src/shared/utils/roles/am-mod.ts b/src/shared/utils/roles/am-mod.ts index 7b792b3..85483da 100644 --- a/src/shared/utils/roles/am-mod.ts +++ b/src/shared/utils/roles/am-mod.ts @@ -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 { diff --git a/src/shared/utils/roles/am-site-creator.ts b/src/shared/utils/roles/am-site-creator.ts index 323ac0a..9da2840 100644 --- a/src/shared/utils/roles/am-site-creator.ts +++ b/src/shared/utils/roles/am-site-creator.ts @@ -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 diff --git a/src/shared/utils/roles/am-top-mod.ts b/src/shared/utils/roles/am-top-mod.ts index 4b942da..9163d7c 100644 --- a/src/shared/utils/roles/am-top-mod.ts +++ b/src/shared/utils/roles/am-top-mod.ts @@ -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 { diff --git a/src/shared/utils/roles/can-admin.ts b/src/shared/utils/roles/can-admin.ts index 080c7ac..cac451e 100644 --- a/src/shared/utils/roles/can-admin.ts +++ b/src/shared/utils/roles/can-admin.ts @@ -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, diff --git a/src/shared/utils/roles/can-create-community.ts b/src/shared/utils/roles/can-create-community.ts index 202290d..b0bfedd 100644 --- a/src/shared/utils/roles/can-create-community.ts +++ b/src/shared/utils/roles/can-create-community.ts @@ -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 { diff --git a/src/shared/utils/roles/can-mod.ts b/src/shared/utils/roles/can-mod.ts index 2892304..df639b7 100644 --- a/src/shared/utils/roles/can-mod.ts +++ b/src/shared/utils/roles/can-mod.ts @@ -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[], diff --git a/src/shared/utils/roles/is-admin.ts b/src/shared/utils/roles/is-admin.ts index fbf662b..bc0332e 100644 --- a/src/shared/utils/roles/is-admin.ts +++ b/src/shared/utils/roles/is-admin.ts @@ -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; } diff --git a/src/shared/utils/roles/is-banned.ts b/src/shared/utils/roles/is-banned.ts index dd5ffe6..d71f6f4 100644 --- a/src/shared/utils/roles/is-banned.ts +++ b/src/shared/utils/roles/is-banned.ts @@ -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 diff --git a/src/shared/utils/roles/is-mod.ts b/src/shared/utils/roles/is-mod.ts index 8731107..018b721 100644 --- a/src/shared/utils/roles/is-mod.ts +++ b/src/shared/utils/roles/is-mod.ts @@ -1,6 +1,6 @@ import { CommunityModeratorView } from "lemmy-js-client"; -export function isMod( +export default function isMod( creatorId: number, mods?: CommunityModeratorView[] ): boolean {