57 lines
2.7 KiB
TypeScript
57 lines
2.7 KiB
TypeScript
// Metro module 11077 (f11078).
|
|
import { useEffect } from "react";
|
|
import SafetyHubStore from "../SafetyHubStore";
|
|
import { ViolationType } from "../SafetyHubConstants";
|
|
import { useStateFromStoresArray, useStateFromStores } from "../../../_bundle/Module589";
|
|
import SnowflakeUtils from "../../../utils/SnowflakeUtils";
|
|
import { isGuildClassification } from "../SafetyHubUtils";
|
|
import { MemberType } from "../SafetyHubModels";
|
|
import { getSafetyHubDataForClassification } from "../SafetyHubActionCreators";
|
|
let $mk86333 = function() {
|
|
return () => SafetyHubStore.getClassifications();
|
|
}, $mk86334 = function() {
|
|
return (a0, a1) => SnowflakeUtils.extractTimestamp(a1.id) - SnowflakeUtils.extractTimestamp(a0.id);
|
|
};
|
|
export function useSafetyHubClassifications() {
|
|
return useStateFromStoresArray([SafetyHubStore], $mk86333()).sort($mk86334());
|
|
}
|
|
export function useSafetyHubClassification(a0) {
|
|
let stateFromStores2;
|
|
const stateFromStores = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getClassification(a0));
|
|
stateFromStores2 = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getClassificationRequestState(a0));
|
|
const stateFromStores3 = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getIsDsaEligible());
|
|
let isAppealEligible = useStateFromStores([SafetyHubStore], () => SafetyHubStore.getIsAppealEligible());
|
|
const violationType = isGuildClassification(stateFromStores) ? stateFromStores.guild_metadata?.member_type === MemberType.OWNER ? ViolationType.GUILD_OWNER : ViolationType.GUILD_MEMBER : ViolationType.USER;
|
|
useEffect(() => {
|
|
if (stateFromStores === void 0 && stateFromStores2 == null) {
|
|
getSafetyHubDataForClassification(a0);
|
|
}
|
|
}, [a0, stateFromStores, stateFromStores2]);
|
|
if (isAppealEligible) {
|
|
isAppealEligible = stateFromStores != null;
|
|
}
|
|
if (isAppealEligible) {
|
|
isAppealEligible = stateFromStores.appeal_status == null;
|
|
}
|
|
return {
|
|
classification: stateFromStores,
|
|
classificationRequestState: stateFromStores2,
|
|
isDsaEligible: stateFromStores3,
|
|
isAppealEligible,
|
|
violationType
|
|
};
|
|
}
|
|
export function useActiveSafetyHubClassifications() {
|
|
const r17 = useStateFromStoresArray([SafetyHubStore], $mk86333()).sort($mk86334());
|
|
let c18522_0 = new Date();
|
|
return r17.filter((item) => new Date(item.max_expiration_time) > c18522_0);
|
|
}
|
|
export function useExpiredSafetyHubClassifications() {
|
|
const r17 = useStateFromStoresArray([SafetyHubStore], $mk86333()).sort($mk86334());
|
|
let c18523_0 = new Date();
|
|
return r17.filter((item) => new Date(item.max_expiration_time) <= c18523_0);
|
|
}
|
|
export function useSafetyHubAppealSignal() {
|
|
return useStateFromStores([SafetyHubStore], () => SafetyHubStore.getAppealSignal());
|
|
}
|