Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5030.js (118.4 MB)
92 lines
3.1 KiB
TypeScript
92 lines
3.1 KiB
TypeScript
// Module ID: 17711
|
|
// Function ID: 17712
|
|
// Name: GuildTemplateSettingsUtils
|
|
// Dependencies: [5, 32, 19, 2044, 4498, 7065, 1074, 504, 6929, 5266, 2]
|
|
// Exports: isGuildTemplateNameValid, useCanViewAllChannels, useGuildTemplate
|
|
|
|
// Module 17711 (GuildTemplateSettingsUtils)
|
|
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
|
|
import _slicedToArray from "module_32" /* 32 */;
|
|
import noop from "module_19" /* 19 */;
|
|
import ChannelStore from "ChannelStore" /* 2044 */;
|
|
import PermissionStore from "PermissionStore" /* 4498 */;
|
|
import GuildTemplateStore from "GuildTemplateStore" /* 7065 */;
|
|
|
|
const require = globalThis.__r;
|
|
|
|
const require = fn;
|
|
const Permissions = fn(1074).Permissions;
|
|
const size = fn(2);
|
|
const result = size.fileFinishedImporting("modules/guild_templates/GuildTemplateSettingsUtils.tsx");
|
|
|
|
export const isGuildTemplateNameValid = function isGuildTemplateNameValid(str) {
|
|
let tmp = null != str;
|
|
if (tmp) {
|
|
tmp = str.trim().length >= 2;
|
|
}
|
|
return tmp;
|
|
};
|
|
export const useCanViewAllChannels = function useCanViewAllChannels(guildId) {
|
|
_require = guildId;
|
|
const items = [ChannelStore, PermissionStore];
|
|
const items1 = [guildId];
|
|
return require("initialize").useStateFromStores(items, () => {
|
|
const values = Object.values(ChannelStore.getMutableGuildChannelsForGuild(closure_0));
|
|
return values.every((item) => closure_1_7.can(constants.VIEW_CHANNEL, item));
|
|
}, items1);
|
|
};
|
|
export const useGuildTemplate = function useGuildTemplate(guildId) {
|
|
_require = guildId;
|
|
[tmp2, importDefault] = noop.useState(null);
|
|
const loadError = _slicedToArray(noop.useState(null), 2);
|
|
dependencyMap = loadError[1];
|
|
const items = [guildId];
|
|
const effect = noop.useEffect(() => {
|
|
closure_0 = async function _fetchGuildTemplate(arg0, arg1) {
|
|
closure_129_0 = closure_0;
|
|
tmp3(null);
|
|
await closure_2_1(6929).loadTemplatesForGuild(closure_0);
|
|
if (1 === tmp7) {
|
|
c4 = 0;
|
|
closure_129_1 = closure_3;
|
|
const aPIError = new guildId(5266).APIError(closure_129_1);
|
|
tmp3(aPIError);
|
|
closure_1(closure_129_0);
|
|
c6 = 3;
|
|
} else if (arg0 === 1) {
|
|
c6 = 3;
|
|
throw arg1;
|
|
} else if (arg0 !== 2) {
|
|
c4 = 0;
|
|
}
|
|
return arg1;
|
|
};
|
|
if (null != closure_0) {
|
|
(function fetchGuildTemplate(arg0) {
|
|
const self = this;
|
|
const apply = closure_0.apply;
|
|
if (typeof apply === "unknown") {
|
|
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
|
|
} else {
|
|
applyArgumentsResult = apply(self, arguments);
|
|
}
|
|
return applyArgumentsResult;
|
|
})(tmp);
|
|
}
|
|
}, items);
|
|
const tmp = _slicedToArray(noop.useState(null), 2);
|
|
const items1 = [GuildTemplateStore];
|
|
const items2 = [guildId];
|
|
let loading = null != guildId;
|
|
const guildTemplate = require("initialize").useStateFromStores(items1, () => {
|
|
let forGuild;
|
|
if (null != closure_0) {
|
|
forGuild = GuildTemplateStore.getForGuild(tmp);
|
|
}
|
|
return forGuild;
|
|
}, items2);
|
|
if (loading) {
|
|
loading = tmp2 !== guildId;
|
|
}
|
|
return { loading, guildTemplate, loadError: loadError[0] };
|
|
};
|