Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4941.js (118.4 MB)
194 lines
7.4 KiB
TypeScript
194 lines
7.4 KiB
TypeScript
// Module ID: 7509
|
|
// Function ID: 7510
|
|
// Name: GuildOfficialMessageUtils
|
|
// Dependencies: [2063, 4395, 4749, 1074, 1092, 672, 4605, 4607, 7510, 504, 7511, 7512, 2]
|
|
// Exports: canManageGuildOfficialMessages, canSendGuildOfficialMessages, getAccessibleGuildOfficialTextColor, isGuildOfficialMessagesEnabled, showGuildOfficialMessageGradient, showGuildOfficialMessageTextColor, useCanToggleGuildOfficialMessages, useIsGuildOfficialMessagesEnabled
|
|
|
|
// Module 7509 (GuildOfficialMessageUtils)
|
|
import _modDef672 from "module_672" /* 672 */;
|
|
import utils_ColorUtils from "utils/ColorUtils" /* 1092 */;
|
|
import ColorUtils from "ColorUtils" /* 4605 */;
|
|
import shared from "shared" /* 4607 */;
|
|
import GuildOfficialMessagesExperimentDefault from "GuildOfficialMessagesExperiment" /* 7510 */;
|
|
import ThreadHooks from "ThreadHooks" /* 7511 */;
|
|
import isSystemMessageDefault from "isSystemMessage" /* 7512 */;
|
|
import GuildStore from "GuildStore" /* 2063 */;
|
|
import PermissionStore from "PermissionStore" /* 4395 */;
|
|
|
|
const require = globalThis.__r;
|
|
|
|
require = fn;
|
|
function useCanManageGuildOfficialMessages(arg0, arg1, location) {
|
|
_require = arg1;
|
|
closure_129_0 = arg0;
|
|
const items = [GuildStore];
|
|
const items1 = [arg0];
|
|
const stateFromStores = require("initialize").useStateFromStores(items, () => {
|
|
let guild = null;
|
|
if (null != closure_0) {
|
|
guild = GuildStore.getGuild(tmp);
|
|
}
|
|
return guild;
|
|
}, items1);
|
|
const obj = require("initialize");
|
|
const tmp = arg0;
|
|
let enabled = null != stateFromStores;
|
|
if (enabled) {
|
|
const features = stateFromStores.features;
|
|
enabled = features.has(constants2.VERIFIED);
|
|
}
|
|
if (enabled) {
|
|
enabled = obj2.useExperiment(obj3).enabled;
|
|
}
|
|
obj2 = GuildOfficialMessagesExperimentDefault;
|
|
obj3 = { guildId: tmp, location };
|
|
const items2 = [PermissionStore];
|
|
const items3 = [arg1];
|
|
if (enabled) {
|
|
enabled = tmp2Result.useStateFromStores(items2, () => PermissionStore.can(constants4.MANAGE_OFFICIAL_MESSAGES, closure_0), items3);
|
|
}
|
|
return enabled;
|
|
}
|
|
let closure_5 = fn(4749).GUILD_OFFICIAL_HIGHLIGHT_ALPHA;
|
|
const Constants = fn(1074);
|
|
({ ChannelTypes: metroRequire, GuildFeatures: closure_7, MessageFlags: closure_8, Permissions: closure_9 } = Constants);
|
|
const size = fn(2);
|
|
const result = size.fileFinishedImporting("modules/messages/GuildOfficialMessageUtils.tsx");
|
|
|
|
export const getAccessibleGuildOfficialTextColor = function getAccessibleGuildOfficialTextColor(officialMessageColor, semanticColor, saturation, arg3) {
|
|
let num = saturation;
|
|
if (saturation === undefined) {
|
|
num = 1;
|
|
}
|
|
let tmp = arg3;
|
|
if (arg3 === undefined) {
|
|
tmp = closure_5;
|
|
}
|
|
const int2hexResult = utils_ColorUtils.int2hex(officialMessageColor);
|
|
let tmp5 = _modDef672(semanticColor);
|
|
const tmp6 = _modDef672(int2hexResult);
|
|
const mixResult = _modDef672.mix(tmp5, int2hexResult, tmp, "rgb");
|
|
const contrastResult = _modDef672.contrast(tmp6, mixResult);
|
|
if (contrastResult < obj4.contrast(tmp6, tmp5)) {
|
|
tmp5 = mixResult;
|
|
}
|
|
obj4 = _modDef672;
|
|
const tmp2Result = ColorUtils;
|
|
return tmp2Result.getAccessibleForegroundColor({ foreground: tmp6, background: tmp5, ratio: shared.WCAGContrastRatios.Text, saturationFactor: num });
|
|
};
|
|
export function showGuildOfficialMessageGradient(officialMessageStyle) {
|
|
let tmp = "no_gradient" !== officialMessageStyle;
|
|
if (tmp) {
|
|
tmp = "hidden" !== officialMessageStyle;
|
|
}
|
|
return tmp;
|
|
}
|
|
export function showGuildOfficialMessageTextColor(officialMessageStyle) {
|
|
let tmp = "no_text_color" !== officialMessageStyle;
|
|
if (tmp) {
|
|
tmp = "hidden" !== officialMessageStyle;
|
|
}
|
|
return tmp;
|
|
}
|
|
export const isGuildOfficialMessagesEnabled = function isGuildOfficialMessagesEnabled(guild, GuildSettingsModalLanding) {
|
|
let enabled = null != guild;
|
|
if (enabled) {
|
|
const features = guild.features;
|
|
enabled = features.has(constants2.VERIFIED);
|
|
}
|
|
if (enabled) {
|
|
const obj2 = { guildId: guild.id, location: GuildSettingsModalLanding };
|
|
enabled = GuildOfficialMessagesExperimentDefault.getCurrentConfig(obj2).enabled;
|
|
}
|
|
return enabled;
|
|
};
|
|
export const useIsGuildOfficialMessagesEnabled = function useIsGuildOfficialMessagesEnabled(id, useGuildActionRows) {
|
|
_require = id;
|
|
const items = [GuildStore];
|
|
const items1 = [id];
|
|
const stateFromStores = require("initialize").useStateFromStores(items, () => {
|
|
let guild = null;
|
|
if (null != closure_0) {
|
|
guild = GuildStore.getGuild(tmp);
|
|
}
|
|
return guild;
|
|
}, items1);
|
|
const obj = require("initialize");
|
|
let enabled = null != stateFromStores;
|
|
if (enabled) {
|
|
const features = stateFromStores.features;
|
|
enabled = features.has(constants2.VERIFIED);
|
|
}
|
|
if (enabled) {
|
|
enabled = obj2.useExperiment(obj3).enabled;
|
|
}
|
|
return enabled;
|
|
};
|
|
export const canManageGuildOfficialMessages = function canManageGuildOfficialMessages(features, arg1, location) {
|
|
let enabled = null != features;
|
|
if (enabled) {
|
|
features = features.features;
|
|
enabled = features.has(constants2.VERIFIED);
|
|
}
|
|
if (enabled) {
|
|
const obj2 = { guildId: features.id, location };
|
|
enabled = GuildOfficialMessagesExperimentDefault.getCurrentConfig(obj2).enabled;
|
|
}
|
|
if (enabled) {
|
|
enabled = PermissionStore.can(constants4.MANAGE_OFFICIAL_MESSAGES, arg1);
|
|
}
|
|
return enabled;
|
|
};
|
|
export { useCanManageGuildOfficialMessages };
|
|
export const useCanToggleGuildOfficialMessages = function useCanToggleGuildOfficialMessages(message, channel, LongPressMessageActionSheet) {
|
|
const guild_id = channel.guild_id;
|
|
const tmpResult = useCanManageGuildOfficialMessages(guild_id, channel, LongPressMessageActionSheet);
|
|
let tmp3 = !tmpResult;
|
|
if (tmpResult) {
|
|
tmp3 = isSystemMessageDefault(message);
|
|
}
|
|
if (tmp3) {
|
|
return !tmp3;
|
|
} else if (message.hasFlag(constants3.IS_GUILD_OFFICIAL)) {
|
|
let isActiveChannelOrUnarchivableThread = ThreadHooks.getIsActiveChannelOrUnarchivableThread(channel);
|
|
} else {
|
|
isActiveChannelOrUnarchivableThread = null != channel && !channel.isPrivate();
|
|
if (isActiveChannelOrUnarchivableThread) {
|
|
isActiveChannelOrUnarchivableThread = ThreadHooks.getIsActiveChannelOrUnarchivableThread(channel);
|
|
}
|
|
if (isActiveChannelOrUnarchivableThread) {
|
|
isActiveChannelOrUnarchivableThread = channel.type !== constants.GUILD_VOICE;
|
|
}
|
|
if (isActiveChannelOrUnarchivableThread) {
|
|
isActiveChannelOrUnarchivableThread = channel.type !== constants.GUILD_STAGE_VOICE;
|
|
}
|
|
}
|
|
};
|
|
export const canSendGuildOfficialMessages = function canSendGuildOfficialMessages(guild, channel, _sendMessage) {
|
|
let enabled = null != guild;
|
|
if (enabled) {
|
|
const features = guild.features;
|
|
enabled = features.has(constants2.VERIFIED);
|
|
}
|
|
if (enabled) {
|
|
const obj2 = { guildId: guild.id, location: _sendMessage };
|
|
enabled = GuildOfficialMessagesExperimentDefault.getCurrentConfig(obj2).enabled;
|
|
}
|
|
if (enabled) {
|
|
enabled = PermissionStore.can(constants4.MANAGE_OFFICIAL_MESSAGES, channel);
|
|
}
|
|
if (enabled) {
|
|
let isActiveChannelOrUnarchivableThread = null != channel && !channel.isPrivate();
|
|
if (isActiveChannelOrUnarchivableThread) {
|
|
isActiveChannelOrUnarchivableThread = ThreadHooks.getIsActiveChannelOrUnarchivableThread(channel);
|
|
}
|
|
if (isActiveChannelOrUnarchivableThread) {
|
|
isActiveChannelOrUnarchivableThread = channel.type !== constants.GUILD_VOICE;
|
|
}
|
|
if (isActiveChannelOrUnarchivableThread) {
|
|
isActiveChannelOrUnarchivableThread = channel.type !== constants.GUILD_STAGE_VOICE;
|
|
}
|
|
enabled = isActiveChannelOrUnarchivableThread;
|
|
}
|
|
return enabled;
|
|
};
|