]> Untitled Git - lemmy-ui.git/commitdiff
make suggested changes
authorAlec Armbruster <35377827+alectrocute@users.noreply.github.com>
Tue, 20 Jun 2023 14:17:16 +0000 (10:17 -0400)
committerAlec Armbruster <35377827+alectrocute@users.noreply.github.com>
Tue, 20 Jun 2023 14:17:16 +0000 (10:17 -0400)
27 files changed:
src/shared/components/app/navbar.tsx
src/shared/components/comment/comment-node.tsx
src/shared/components/community/communities.tsx
src/shared/components/community/community.tsx
src/shared/components/community/sidebar.tsx
src/shared/components/home/home.tsx
src/shared/components/home/login.tsx
src/shared/components/home/signup.tsx
src/shared/components/modlog.tsx
src/shared/components/person/profile.tsx
src/shared/components/person/reports.tsx
src/shared/components/person/settings.tsx
src/shared/components/post/create-post.tsx
src/shared/components/post/post-listing.tsx
src/shared/components/post/post.tsx
src/shared/components/search.tsx
src/shared/utils/browser/can-share.ts
src/shared/utils/browser/index.ts [new file with mode: 0644]
src/shared/utils/browser/share.ts
src/shared/utils/helpers/get-query-params.ts
src/shared/utils/helpers/index.ts [new file with mode: 0644]
src/shared/utils/roles/am-mod.ts
src/shared/utils/roles/can-admin.ts
src/shared/utils/roles/can-create-community.ts
src/shared/utils/roles/index.ts [new file with mode: 0644]
src/shared/utils/types/index.ts [new file with mode: 0644]
tsconfig.json

index 9f68656aa87f8f6aab365f5a78357029d1ac5ba2..d412e006b03715bd4ca6139ab814d34e32684c81 100644 (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 { NavLink } from "inferno-router";
 import {
@@ -17,10 +20,6 @@ import {
   toast,
   updateUnreadCountsInterval,
 } 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 { PictrsImage } from "../common/pictrs-image";
 
index bcbd605001593f2898fdb66948a26984c73eaade..e60ad437b107db03605f36991d8cd7c3efeb6b1e 100644 (file)
@@ -1,3 +1,11 @@
+import {
+  amCommunityCreator,
+  canAdmin,
+  canMod,
+  isAdmin,
+  isBanned,
+  isMod,
+} from "@utils/roles";
 import classNames from "classnames";
 import { Component, InfernoNode, linkEvent } from "inferno";
 import { Link } from "inferno-router";
@@ -53,12 +61,6 @@ 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 { Icon, PurgeWarning, Spinner } from "../common/icon";
 import { MomentTime } from "../common/moment-time";
 import { CommunityLink } from "../community/community-link";
index 6a2ae6ad6ed5682ce73351fa94d6e0f049bf4c9a..a64b9e9615da888e44717b4698e8dfec8169cb56 100644 (file)
@@ -1,3 +1,5 @@
+import { getQueryParams, getQueryString } from "@utils/helpers";
+import type { QueryParams } from "@utils/types";
 import { Component, linkEvent } from "inferno";
 import {
   CommunityResponse,
@@ -20,9 +22,6 @@ import {
   setIsoData,
   showLocal,
 } 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 { Spinner } from "../common/icon";
 import { ListingTypeSelect } from "../common/listing-type-select";
index 42a77836b64e668cc25fbeb2eec31af85c65f1cd..203288c5b1c9ced1d80195e7798830a1ab44b7e8 100644 (file)
@@ -1,3 +1,5 @@
+import { getQueryParams, getQueryString } from "@utils/helpers";
+import type { QueryParams } from "@utils/types";
 import { Component, linkEvent } from "inferno";
 import { RouteComponentProps } from "inferno-router/dist/Route";
 import {
@@ -86,9 +88,6 @@ import {
   updateCommunityBlock,
   updatePersonBlock,
 } 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 { BannerIconHeader } from "../common/banner-icon-header";
 import { DataTypeSelect } from "../common/data-type-select";
index 72c94c09df3dac99ef5cc15af9722e44cd651262..2396b5278ad9005574695f15aac96a01d21e65f8 100644 (file)
@@ -1,3 +1,4 @@
+import { amAdmin, amMod, amTopMod } from "@utils/roles";
 import { Component, InfernoNode, linkEvent } from "inferno";
 import { T } from "inferno-i18next-dess";
 import { Link } from "inferno-router";
@@ -17,9 +18,6 @@ import {
 import { i18n } from "../../i18next";
 import { UserService } from "../../services";
 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 { BannerIconHeader } from "../common/banner-icon-header";
 import { Icon, PurgeWarning, Spinner } from "../common/icon";
index 4a1e9d702a65d1884fb006c0d2e5bf704556d1fd..deca4589b1d925450c15b9549326cd59efe03700 100644 (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 { Component, linkEvent, MouseEventHandler } from "inferno";
+import { Component, MouseEventHandler, linkEvent } from "inferno";
 import { T } from "inferno-i18next-dess";
 import { Link } from "inferno-router";
 import {
@@ -57,6 +60,7 @@ import { UserService } from "../../services";
 import { FirstLoadService } from "../../services/FirstLoadService";
 import { HttpService, RequestState } from "../../services/HttpService";
 import {
+  RouteDataResponse,
   commentsToFlatNodes,
   editComment,
   editPost,
@@ -73,7 +77,6 @@ import {
   postToCommentSortType,
   relTags,
   restoreScrollPosition,
-  RouteDataResponse,
   saveScrollPosition,
   setIsoData,
   setupTippy,
@@ -82,10 +85,6 @@ import {
   trendingFetchLimit,
   updatePersonBlock,
 } 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 { DataTypeSelect } from "../common/data-type-select";
 import { HtmlTags } from "../common/html-tags";
index e25222e0b61a03bb49694c96cecd1e3b8e103e6c..d1b3abd034bfd46674fc6c2ff346abd9b5f78e0c 100644 (file)
@@ -1,10 +1,10 @@
+import { isBrowser } from "@utils/browser";
 import { Component, linkEvent } from "inferno";
 import { GetSiteResponse, LoginResponse } from "lemmy-js-client";
 import { i18n } from "../../i18next";
 import { UserService } from "../../services";
 import { HttpService, RequestState } from "../../services/HttpService";
 import { myAuth, setIsoData, toast, validEmail } from "../../utils";
-import isBrowser from "../../utils/browser/is-browser";
 import { HtmlTags } from "../common/html-tags";
 import { Spinner } from "../common/icon";
 
index 287bdb7bff49076f6c7a220b4648ad92c690112a..6961a14af068a6b1e4fa7ad3f1e614d45bba8ca6 100644 (file)
@@ -1,3 +1,4 @@
+import { isBrowser } from "@utils/browser";
 import { Options, passwordStrength } from "check-password-strength";
 import { NoOptionI18nKeys } from "i18next";
 import { Component, linkEvent } from "inferno";
@@ -20,7 +21,6 @@ import {
   toast,
   validEmail,
 } from "../../utils";
-import isBrowser from "../../utils/browser/is-browser";
 import { HtmlTags } from "../common/html-tags";
 import { Icon, Spinner } from "../common/icon";
 import { MarkdownTextArea } from "../common/markdown-textarea";
index 3ea910c514271681b5d4c75ee816196f8bf5c97a..a37486f9d13f0aacd08c407161385cd62cfd34ec 100644 (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 { Component, linkEvent } from "inferno";
 import { T } from "inferno-i18next-dess";
@@ -44,12 +47,6 @@ import {
   personToChoice,
   setIsoData,
 } 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 { Icon, Spinner } from "./common/icon";
 import { MomentTime } from "./common/moment-time";
index d99ab124512d8a9497d62c73a72795cef7d75607..b4bec066fee7b8302356c844d826c8ec7c7cc1d3 100644 (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 { NoOptionI18nKeys } from "i18next";
 import { Component, linkEvent } from "inferno";
@@ -76,12 +79,6 @@ import {
   toast,
   updatePersonBlock,
 } 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 { HtmlTags } from "../common/html-tags";
 import { Icon, Spinner } from "../common/icon";
index ce9d215af8cec9d2f59c06ca0bd9ae69816c5f3a..de303a873c15e758f3fe283c0376d40f97f50528 100644 (file)
@@ -1,3 +1,4 @@
+import { amAdmin } from "@utils/roles";
 import { Component, linkEvent } from "inferno";
 import {
   CommentReportResponse,
@@ -31,7 +32,6 @@ import {
   myAuthRequired,
   setIsoData,
 } from "../../utils";
-import amAdmin from "../../utils/roles/am-admin";
 import { CommentReport } from "../comment/comment-report";
 import { HtmlTags } from "../common/html-tags";
 import { Spinner } from "../common/icon";
index 7cb9308c6478bad64f0d797c7f914b6804743c7e..08567dcbe383eacaaa7551023d25916853ecac92 100644 (file)
@@ -1,3 +1,4 @@
+import { debounce } from "@utils/helpers";
 import { NoOptionI18nKeys } from "i18next";
 import { Component, linkEvent } from "inferno";
 import {
@@ -35,7 +36,6 @@ import {
   updateCommunityBlock,
   updatePersonBlock,
 } from "../../utils";
-import debounce from "../../utils/helpers/debounce";
 import { HtmlTags } from "../common/html-tags";
 import { Icon, Spinner } from "../common/icon";
 import { ImageUploadForm } from "../common/image-upload-form";
index 4f36771290973db8b0ce98ea84486ce0c91ea00d..ad2313460daac4212afc771b0d4fcdc13959ceed 100644 (file)
@@ -1,3 +1,5 @@
+import { getQueryParams } from "@utils/helpers";
+import type { QueryParams } from "@utils/types";
 import { Component } from "inferno";
 import { RouteComponentProps } from "inferno-router/dist/Route";
 import {
@@ -24,8 +26,6 @@ import {
   myAuth,
   setIsoData,
 } 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 { Spinner } from "../common/icon";
 import { PostForm } from "./post-form";
index 914c16d39daefe2e481f3219e9c69e3a6d565956..928c1eceaedae3055fc45277f0ea4012c03125c9 100644 (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 { Component, linkEvent } from "inferno";
 import { Link } from "inferno-router";
@@ -42,16 +53,6 @@ import {
   setupTippy,
   showScores,
 } 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 { MomentTime } from "../common/moment-time";
 import { PictrsImage } from "../common/pictrs-image";
index 8b10c058dcbf420ad619d289bf196fc77d1e8c26..60059fee51966e5de7bbec08d61d383a1d17b676 100644 (file)
@@ -1,3 +1,5 @@
+import { isBrowser } from "@utils/browser";
+import { debounce } from "@utils/helpers";
 import autosize from "autosize";
 import { Component, createRef, linkEvent, RefObject } from "inferno";
 import {
@@ -83,8 +85,6 @@ import {
   updateCommunityBlock,
   updatePersonBlock,
 } from "../../utils";
-import isBrowser from "../../utils/browser/is-browser";
-import debounce from "../../utils/helpers/debounce";
 import { CommentForm } from "../comment/comment-form";
 import { CommentNodes } from "../comment/comment-nodes";
 import { HtmlTags } from "../common/html-tags";
index 844737cc6578c1b0478af7ed41d376cb6759fc98..0dc4eb779e4d5c698c723260d08b1f1616573717 100644 (file)
@@ -1,3 +1,5 @@
+import { debounce, getQueryParams, getQueryString } from "@utils/helpers";
+import type { QueryParams } from "@utils/types";
 import type { NoOptionI18nKeys } from "i18next";
 import { Component, linkEvent } from "inferno";
 import {
@@ -46,10 +48,6 @@ import {
   setIsoData,
   showLocal,
 } 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 { HtmlTags } from "./common/html-tags";
 import { Spinner } from "./common/icon";
index f141fe505c46f334e03e9a142b524119430331aa..77de9838aeca41c976639e358841ec4f8827e713 100644 (file)
@@ -1,4 +1,4 @@
-import isBrowser from "./is-browser";
+import { isBrowser } from "@utils/browser";
 
 export default function canShare() {
   return isBrowser() && !!navigator.canShare;
diff --git a/src/shared/utils/browser/index.ts b/src/shared/utils/browser/index.ts
new file mode 100644 (file)
index 0000000..a7a08a5
--- /dev/null
@@ -0,0 +1,5 @@
+import canShare from "./can-share";
+import isBrowser from "./is-browser";
+import share from "./share";
+
+export { canShare, isBrowser, share };
index 9ae94974c3045edf98a4b31828c5884c0ae5b88e..98d17712c57d7b01158ae6dc665a98b9bef804bd 100644 (file)
@@ -1,4 +1,4 @@
-import isBrowser from "./is-browser";
+import { isBrowser } from "@utils/browser";
 
 export default function share(shareData: ShareData) {
   if (isBrowser()) {
index 5488c6eaec824acb346bdc2e7bf99fe94f8cfa63..627341e46ac4d95cac087e51d2d64f8d86d9f213 100644 (file)
@@ -1,4 +1,4 @@
-import isBrowser from "../browser/is-browser";
+import { isBrowser } from "@utils/browser";
 
 export default function getQueryParams<
   T extends Record<string, any>
diff --git a/src/shared/utils/helpers/index.ts b/src/shared/utils/helpers/index.ts
new file mode 100644 (file)
index 0000000..663afbf
--- /dev/null
@@ -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 };
index 85483dae9723b15f3127aa850fc1701a888a4e0f..c0632f78dde62d0b0c6a8839762c6c56abd6d431 100644 (file)
@@ -1,6 +1,6 @@
+import { isMod } from "@utils/roles";
 import { CommunityModeratorView } from "lemmy-js-client";
 import { UserService } from "../../services";
-import isMod from "./is-mod";
 
 export default function amMod(
   mods?: CommunityModeratorView[],
index cac451e91bcb806308974e368f6c6abdb636a61d..55bfd1cf61f1e4c814ca0ad1e75a757780d93232 100644 (file)
@@ -1,6 +1,6 @@
+import { canMod } from "@utils/roles";
 import { PersonView } from "lemmy-js-client";
 import { UserService } from "../../services";
-import canMod from "./can-mod";
 
 export default function canAdmin(
   creatorId: number,
index b0bfeddc4e61d44fd31811b334c7065dd67fb27e..1b5cf05cda246e1094de373f441b3b7a10a750b8 100644 (file)
@@ -1,6 +1,6 @@
+import { amAdmin } from "@utils/roles";
 import { GetSiteResponse } from "lemmy-js-client";
 import { UserService } from "../../services";
-import amAdmin from "./am-admin";
 
 export default function canCreateCommunity(
   siteRes: GetSiteResponse,
diff --git a/src/shared/utils/roles/index.ts b/src/shared/utils/roles/index.ts
new file mode 100644 (file)
index 0000000..4762637
--- /dev/null
@@ -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,
+};
diff --git a/src/shared/utils/types/index.ts b/src/shared/utils/types/index.ts
new file mode 100644 (file)
index 0000000..9b4a1ce
--- /dev/null
@@ -0,0 +1,3 @@
+import { QueryParams } from "./query-params";
+
+export { QueryParams };
index 3b7d3e41049b11e75a1cb10910b39aef10882afc..600d33aaf4078f2c380c9457ff9b5252ee408953 100644 (file)
     "noImplicitReturns": true,
     "experimentalDecorators": 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": [
     "src/**/*.ts",