268 lines
9 KiB
TypeScript
268 lines
9 KiB
TypeScript
// Module ID: 4445
|
|
// Function ID: 4446
|
|
// Name: computeChannelName
|
|
// Dependencies: [32, 4169, 3892, 1874, 676, 1351, 4094, 1236, 589, 2]
|
|
// Exports: computeDefaultGroupDmName, computeDefaultGroupDmNameFromUserIds, computeGroupDmName, default, escapeChannelName, unescapeChannelName, useComputedGroupDmName
|
|
|
|
// Module 4445 (computeChannelName)
|
|
import _slicedToArray from "_slicedToArray";
|
|
import getHash from "getHash";
|
|
import upsertRelationship from "upsertRelationship";
|
|
import mergeGuildAvatar from "mergeGuildAvatar";
|
|
import ME from "ME";
|
|
|
|
let error;
|
|
let metroImportAll;
|
|
const require = arg1;
|
|
function computeChannelName(channel, closure_9, closure_7, arg3, arg4) {
|
|
let flag = arg3;
|
|
if (arg3 === undefined) {
|
|
flag = false;
|
|
}
|
|
let flag2 = arg4;
|
|
if (arg4 === undefined) {
|
|
flag2 = false;
|
|
}
|
|
if (channel.isObfuscated()) {
|
|
const intl3 = _require(1236).intl;
|
|
return intl3.string(_require(1236).t["/YzI63"]);
|
|
} else {
|
|
const type = channel.type;
|
|
if (constants.DM === type) {
|
|
if ("" !== str) {
|
|
let combined = str;
|
|
if (flag) {
|
|
const _HermesInternal6 = HermesInternal;
|
|
combined = "@" + str;
|
|
}
|
|
return combined;
|
|
} else {
|
|
const recipients = channel.recipients;
|
|
const mapped = recipients.map(closure_9.getUser);
|
|
const first = callback(mapped.filter(_require(1351).isNotNullish), 1)[0];
|
|
if (null == first) {
|
|
return "???";
|
|
} else {
|
|
if (!first.isProvisional) {
|
|
let str17 = closure_7.getNickname(first.id);
|
|
if (str17 == null) {
|
|
str17 = importDefault(4094).getName(first);
|
|
const obj3 = importDefault(4094);
|
|
}
|
|
if (str17 == null) {
|
|
str17 = "???";
|
|
}
|
|
let globalName = str17;
|
|
if (flag) {
|
|
const _HermesInternal5 = HermesInternal;
|
|
globalName = "@" + str17;
|
|
}
|
|
}
|
|
globalName = first.globalName;
|
|
}
|
|
}
|
|
} else if (tmp3.GROUP_DM === type) {
|
|
if ("" !== str) {
|
|
return str;
|
|
} else {
|
|
const recipients1 = channel.recipients;
|
|
_require = closure_7;
|
|
const mapped1 = recipients1.map(closure_9.getUser);
|
|
const found = mapped1.filter(_require(1351).isNotNullish);
|
|
const mapped2 = found.map((id) => {
|
|
nickname = nickname.getNickname(id.id);
|
|
if (nickname == null) {
|
|
nickname = outer1_1(outer1_2[6]).getName(id);
|
|
const obj = outer1_1(outer1_2[6]);
|
|
}
|
|
return nickname;
|
|
});
|
|
if (mapped2.length > 0) {
|
|
let joined = mapped2.join(", ");
|
|
} else {
|
|
const intl2 = tmp25(1236).intl;
|
|
const obj = { name: null };
|
|
obj[0] = importDefault(4094).getName(closure_9.getCurrentUser());
|
|
joined = intl2.formatToPlainString(tmp25(1236).t["9Uk8PF"], obj);
|
|
const obj2 = importDefault(4094);
|
|
}
|
|
}
|
|
} else {
|
|
if (tmp3.GUILD_ANNOUNCEMENT !== type) {
|
|
if (tmp3.GUILD_TEXT !== type) {
|
|
if (tmp3.GUILD_FORUM !== type) {
|
|
if (tmp3.GUILD_MEDIA !== type) {
|
|
if (tmp3.GUILD_CATEGORY === type) {
|
|
if (channel.id === closure_8) {
|
|
const intl = _require(1236).intl;
|
|
let stringResult = intl.string(_require(1236).t.GSfOoo);
|
|
} else {
|
|
stringResult = str;
|
|
if (flag2) {
|
|
const _HermesInternal3 = HermesInternal;
|
|
stringResult = "#\"" + str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"";
|
|
const str9 = str.replace(/\\/g, "\\\\");
|
|
}
|
|
}
|
|
return stringResult;
|
|
} else {
|
|
if (tmp3.PUBLIC_THREAD !== type) {
|
|
if (tmp3.PRIVATE_THREAD !== type) {
|
|
if (tmp3.ANNOUNCEMENT_THREAD !== type) {
|
|
if (tmp3.GUILD_VOICE !== type) {
|
|
if (tmp3.GUILD_STAGE_VOICE !== type) {
|
|
return str;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (flag2) {
|
|
const _HermesInternal2 = HermesInternal;
|
|
let combined1 = "#\"" + str.replace(/\\/g, "\\\\").replace(/"/g, "\\\"") + "\"";
|
|
const str4 = str.replace(/\\/g, "\\\\");
|
|
} else {
|
|
combined1 = str;
|
|
if (flag) {
|
|
combined1 = str;
|
|
if (channel.isThread()) {
|
|
const _HermesInternal = HermesInternal;
|
|
combined1 = "\"" + str + "\"";
|
|
}
|
|
}
|
|
}
|
|
return combined1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let combined2 = str;
|
|
if (flag) {
|
|
const _HermesInternal4 = HermesInternal;
|
|
combined2 = "#" + str;
|
|
}
|
|
return combined2;
|
|
}
|
|
}
|
|
}
|
|
({ ChannelTypes: error, NULL_STRING_CHANNEL_ID: metroImportAll } = ME);
|
|
const result = require("upsertRelationship").fileFinishedImporting("modules/channel/useChannelName.tsx");
|
|
|
|
export default function useChannelName(arg0) {
|
|
const _require = arg0;
|
|
let flag = arg1;
|
|
if (arg1 === undefined) {
|
|
flag = false;
|
|
}
|
|
const items = [mergeGuildAvatar, getHash, upsertRelationship];
|
|
return _require(589).useStateFromStores(items, () => {
|
|
let tmp2 = null;
|
|
if (null != closure_0) {
|
|
tmp2 = outer1_9(tmp, outer1_6, outer1_5, flag);
|
|
}
|
|
return tmp2;
|
|
});
|
|
};
|
|
export const computeDefaultGroupDmNameFromUserIds = function computeDefaultGroupDmNameFromUserIds(arr, getUser) {
|
|
const _require = arg2;
|
|
const mapped = arr.map(getUser.getUser);
|
|
const found = mapped.filter(_require(1351).isNotNullish);
|
|
const mapped1 = found.map((id) => {
|
|
nickname = nickname.getNickname(id.id);
|
|
if (nickname == null) {
|
|
nickname = outer1_1(outer1_2[6]).getName(id);
|
|
const obj = outer1_1(outer1_2[6]);
|
|
}
|
|
return nickname;
|
|
});
|
|
if (mapped1.length > 0) {
|
|
let joined = mapped1.join(", ");
|
|
} else {
|
|
const intl = tmp(1236).intl;
|
|
const obj = { name: null };
|
|
obj[0] = importDefault(4094).getName(getUser.getCurrentUser());
|
|
joined = intl.formatToPlainString(tmp(1236).t["9Uk8PF"], obj);
|
|
const obj2 = importDefault(4094);
|
|
}
|
|
return joined;
|
|
};
|
|
export const computeDefaultGroupDmName = function computeDefaultGroupDmName(recipients, getUser) {
|
|
recipients = recipients.recipients;
|
|
const _require = arg2;
|
|
const mapped = recipients.map(getUser.getUser);
|
|
const found = mapped.filter(_require(1351).isNotNullish);
|
|
const mapped1 = found.map((id) => {
|
|
nickname = nickname.getNickname(id.id);
|
|
if (nickname == null) {
|
|
nickname = outer1_1(outer1_2[6]).getName(id);
|
|
const obj = outer1_1(outer1_2[6]);
|
|
}
|
|
return nickname;
|
|
});
|
|
if (mapped1.length > 0) {
|
|
let joined = mapped1.join(", ");
|
|
} else {
|
|
const intl = tmp(1236).intl;
|
|
const obj = { name: null };
|
|
obj[0] = importDefault(4094).getName(getUser.getCurrentUser());
|
|
joined = intl.formatToPlainString(tmp(1236).t["9Uk8PF"], obj);
|
|
const obj2 = importDefault(4094);
|
|
}
|
|
return joined;
|
|
};
|
|
export const useComputedGroupDmName = function useComputedGroupDmName(arg0) {
|
|
const _require = arg0;
|
|
const items = [mergeGuildAvatar, upsertRelationship];
|
|
return _require(589).useStateFromStores(items, () => {
|
|
let obj = callback;
|
|
let tmp = null;
|
|
if (null != callback) {
|
|
tmp = null;
|
|
if (obj.isMultiUserDM()) {
|
|
const recipients = obj.recipients;
|
|
callback = outer1_5;
|
|
const mapped = recipients.map(outer1_6.getUser);
|
|
const found = mapped.filter(callback(outer1_2[5]).isNotNullish);
|
|
const mapped1 = found.map((id) => {
|
|
nickname = nickname.getNickname(id.id);
|
|
if (nickname == null) {
|
|
nickname = outer1_1(outer1_2[6]).getName(id);
|
|
const obj = outer1_1(outer1_2[6]);
|
|
}
|
|
return nickname;
|
|
});
|
|
if (mapped1.length > 0) {
|
|
let joined = mapped1.join(", ");
|
|
} else {
|
|
const intl = tmp3(tmp4[7]).intl;
|
|
obj = { name: null };
|
|
obj[0] = outer1_1(tmp4[6]).getName(obj2.getCurrentUser());
|
|
joined = intl.formatToPlainString(tmp3(tmp4[7]).t["9Uk8PF"], obj);
|
|
const obj4 = outer1_1(tmp4[6]);
|
|
}
|
|
obj2 = outer1_6;
|
|
}
|
|
}
|
|
return tmp;
|
|
});
|
|
};
|
|
export const computeGroupDmName = function computeGroupDmName(isObfuscated) {
|
|
if (!isObfuscated.isObfuscated()) {
|
|
if (isObfuscated.isMultiUserDM()) {
|
|
const name = isObfuscated.name;
|
|
let tmp;
|
|
if ("" !== name) {
|
|
tmp = name;
|
|
}
|
|
return tmp;
|
|
}
|
|
}
|
|
};
|
|
export { computeChannelName };
|
|
export const escapeChannelName = function escapeChannelName(channelName) {
|
|
return channelName.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
};
|
|
export const unescapeChannelName = function unescapeChannelName(str) {
|
|
return str.replace(/\\"/g, "\"").replace(/\\\\/g, "\\");
|
|
};
|