X-Git-Url: http://these/git/?a=blobdiff_plain;f=src%2Fshared%2Fcomponents%2Fmodlog.tsx;h=ca1cb3326b2cfef3a2ca454d00d071d454e72abc;hb=ed0fd264de3d2162a3837733632fee69696681aa;hp=cb4b37f4363d49f579fa72c295ebdbf6eea38481;hpb=feb4c434d1723a38a8991e1be0fc8ca5536d9b08;p=lemmy-ui.git diff --git a/src/shared/components/modlog.tsx b/src/shared/components/modlog.tsx index cb4b37f..ca1cb33 100644 --- a/src/shared/components/modlog.tsx +++ b/src/shared/components/modlog.tsx @@ -1,3 +1,21 @@ +import { + fetchUsers, + getUpdatedSearchId, + myAuth, + personToChoice, + setIsoData, +} from "@utils/app"; +import { + debounce, + formatPastDate, + getIdFromString, + getPageFromString, + getQueryParams, + getQueryString, +} from "@utils/helpers"; +import { amAdmin, amMod } from "@utils/roles"; +import type { QueryParams } from "@utils/types"; +import { Choice, RouteDataResponse } from "@utils/types"; import { NoOptionI18nKeys } from "i18next"; import { Component, linkEvent } from "inferno"; import { T } from "inferno-i18next-dess"; @@ -8,7 +26,6 @@ import { AdminPurgeCommunityView, AdminPurgePersonView, AdminPurgePostView, - CommunityModeratorView, GetCommunity, GetCommunityResponse, GetModlog, @@ -27,37 +44,11 @@ import { ModTransferCommunityView, ModlogActionType, Person, - UserOperation, - wsJsonToRes, - wsUserOp, } from "lemmy-js-client"; -import moment from "moment"; -import { Subscription } from "rxjs"; -import { i18n } from "../i18next"; +import { fetchLimit } from "../config"; import { InitialFetchRequest } from "../interfaces"; -import { WebSocketService } from "../services"; -import { - Choice, - QueryParams, - WithPromiseKeys, - amAdmin, - amMod, - debounce, - fetchLimit, - fetchUsers, - getIdFromString, - getPageFromString, - getQueryParams, - getQueryString, - getUpdatedSearchId, - isBrowser, - myAuth, - personToChoice, - setIsoData, - toast, - wsClient, - wsSubscribe, -} from "../utils"; +import { FirstLoadService, I18NextService } from "../services"; +import { HttpService, RequestState } from "../services/HttpService"; import { HtmlTags } from "./common/html-tags"; import { Icon, Spinner } from "./common/icon"; import { MomentTime } from "./common/moment-time"; @@ -84,12 +75,12 @@ type View = | AdminPurgePostView | AdminPurgeCommentView; -interface ModlogData { - modlogResponse: GetModlogResponse; - communityResponse?: GetCommunityResponse; - modUserResponse?: GetPersonDetailsResponse; - userResponse?: GetPersonDetailsResponse; -} +type ModlogData = RouteDataResponse<{ + res: GetModlogResponse; + communityRes: GetCommunityResponse; + modUserResponse: GetPersonDetailsResponse; + userResponse: GetPersonDetailsResponse; +}>; interface ModlogType { id: number; @@ -108,10 +99,8 @@ const getModlogQueryParams = () => }); interface ModlogState { - res?: GetModlogResponse; - communityMods?: CommunityModeratorView[]; - communityName?: string; - loadingModlog: boolean; + res: RequestState; + communityRes: RequestState; loadingModSearch: boolean; loadingUserSearch: boolean; modSearchOptions: Choice[]; @@ -323,6 +312,7 @@ function renderModlogType({ type_, view }: ModlogType) { const { mod_feature_post: { featured, is_featured_community }, post: { id, name }, + community, } = view as ModFeaturePostView; return ( @@ -331,7 +321,12 @@ function renderModlogType({ type_, view }: ModlogType) { Post {name} - {is_featured_community ? " In Community" : " In Local"} + + {is_featured_community + ? " in community " + : " in Local, from community "} + + ); } @@ -382,7 +377,7 @@ function renderModlogType({ type_, view }: ModlogType) { )} {expires && ( -
expires: {moment.utc(expires).fromNow()}
+
expires: {formatPastDate(expires)}
)} @@ -414,7 +409,7 @@ function renderModlogType({ type_, view }: ModlogType) { )} {expires && ( -
expires: {moment.utc(expires).fromNow()}
+
expires: {formatPastDate(expires)}
)} @@ -478,7 +473,7 @@ function renderModlogType({ type_, view }: ModlogType) { )} {expires && ( -
expires: {moment.utc(expires).fromNow()}
+
expires: {formatPastDate(expires)}
)} @@ -543,7 +538,7 @@ function renderModlogType({ type_, view }: ModlogType) { return ( <> - Purged a Post from from + Purged a Post from {reason && ( @@ -594,16 +589,16 @@ const Filter = ({ options: Choice[]; loading: boolean; }) => ( -
-