decord/alpha/source/modules/channel/useChannelName.tsx

388 lines
13 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 5418
// Function ID: 5419
// Name: useChannelName
2026-10-09 10:00:15 +00:00
// Dependencies: [32, 4977, 4719, 1390, 1085, 1388, 4923, 1126, 558, 576, 504, 2]
2026-10-03 08:58:59 +00:00
// Exports: computeDefaultGroupDmName, computeDefaultGroupDmNameFromUserIds, computeGroupDmName, escapeChannelName, unescapeChannelName
2026-07-20 16:05:17 +00:00
2026-10-09 10:00:15 +00:00
// Module 5418 (useChannelName)
import GlobalUtils from "GlobalUtils" /* 1388 */;
import UserUtilsDefault from "UserUtils" /* 4923 */;
2026-10-03 08:58:59 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
2026-10-09 10:00:15 +00:00
import ExperimentStore from "ExperimentStore" /* 4977 */;
import RelationshipStore from "RelationshipStore" /* 4719 */;
import UserStore from "UserStore" /* 1390 */;
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
import ReactCompilerGating_mod from "ReactCompilerGating" /* 558 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
2026-10-03 08:58:59 +00:00
let _require, multiUserDM, nickname;
2026-10-03 08:58:59 +00:00
let metroImportAll;
let metroImportDefault;
2026-10-09 10:00:15 +00:00
const f91555 = (id) => {
2026-10-03 08:58:59 +00:00
nickname = nickname.getNickname(id.id);
if (nickname == null) {
const obj = closure_2_1(closure_2_2[6]);
nickname = obj.getName(id);
}
return nickname;
};
function computeChannelName(channel, UserStore, RelationshipStore, flag, arg4) {
2026-10-03 08:58:59 +00:00
let obj2;
if (flag === undefined) {
2026-07-20 16:05:17 +00:00
flag = false;
}
2026-07-29 08:29:29 +00:00
let flag2 = arg4;
if (arg4 === undefined) {
2026-07-20 16:05:17 +00:00
flag2 = false;
}
if (channel.isObfuscated()) {
2026-10-03 08:58:59 +00:00
const intl3 = require("intl").intl;
return intl3.string(require("intl").t["/YzI63"]);
2026-07-20 16:05:17 +00:00
} else {
const type = channel.type;
2026-08-04 08:36:32 +00:00
if (constants.DM === type) {
2026-10-03 08:58:59 +00:00
if ("" !== channel.name) {
2026-07-29 08:29:29 +00:00
let combined = str;
if (flag) {
2026-08-04 08:36:32 +00:00
const _HermesInternal6 = HermesInternal;
2026-07-29 08:29:29 +00:00
combined = "@" + str;
}
return combined;
2026-07-20 16:05:17 +00:00
} else {
const recipients = channel.recipients;
const mapped = recipients.map(UserStore.getUser);
const first = _slicedToArray(mapped.filter(require("GlobalUtils").isNotNullish), 1)[0];
2026-10-03 08:58:59 +00:00
let str19 = "???";
if (null != first) {
let globalName;
if (first.isProvisional) {
if (null != first.globalName) {
globalName = first.globalName;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
str19 = globalName;
}
let str17 = RelationshipStore.getNickname(first.id);
if (str17 == null) {
const obj3 = UserUtilsDefault;
str17 = obj3.getName(first);
}
if (str17 == null) {
str17 = "???";
}
globalName = str17;
if (flag) {
const _HermesInternal5 = HermesInternal;
globalName = "@" + str17;
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
return str19;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
} else if (constants.GROUP_DM === type) {
let tmp14 = str;
if ("" === channel.name) {
let joined;
2026-07-29 08:29:29 +00:00
const recipients1 = channel.recipients;
_require = RelationshipStore;
const mapped1 = recipients1.map(UserStore.getUser);
const found = mapped1.filter(require("GlobalUtils").isNotNullish);
2026-10-09 10:00:15 +00:00
const mapped2 = found.map(f91555);
2026-07-29 08:29:29 +00:00
if (mapped2.length > 0) {
2026-10-03 08:58:59 +00:00
joined = mapped2.join(", ");
2026-07-29 08:29:29 +00:00
} else {
2026-10-03 08:58:59 +00:00
const intl2 = tmp24(1126).intl;
const formatToPlainString = intl2.formatToPlainString;
const obj = { name: obj2.getName(UserStore.getCurrentUser()) };
const v9Uk8PF = tmp24(1126).t["9Uk8PF"];
obj2 = UserUtilsDefault;
joined = formatToPlainString(v9Uk8PF, obj);
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
tmp14 = joined;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
return tmp14;
2026-07-20 16:05:17 +00:00
} else {
2026-10-03 08:58:59 +00:00
if (constants.GUILD_ANNOUNCEMENT !== type) {
if (constants.GUILD_TEXT !== type) {
if (constants.GUILD_FORUM !== type) {
if (constants.GUILD_MEDIA !== type) {
if (constants.GUILD_APP !== type) {
if (constants.GUILD_CATEGORY === type) {
let stringResult;
2026-09-02 09:53:35 +00:00
if (channel.id === closure_8) {
2026-10-03 08:58:59 +00:00
const intl = require("intl").intl;
stringResult = intl.string(require("intl").t.GSfOoo);
2026-09-02 09:53:35 +00:00
} else {
stringResult = str;
if (flag2) {
const _HermesInternal3 = HermesInternal;
2026-10-03 08:58:59 +00:00
const str9 = channel.name.replace(/\\/g, "\\\\");
stringResult = "#\"" + str9.replace(/"/g, "\\\"") + "\"";
2026-09-02 09:53:35 +00:00
}
2026-08-04 08:36:32 +00:00
}
2026-09-02 09:53:35 +00:00
return stringResult;
} else {
2026-10-03 08:58:59 +00:00
let combined1;
if (constants.PUBLIC_THREAD !== type) {
if (constants.PRIVATE_THREAD !== type) {
if (constants.ANNOUNCEMENT_THREAD !== type) {
if (constants.MEDIA_THREAD !== type) {
if (constants.GUILD_VOICE !== type) {
if (constants.GUILD_STAGE_VOICE !== type) {
if (constants.GUILD_STORE !== type) {
if (constants.GUILD_DIRECTORY !== type) {
if (constants.GUILD_SPACE !== type) {
2026-09-02 09:53:35 +00:00
const UNKNOWN = tmp3.UNKNOWN;
}
}
}
2026-10-03 08:58:59 +00:00
return channel.name;
2026-09-02 09:53:35 +00:00
}
}
2026-07-20 16:05:17 +00:00
}
}
}
}
2026-09-02 09:53:35 +00:00
if (flag2) {
const _HermesInternal2 = HermesInternal;
2026-10-03 08:58:59 +00:00
const str4 = channel.name.replace(/\\/g, "\\\\");
combined1 = "#\"" + str4.replace(/"/g, "\\\"") + "\"";
2026-09-02 09:53:35 +00:00
} else {
2026-08-04 08:36:32 +00:00
combined1 = str;
2026-09-02 09:53:35 +00:00
if (flag) {
combined1 = str;
if (channel.isThread()) {
const _HermesInternal = HermesInternal;
combined1 = "\"" + str + "\"";
}
2026-08-04 08:36:32 +00:00
}
2026-07-20 16:05:17 +00:00
}
2026-09-02 09:53:35 +00:00
return combined1;
2026-07-20 16:05:17 +00:00
}
}
}
}
}
}
2026-07-29 08:29:29 +00:00
let combined2 = str;
2026-07-20 16:05:17 +00:00
if (flag) {
2026-08-04 08:36:32 +00:00
const _HermesInternal4 = HermesInternal;
2026-07-29 08:29:29 +00:00
combined2 = "#" + str;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return combined2;
2026-07-20 16:05:17 +00:00
}
}
}
2026-10-03 08:58:59 +00:00
({ ChannelTypes: metroImportDefault, NULL_STRING_CHANNEL_ID: metroImportAll } = Constants);
let ReactCompilerGating = ReactCompilerGating_mod;
2026-10-08 09:57:35 +00:00
const tmp3 = ReactCompilerGating.isReactCompilerEnabled() ? (function useComputedGroupDmName(arg0) {
2026-10-03 08:58:59 +00:00
let first;
let tmp7;
_require = arg0;
let tmp = _require;
const obj = require("react");
const cResult = obj.c(3);
if (cResult[0] === Symbol.for("react.memo_cache_sentinel")) {
const items = [UserStore, ];
items[1] = RelationshipStore;
cResult[0] = items;
first = items;
} else {
first = cResult[0];
}
if (cResult[1] !== arg0) {
const fn = function l() {
let obj4;
let tmp = null;
if (null != multiUserDM) {
tmp = null;
if (multiUserDM.isMultiUserDM()) {
let joined;
const recipients = obj.recipients;
multiUserDM = RelationshipStore;
const mapped = recipients.map(UserStore.getUser);
const found = mapped.filter(GlobalUtils.isNotNullish);
2026-10-09 10:00:15 +00:00
const mapped1 = found.map(f91555);
2026-10-03 08:58:59 +00:00
const obj2 = UserStore;
if (mapped1.length > 0) {
joined = mapped1.join(", ");
} else {
const intl = tmp3(1126).intl;
const formatToPlainString = intl.formatToPlainString;
const obj3 = { name: obj4.getName(obj2.getCurrentUser()) };
const v9Uk8PF = tmp3(1126).t["9Uk8PF"];
obj4 = UserUtilsDefault;
joined = formatToPlainString(v9Uk8PF, obj3);
}
tmp = joined;
}
}
return tmp;
};
cResult[1] = arg0;
cResult[2] = fn;
tmp7 = fn;
} else {
tmp7 = cResult[2];
}
const tmpResult = tmp(504);
return tmpResult.useStateFromStores(first, tmp7);
2026-10-08 09:57:35 +00:00
}) : (function useComputedGroupDmName(arg0) {
2026-10-03 08:58:59 +00:00
_require = arg0;
let obj = require("get initialized");
const items = [UserStore, RelationshipStore];
return obj.useStateFromStores(items, () => {
let obj4;
let obj = closure_0;
let tmp = null;
if (null != closure_0) {
tmp = null;
if (obj.isMultiUserDM()) {
let joined;
const recipients = obj.recipients;
closure_0 = RelationshipStore;
const mapped = recipients.map(UserStore.getUser);
const found = mapped.filter(GlobalUtils.isNotNullish);
2026-10-09 10:00:15 +00:00
const mapped1 = found.map(f91555);
2026-10-03 08:58:59 +00:00
const obj2 = UserStore;
if (mapped1.length > 0) {
joined = mapped1.join(", ");
} else {
const intl = tmp3(1126).intl;
const formatToPlainString = intl.formatToPlainString;
const obj3 = { name: obj4.getName(obj2.getCurrentUser()) };
const v9Uk8PF = tmp3(1126).t["9Uk8PF"];
obj4 = UserUtilsDefault;
joined = formatToPlainString(v9Uk8PF, obj3);
}
tmp = joined;
}
}
return tmp;
});
});
ReactCompilerGating = ReactCompilerGating_mod;
2026-10-08 09:57:35 +00:00
const tmp4 = ReactCompilerGating.isReactCompilerEnabled() ? (function useChannelName(arg0, arg1) {
2026-10-03 08:58:59 +00:00
let closure_0;
let first;
_require = arg0;
const tmp = _require;
let tmp2 = dependencyMap;
const obj = require("react");
const cResult = obj.c(4);
let closure_1 = tmp4;
if (cResult[0] === Symbol.for("react.memo_cache_sentinel")) {
const items = [UserStore, , ];
items[1] = ExperimentStore;
items[2] = RelationshipStore;
cResult[0] = items;
first = items;
} else {
first = cResult[0];
}
if (cResult[1] === arg0) {
let tmp9;
if (cResult[2] === (undefined !== arg1 && arg1)) {
tmp9 = cResult[3];
}
const tmpResult = tmp(504);
return tmpResult.useStateFromStores(first, tmp9);
}
const fn = function c() {
let tmp2 = null;
if (null != closure_0) {
tmp2 = computeChannelName(tmp, UserStore, RelationshipStore, closure_1);
}
return tmp2;
};
cResult[1] = arg0;
cResult[2] = undefined !== arg1 && arg1;
cResult[3] = fn;
tmp9 = fn;
2026-10-08 09:57:35 +00:00
}) : (function useChannelName(arg0) {
2026-10-03 08:58:59 +00:00
let closure_0;
_require = arg0;
2026-07-29 08:29:29 +00:00
let flag = arg1;
2026-07-20 16:05:17 +00:00
if (arg1 === undefined) {
flag = false;
}
const items = [UserStore, ExperimentStore, RelationshipStore];
2026-10-03 08:58:59 +00:00
const obj = require("get initialized");
return obj.useStateFromStores(items, () => {
2026-07-29 08:29:29 +00:00
let tmp2 = null;
2026-07-23 10:11:24 +00:00
if (null != closure_0) {
tmp2 = computeChannelName(tmp, UserStore, RelationshipStore, flag);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp2;
2026-07-20 16:05:17 +00:00
});
2026-10-03 08:58:59 +00:00
});
function computeDefaultGroupDmNameFromUserIds(arr, getUser, arg2) {
let closure_0;
let joined;
let obj2;
_require = arg2;
2026-07-29 08:29:29 +00:00
const mapped = arr.map(getUser.getUser);
const found = mapped.filter(require("GlobalUtils").isNotNullish);
2026-10-09 10:00:15 +00:00
const mapped1 = found.map(f91555);
2026-07-29 08:29:29 +00:00
if (mapped1.length > 0) {
2026-10-03 08:58:59 +00:00
joined = mapped1.join(", ");
2026-07-29 08:29:29 +00:00
} else {
2026-10-03 08:58:59 +00:00
const intl = tmp(1126).intl;
const formatToPlainString = intl.formatToPlainString;
const obj = { name: obj2.getName(getUser.getCurrentUser()) };
const v9Uk8PF = tmp(1126).t["9Uk8PF"];
obj2 = UserUtilsDefault;
joined = formatToPlainString(v9Uk8PF, obj);
2026-07-29 08:29:29 +00:00
}
return joined;
2026-10-03 08:58:59 +00:00
}
function computeDefaultGroupDmName(recipients, getUser, arg2) {
let closure_0;
let joined;
let obj2;
2026-07-29 08:29:29 +00:00
recipients = recipients.recipients;
_require = arg2;
2026-07-29 08:29:29 +00:00
const mapped = recipients.map(getUser.getUser);
const found = mapped.filter(require("GlobalUtils").isNotNullish);
2026-10-09 10:00:15 +00:00
const mapped1 = found.map(f91555);
2026-07-29 08:29:29 +00:00
if (mapped1.length > 0) {
2026-10-03 08:58:59 +00:00
joined = mapped1.join(", ");
2026-07-29 08:29:29 +00:00
} else {
2026-10-03 08:58:59 +00:00
const intl = tmp(1126).intl;
const formatToPlainString = intl.formatToPlainString;
const obj = { name: obj2.getName(getUser.getCurrentUser()) };
const v9Uk8PF = tmp(1126).t["9Uk8PF"];
obj2 = UserUtilsDefault;
joined = formatToPlainString(v9Uk8PF, obj);
2026-07-29 08:29:29 +00:00
}
return joined;
2026-10-03 08:58:59 +00:00
}
function escapeChannelName(channelName) {
const str = channelName.replace(/\\/g, "\\\\");
return str.replace(/"/g, "\\\"");
}
const result = size.fileFinishedImporting("modules/channel/useChannelName.tsx");
export default tmp4;
export { computeDefaultGroupDmNameFromUserIds };
export { computeDefaultGroupDmName };
export const useComputedGroupDmName = tmp3;
2026-09-02 09:53:35 +00:00
export const computeGroupDmName = function computeGroupDmName(stateFromStores) {
if (!stateFromStores.isObfuscated()) {
if (stateFromStores.isMultiUserDM()) {
const name = stateFromStores.name;
2026-07-20 16:05:17 +00:00
let tmp;
if ("" !== name) {
tmp = name;
}
return tmp;
}
}
};
export { computeChannelName };
2026-10-03 08:58:59 +00:00
export { escapeChannelName };
2026-07-29 08:29:29 +00:00
export const unescapeChannelName = function unescapeChannelName(str) {
2026-10-03 08:58:59 +00:00
str = str.replace(/\\"/g, "\"");
return str.replace(/\\\\/g, "\\");
2026-07-20 16:05:17 +00:00
};