93 lines
4.1 KiB
TypeScript
93 lines
4.1 KiB
TypeScript
// Metro module 11062 (f11063).
|
|
import { useCallback } from "react";
|
|
import ProfileCustomizationNavigationStore from "../profile_customization/ProfileCustomizationNavigationStore";
|
|
import AuthenticationStore from "../../stores/AuthenticationStore";
|
|
import GuildMemberStore from "../../stores/GuildMemberStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import PermissionStore from "../../stores/PermissionStore";
|
|
import SelectedGuildStore from "../../stores/SelectedGuildStore";
|
|
import { Permissions, UserSettingsSections } from "../../Constants";
|
|
import { GuildMemberFlags } from "../guild_member/GuildMemberConstants";
|
|
import { ProfileCustomizationSubsection } from "../user_settings/UserSettingsConstants";
|
|
import { useStateFromStores, useStateFromStoresObject } from "../../_bundle/defaultAreStatesEqual";
|
|
import { hasAutomodQuarantinedProfile, getAutomodQuarantinedProfileFlags } from "./AutomodPermissionUtils";
|
|
import { t, intl } from "../../intl/index.native";
|
|
import { useIsEligibleForUserProfileWYSIWYGEditing } from "../user_profile/experiments/UserProfileWYSIWYGEditingExperiment";
|
|
import { initGuildIdentitySettings } from "../guild_identity/GuildIdentityActionCreators";
|
|
import { openUserSettings } from "../user_settings/core/native/openUserSettings";
|
|
export function useCurrentUserHasAutomodQuarantinedProfile(a0) {
|
|
return useStateFromStores([AuthenticationStore, GuildMemberStore], () => {
|
|
if (a0 == null) {
|
|
return false;
|
|
}
|
|
return hasAutomodQuarantinedProfile(GuildMemberStore.getMember(a0, AuthenticationStore.getId()));
|
|
}, [a0]);
|
|
}
|
|
export function useGuildAutomodProfileQuarantineErrors(a0) {
|
|
return useStateFromStoresObject([AuthenticationStore, GuildMemberStore, SelectedGuildStore, GuildStore], () => {
|
|
let nick;
|
|
const guildId2 = SelectedGuildStore.getGuildId();
|
|
let r17 = a0;
|
|
if (r17 == null) {
|
|
r17 = guildId2;
|
|
}
|
|
const r18 = {
|
|
nick: void 0,
|
|
bio: void 0
|
|
};
|
|
const guild = GuildStore.getGuild(r17);
|
|
const r11 = r17;
|
|
if (guild != null && r11 != null) {
|
|
const automodQuarantinedProfileFlags = getAutomodQuarantinedProfileFlags(GuildMemberStore.getMember(r11, AuthenticationStore.getId())?.flags);
|
|
if (automodQuarantinedProfileFlags.size !== 0) {
|
|
if (automodQuarantinedProfileFlags.has(GuildMemberFlags.AUTOMOD_QUARANTINED_USERNAME_OR_GUILD_NICKNAME)) {
|
|
if (a0 == null) {
|
|
const WBUh3O = t.WBUh3O;
|
|
let name = guild.name;
|
|
if (name == null) {
|
|
name = "";
|
|
}
|
|
nick = [intl.formatToPlainString(WBUh3O, {
|
|
guildName: name
|
|
})];
|
|
} else {
|
|
nick = [intl.string(t.EPZCrM)];
|
|
}
|
|
r18.nick = nick;
|
|
}
|
|
if (automodQuarantinedProfileFlags.has(GuildMemberFlags.AUTOMOD_QUARANTINED_BIO)) {
|
|
r18.bio = [intl.string(t.dZh1vz)];
|
|
}
|
|
}
|
|
return r18;
|
|
}
|
|
return r18;
|
|
}, [a0]);
|
|
}
|
|
export function useOpenFixQuarantinedProfileModal({ guildId, scrollPosition, analyticsLocations }) {
|
|
let stateFromStores2;
|
|
stateFromStores2 = void 0;
|
|
const stateFromStores = useStateFromStores([GuildStore], () => GuildStore.getGuild(guildId), [guildId]);
|
|
stateFromStores2 = useStateFromStores([PermissionStore], () => stateFromStores != null && PermissionStore.can(Permissions.CHANGE_NICKNAME, stateFromStores), [stateFromStores]);
|
|
return [useCallback(() => {
|
|
let subsection;
|
|
if (stateFromStores != null) {
|
|
const PROFILE_CUSTOMIZATION = UserSettingsSections.PROFILE_CUSTOMIZATION;
|
|
const GUILD = ProfileCustomizationSubsection.GUILD;
|
|
if (stateFromStores2) {
|
|
initGuildIdentitySettings(stateFromStores.id);
|
|
subsection = GUILD;
|
|
} else {
|
|
subsection = ProfileCustomizationSubsection.USER_PROFILE;
|
|
}
|
|
ProfileCustomizationNavigationStore.setState({
|
|
subsection,
|
|
scrollPosition
|
|
});
|
|
openUserSettings({
|
|
screen: PROFILE_CUSTOMIZATION
|
|
});
|
|
}
|
|
}, [stateFromStores2, scrollPosition, analyticsLocations, stateFromStores, useIsEligibleForUserProfileWYSIWYGEditing("AutomodQuarantineUtils")]), stateFromStores2];
|
|
}
|