make suggested changes

This commit is contained in:
Alec Armbruster 2023-06-20 10:17:16 -04:00
parent 69a123b6d8
commit e4f9c31cfa
No known key found for this signature in database
GPG key ID: 52BC7C84E960FD1B
27 changed files with 102 additions and 66 deletions

View file

@ -1,3 +1,6 @@
import { isBrowser } from "@utils/browser";
import { poll } from "@utils/helpers";
import { amAdmin, canCreateCommunity } from "@utils/roles";
import { Component, createRef, linkEvent } from "inferno"; import { Component, createRef, linkEvent } from "inferno";
import { NavLink } from "inferno-router"; import { NavLink } from "inferno-router";
import { import {
@ -17,10 +20,6 @@ import {
toast, toast,
updateUnreadCountsInterval, updateUnreadCountsInterval,
} from "../../utils"; } from "../../utils";
import isBrowser from "../../utils/browser/is-browser";
import poll from "../../utils/helpers/poll";
import amAdmin from "../../utils/roles/am-admin";
import canCreateCommunity from "../../utils/roles/can-create-community";
import { Icon } from "../common/icon"; import { Icon } from "../common/icon";
import { PictrsImage } from "../common/pictrs-image"; import { PictrsImage } from "../common/pictrs-image";

View file

@ -1,3 +1,11 @@
import {
amCommunityCreator,
canAdmin,
canMod,
isAdmin,
isBanned,
isMod,
} from "@utils/roles";
import classNames from "classnames"; import classNames from "classnames";
import { Component, InfernoNode, linkEvent } from "inferno"; import { Component, InfernoNode, linkEvent } from "inferno";
import { Link } from "inferno-router"; import { Link } from "inferno-router";
@ -53,12 +61,6 @@ import {
setupTippy, setupTippy,
showScores, showScores,
} from "../../utils"; } 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 { Icon, PurgeWarning, Spinner } from "../common/icon"; import { Icon, PurgeWarning, Spinner } from "../common/icon";
import { MomentTime } from "../common/moment-time"; import { MomentTime } from "../common/moment-time";
import { CommunityLink } from "../community/community-link"; import { CommunityLink } from "../community/community-link";

View file

@ -1,3 +1,5 @@
import { getQueryParams, getQueryString } from "@utils/helpers";
import type { QueryParams } from "@utils/types";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { import {
CommunityResponse, CommunityResponse,
@ -20,9 +22,6 @@ import {
setIsoData, setIsoData,
showLocal, showLocal,
} from "../../utils"; } from "../../utils";
import getQueryParams from "../../utils/helpers/get-query-params";
import getQueryString from "../../utils/helpers/get-query-string";
import type { QueryParams } from "../../utils/types/query-params";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { Spinner } from "../common/icon"; import { Spinner } from "../common/icon";
import { ListingTypeSelect } from "../common/listing-type-select"; import { ListingTypeSelect } from "../common/listing-type-select";

View file

@ -1,3 +1,5 @@
import { getQueryParams, getQueryString } from "@utils/helpers";
import type { QueryParams } from "@utils/types";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { RouteComponentProps } from "inferno-router/dist/Route"; import { RouteComponentProps } from "inferno-router/dist/Route";
import { import {
@ -86,9 +88,6 @@ import {
updateCommunityBlock, updateCommunityBlock,
updatePersonBlock, updatePersonBlock,
} from "../../utils"; } from "../../utils";
import getQueryParams from "../../utils/helpers/get-query-params";
import getQueryString from "../../utils/helpers/get-query-string";
import type { QueryParams } from "../../utils/types/query-params";
import { CommentNodes } from "../comment/comment-nodes"; import { CommentNodes } from "../comment/comment-nodes";
import { BannerIconHeader } from "../common/banner-icon-header"; import { BannerIconHeader } from "../common/banner-icon-header";
import { DataTypeSelect } from "../common/data-type-select"; import { DataTypeSelect } from "../common/data-type-select";

View file

@ -1,3 +1,4 @@
import { amAdmin, amMod, amTopMod } from "@utils/roles";
import { Component, InfernoNode, linkEvent } from "inferno"; import { Component, InfernoNode, linkEvent } from "inferno";
import { T } from "inferno-i18next-dess"; import { T } from "inferno-i18next-dess";
import { Link } from "inferno-router"; import { Link } from "inferno-router";
@ -17,9 +18,6 @@ import {
import { i18n } from "../../i18next"; import { i18n } from "../../i18next";
import { UserService } from "../../services"; import { UserService } from "../../services";
import { getUnixTime, hostname, mdToHtml, myAuthRequired } from "../../utils"; import { getUnixTime, hostname, mdToHtml, myAuthRequired } 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 { Badges } from "../common/badges";
import { BannerIconHeader } from "../common/banner-icon-header"; import { BannerIconHeader } from "../common/banner-icon-header";
import { Icon, PurgeWarning, Spinner } from "../common/icon"; import { Icon, PurgeWarning, Spinner } from "../common/icon";

View file

@ -1,5 +1,8 @@
import { getQueryParams, getQueryString } from "@utils/helpers";
import { canCreateCommunity } from "@utils/roles";
import type { QueryParams } from "@utils/types";
import { NoOptionI18nKeys } from "i18next"; import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent, MouseEventHandler } from "inferno"; import { Component, MouseEventHandler, linkEvent } from "inferno";
import { T } from "inferno-i18next-dess"; import { T } from "inferno-i18next-dess";
import { Link } from "inferno-router"; import { Link } from "inferno-router";
import { import {
@ -57,6 +60,7 @@ import { UserService } from "../../services";
import { FirstLoadService } from "../../services/FirstLoadService"; import { FirstLoadService } from "../../services/FirstLoadService";
import { HttpService, RequestState } from "../../services/HttpService"; import { HttpService, RequestState } from "../../services/HttpService";
import { import {
RouteDataResponse,
commentsToFlatNodes, commentsToFlatNodes,
editComment, editComment,
editPost, editPost,
@ -73,7 +77,6 @@ import {
postToCommentSortType, postToCommentSortType,
relTags, relTags,
restoreScrollPosition, restoreScrollPosition,
RouteDataResponse,
saveScrollPosition, saveScrollPosition,
setIsoData, setIsoData,
setupTippy, setupTippy,
@ -82,10 +85,6 @@ import {
trendingFetchLimit, trendingFetchLimit,
updatePersonBlock, updatePersonBlock,
} from "../../utils"; } from "../../utils";
import getQueryParams from "../../utils/helpers/get-query-params";
import getQueryString from "../../utils/helpers/get-query-string";
import canCreateCommunity from "../../utils/roles/can-create-community";
import type { QueryParams } from "../../utils/types/query-params";
import { CommentNodes } from "../comment/comment-nodes"; import { CommentNodes } from "../comment/comment-nodes";
import { DataTypeSelect } from "../common/data-type-select"; import { DataTypeSelect } from "../common/data-type-select";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";

View file

@ -1,10 +1,10 @@
import { isBrowser } from "@utils/browser";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { GetSiteResponse, LoginResponse } from "lemmy-js-client"; import { GetSiteResponse, LoginResponse } from "lemmy-js-client";
import { i18n } from "../../i18next"; import { i18n } from "../../i18next";
import { UserService } from "../../services"; import { UserService } from "../../services";
import { HttpService, RequestState } from "../../services/HttpService"; import { HttpService, RequestState } from "../../services/HttpService";
import { myAuth, setIsoData, toast, validEmail } from "../../utils"; import { myAuth, setIsoData, toast, validEmail } from "../../utils";
import isBrowser from "../../utils/browser/is-browser";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { Spinner } from "../common/icon"; import { Spinner } from "../common/icon";

View file

@ -1,3 +1,4 @@
import { isBrowser } from "@utils/browser";
import { Options, passwordStrength } from "check-password-strength"; import { Options, passwordStrength } from "check-password-strength";
import { NoOptionI18nKeys } from "i18next"; import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
@ -20,7 +21,6 @@ import {
toast, toast,
validEmail, validEmail,
} from "../../utils"; } from "../../utils";
import isBrowser from "../../utils/browser/is-browser";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { Icon, Spinner } from "../common/icon"; import { Icon, Spinner } from "../common/icon";
import { MarkdownTextArea } from "../common/markdown-textarea"; import { MarkdownTextArea } from "../common/markdown-textarea";

View file

@ -1,3 +1,6 @@
import { debounce, getQueryParams, getQueryString } from "@utils/helpers";
import { amAdmin, amMod } from "@utils/roles";
import type { QueryParams } from "@utils/types";
import { NoOptionI18nKeys } from "i18next"; import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { T } from "inferno-i18next-dess"; import { T } from "inferno-i18next-dess";
@ -44,12 +47,6 @@ import {
personToChoice, personToChoice,
setIsoData, setIsoData,
} from "../utils"; } from "../utils";
import debounce from "../utils/helpers/debounce";
import getQueryParams from "../utils/helpers/get-query-params";
import getQueryString from "../utils/helpers/get-query-string";
import amAdmin from "../utils/roles/am-admin";
import amMod from "../utils/roles/am-mod";
import type { QueryParams } from "../utils/types/query-params";
import { HtmlTags } from "./common/html-tags"; import { HtmlTags } from "./common/html-tags";
import { Icon, Spinner } from "./common/icon"; import { Icon, Spinner } from "./common/icon";
import { MomentTime } from "./common/moment-time"; import { MomentTime } from "./common/moment-time";

View file

@ -1,3 +1,6 @@
import { getQueryParams, getQueryString } from "@utils/helpers";
import { canMod, isAdmin, isBanned } from "@utils/roles";
import type { QueryParams } from "@utils/types";
import classNames from "classnames"; import classNames from "classnames";
import { NoOptionI18nKeys } from "i18next"; import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
@ -76,12 +79,6 @@ import {
toast, toast,
updatePersonBlock, updatePersonBlock,
} from "../../utils"; } from "../../utils";
import getQueryParams from "../../utils/helpers/get-query-params";
import getQueryString from "../../utils/helpers/get-query-string";
import canMod from "../../utils/roles/can-mod";
import isAdmin from "../../utils/roles/is-admin";
import isBanned from "../../utils/roles/is-banned";
import type { QueryParams } from "../../utils/types/query-params";
import { BannerIconHeader } from "../common/banner-icon-header"; import { BannerIconHeader } from "../common/banner-icon-header";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { Icon, Spinner } from "../common/icon"; import { Icon, Spinner } from "../common/icon";

View file

@ -1,3 +1,4 @@
import { amAdmin } from "@utils/roles";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { import {
CommentReportResponse, CommentReportResponse,
@ -31,7 +32,6 @@ import {
myAuthRequired, myAuthRequired,
setIsoData, setIsoData,
} from "../../utils"; } from "../../utils";
import amAdmin from "../../utils/roles/am-admin";
import { CommentReport } from "../comment/comment-report"; import { CommentReport } from "../comment/comment-report";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { Spinner } from "../common/icon"; import { Spinner } from "../common/icon";

View file

@ -1,3 +1,4 @@
import { debounce } from "@utils/helpers";
import { NoOptionI18nKeys } from "i18next"; import { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { import {
@ -35,7 +36,6 @@ import {
updateCommunityBlock, updateCommunityBlock,
updatePersonBlock, updatePersonBlock,
} from "../../utils"; } from "../../utils";
import debounce from "../../utils/helpers/debounce";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { Icon, Spinner } from "../common/icon"; import { Icon, Spinner } from "../common/icon";
import { ImageUploadForm } from "../common/image-upload-form"; import { ImageUploadForm } from "../common/image-upload-form";

View file

@ -1,3 +1,5 @@
import { getQueryParams } from "@utils/helpers";
import type { QueryParams } from "@utils/types";
import { Component } from "inferno"; import { Component } from "inferno";
import { RouteComponentProps } from "inferno-router/dist/Route"; import { RouteComponentProps } from "inferno-router/dist/Route";
import { import {
@ -24,8 +26,6 @@ import {
myAuth, myAuth,
setIsoData, setIsoData,
} from "../../utils"; } from "../../utils";
import getQueryParams from "../../utils/helpers/get-query-params";
import type { QueryParams } from "../../utils/types/query-params";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";
import { Spinner } from "../common/icon"; import { Spinner } from "../common/icon";
import { PostForm } from "./post-form"; import { PostForm } from "./post-form";

View file

@ -1,3 +1,14 @@
import { canShare, share } from "@utils/browser";
import {
amAdmin,
amCommunityCreator,
amMod,
canAdmin,
canMod,
isAdmin,
isBanned,
isMod,
} from "@utils/roles";
import classNames from "classnames"; import classNames from "classnames";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { Link } from "inferno-router"; import { Link } from "inferno-router";
@ -42,16 +53,6 @@ import {
setupTippy, setupTippy,
showScores, showScores,
} from "../../utils"; } from "../../utils";
import canShare from "../../utils/browser/can-share";
import share from "../../utils/browser/share";
import amAdmin from "../../utils/roles/am-admin";
import amCommunityCreator from "../../utils/roles/am-community-creator";
import amMod from "../../utils/roles/am-mod";
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 { Icon, PurgeWarning, Spinner } from "../common/icon";
import { MomentTime } from "../common/moment-time"; import { MomentTime } from "../common/moment-time";
import { PictrsImage } from "../common/pictrs-image"; import { PictrsImage } from "../common/pictrs-image";

View file

@ -1,3 +1,5 @@
import { isBrowser } from "@utils/browser";
import { debounce } from "@utils/helpers";
import autosize from "autosize"; import autosize from "autosize";
import { Component, createRef, linkEvent, RefObject } from "inferno"; import { Component, createRef, linkEvent, RefObject } from "inferno";
import { import {
@ -83,8 +85,6 @@ import {
updateCommunityBlock, updateCommunityBlock,
updatePersonBlock, updatePersonBlock,
} from "../../utils"; } from "../../utils";
import isBrowser from "../../utils/browser/is-browser";
import debounce from "../../utils/helpers/debounce";
import { CommentForm } from "../comment/comment-form"; import { CommentForm } from "../comment/comment-form";
import { CommentNodes } from "../comment/comment-nodes"; import { CommentNodes } from "../comment/comment-nodes";
import { HtmlTags } from "../common/html-tags"; import { HtmlTags } from "../common/html-tags";

View file

@ -1,3 +1,5 @@
import { debounce, getQueryParams, getQueryString } from "@utils/helpers";
import type { QueryParams } from "@utils/types";
import type { NoOptionI18nKeys } from "i18next"; import type { NoOptionI18nKeys } from "i18next";
import { Component, linkEvent } from "inferno"; import { Component, linkEvent } from "inferno";
import { import {
@ -46,10 +48,6 @@ import {
setIsoData, setIsoData,
showLocal, showLocal,
} from "../utils"; } from "../utils";
import debounce from "../utils/helpers/debounce";
import getQueryParams from "../utils/helpers/get-query-params";
import getQueryString from "../utils/helpers/get-query-string";
import type { QueryParams } from "../utils/types/query-params";
import { CommentNodes } from "./comment/comment-nodes"; import { CommentNodes } from "./comment/comment-nodes";
import { HtmlTags } from "./common/html-tags"; import { HtmlTags } from "./common/html-tags";
import { Spinner } from "./common/icon"; import { Spinner } from "./common/icon";

View file

@ -1,4 +1,4 @@
import isBrowser from "./is-browser"; import { isBrowser } from "@utils/browser";
export default function canShare() { export default function canShare() {
return isBrowser() && !!navigator.canShare; return isBrowser() && !!navigator.canShare;

View file

@ -0,0 +1,5 @@
import canShare from "./can-share";
import isBrowser from "./is-browser";
import share from "./share";
export { canShare, isBrowser, share };

View file

@ -1,4 +1,4 @@
import isBrowser from "./is-browser"; import { isBrowser } from "@utils/browser";
export default function share(shareData: ShareData) { export default function share(shareData: ShareData) {
if (isBrowser()) { if (isBrowser()) {

View file

@ -1,4 +1,4 @@
import isBrowser from "../browser/is-browser"; import { isBrowser } from "@utils/browser";
export default function getQueryParams< export default function getQueryParams<
T extends Record<string, any> T extends Record<string, any>

View file

@ -0,0 +1,8 @@
import debounce from "./debounce";
import getQueryParams from "./get-query-params";
import getQueryString from "./get-query-string";
import { groupBy } from "./group-by";
import poll from "./poll";
import sleep from "./sleep";
export { debounce, getQueryParams, getQueryString, groupBy, poll, sleep };

View file

@ -1,6 +1,6 @@
import { isMod } from "@utils/roles";
import { CommunityModeratorView } from "lemmy-js-client"; import { CommunityModeratorView } from "lemmy-js-client";
import { UserService } from "../../services"; import { UserService } from "../../services";
import isMod from "./is-mod";
export default function amMod( export default function amMod(
mods?: CommunityModeratorView[], mods?: CommunityModeratorView[],

View file

@ -1,6 +1,6 @@
import { canMod } from "@utils/roles";
import { PersonView } from "lemmy-js-client"; import { PersonView } from "lemmy-js-client";
import { UserService } from "../../services"; import { UserService } from "../../services";
import canMod from "./can-mod";
export default function canAdmin( export default function canAdmin(
creatorId: number, creatorId: number,

View file

@ -1,6 +1,6 @@
import { amAdmin } from "@utils/roles";
import { GetSiteResponse } from "lemmy-js-client"; import { GetSiteResponse } from "lemmy-js-client";
import { UserService } from "../../services"; import { UserService } from "../../services";
import amAdmin from "./am-admin";
export default function canCreateCommunity( export default function canCreateCommunity(
siteRes: GetSiteResponse, siteRes: GetSiteResponse,

View file

@ -0,0 +1,25 @@
import amAdmin from "./am-admin";
import amCommunityCreator from "./am-community-creator";
import amMod from "./am-mod";
import amSiteCreator from "./am-site-creator";
import amTopMod from "./am-top-mod";
import canAdmin from "./can-admin";
import canCreateCommunity from "./can-create-community";
import canMod from "./can-mod";
import isAdmin from "./is-admin";
import isBanned from "./is-banned";
import isMod from "./is-mod";
export {
amAdmin,
amCommunityCreator,
amMod,
amSiteCreator,
amTopMod,
canAdmin,
canCreateCommunity,
canMod,
isAdmin,
isBanned,
isMod,
};

View file

@ -0,0 +1,3 @@
import { QueryParams } from "./query-params";
export { QueryParams };

View file

@ -18,7 +18,13 @@
"noImplicitReturns": true, "noImplicitReturns": true,
"experimentalDecorators": true, "experimentalDecorators": true,
"strictNullChecks": true, "strictNullChecks": true,
"noFallthroughCasesInSwitch": true "noFallthroughCasesInSwitch": true,
"paths": {
"@utils/roles": ["./shared/utils/roles/index"],
"@utils/browser": ["./shared/utils/browser/index"],
"@utils/helpers": ["./shared/utils/helpers/index"],
"@utils/types": ["./shared/utils/types/index"],
}
}, },
"include": [ "include": [
"src/**/*.ts", "src/**/*.ts",