272 lines
12 KiB
TypeScript
272 lines
12 KiB
TypeScript
/* Metro module 3995; source: utils/UserUtils.tsx; dependencies: [3996, 1878, 661, 566, 1244, 2] */
|
|
function _fun32805(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#32805, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:6, offset: 0x0101eb41, size: 440 bytes, params: 8, frame: 30
|
|
var object2;
|
|
let env0_0 = require;
|
|
const conceal = function([property]) {
|
|
return '' + property + '…';
|
|
};
|
|
const present = function(a0) {
|
|
return !!(a0 != null && a0.length > 0);
|
|
};
|
|
const closure = nameFromUser;
|
|
const closure2 = getName_32809;
|
|
const closure3 = useName;
|
|
const closure4 = getGlobalName;
|
|
const closure5 = getFormattedName;
|
|
const closure6 = humanizeStatus;
|
|
const closure7 = accountAgeInRange;
|
|
const closure8 = getUserTag;
|
|
const closure9 = useUserTag;
|
|
const closure10 = function(a0) {
|
|
var env0_0 = a0;
|
|
return require(dependencyMap[3]).useStateFromStores([UserStore], _fun32821);
|
|
};
|
|
const closure11 = getUserIsStaff;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const streamerModeStore = importDefault(3996) /* metro dependency 3996: StreamerModeStore */;
|
|
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
|
|
const constantsModule = require(661) /* metro dependency 661: Constants */;
|
|
const env0_4 = constantsModule.NON_USER_BOT_DISCRIMINATOR;
|
|
const env0_5 = constantsModule.StatusTypes;
|
|
const env0_8 = {'mode': 'full', 'decoration': 'never', 'identifiable': 'auto'};
|
|
object2 = {getName: closure2, useName: closure3, isNameConcealed: function(a0) {
|
|
return a0.length === 2 && a0.endsWith('…');
|
|
}, getUserTag: closure8, useUserTag: closure9, getUserIsStaff: closure11, getFormattedName: closure5,
|
|
getGlobalName: closure4, humanizeStatus: closure6, useDirectMessageRecipient: closure10};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('utils/UserUtils.tsx');
|
|
exports.default = object2;
|
|
exports.nameFromUser = closure;
|
|
exports.getName = closure2;
|
|
exports.useName = closure3;
|
|
exports.getGlobalName = closure4;
|
|
exports.getFormattedName = closure5;
|
|
exports.humanizeStatus = closure6;
|
|
exports.accountAgeInRange = closure7;
|
|
exports.ageEligibleForPremiumUpsell = function(a0) {
|
|
return !accountAgeInRange(a0, {'minDaysOld': 0, 'maxDaysOld': 30});
|
|
};
|
|
exports.isNewUser = function(a0) {
|
|
return accountAgeInRange(a0, {'minDaysOld': 0, 'maxDaysOld': 7});
|
|
};
|
|
exports.getUserTag = closure8;
|
|
exports.useUserTag = closure9;
|
|
exports.useDirectMessageRecipient = closure10;
|
|
exports.getUserIsStaff = closure11;
|
|
}
|
|
|
|
function nameFromUser(a0) { // fn#32808, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:337, offset: 0x0101ed40, size: 92 bytes, params: 2, frame: 13
|
|
return present(a0.global_name) ? a0.global_name : present(a0.globalName) ? a0.globalName : present(a0.username) ? a0.username : env0_7;
|
|
}
|
|
|
|
function getName_32809(a0) { // fn#32809, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:474, offset: 0x0101ed9c, size: 115 bytes, params: 2, frame: 17
|
|
var r4;
|
|
var hidePersonalInformation;
|
|
var nameFromUserBinding;
|
|
var value2;
|
|
var value3;
|
|
var value4;
|
|
var username;
|
|
if (a0 != null) {
|
|
hidePersonalInformation = StreamerModeStore.hidePersonalInformation;
|
|
nameFromUserBinding = nameFromUser;
|
|
value2 = undefined;
|
|
value3 = nameFromUserBinding(a0);
|
|
if (hidePersonalInformation) {
|
|
value4 = value3.toLocaleLowerCase();
|
|
username = a0.username;
|
|
r4 = value4 === (username == null ? value2 : username.toLocaleLowerCase());
|
|
} else {
|
|
r4 = hidePersonalInformation;
|
|
}
|
|
r4 = r4 && a0.discriminator === '0';
|
|
return r4 ? conceal(value3) : value3;
|
|
}
|
|
}
|
|
|
|
function useName(a0) { // fn#32810, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:690, offset: 0x0101ee0f, size: 153 bytes, params: 2, frame: 18
|
|
var r4;
|
|
var value3;
|
|
var value4;
|
|
var username;
|
|
const value2 = undefined;
|
|
const hidePersonalInformation = (require(566) /* metro dependency 566: flux */).useStateFromStores([StreamerModeStore],
|
|
function() {
|
|
return StreamerModeStore.hidePersonalInformation;
|
|
});
|
|
if (a0 != null) {
|
|
value3 = nameFromUser(a0);
|
|
if (hidePersonalInformation) {
|
|
value4 = value3.toLocaleLowerCase();
|
|
username = a0.username;
|
|
r4 = value4 === (username == null ? value2 : username.toLocaleLowerCase());
|
|
} else {
|
|
r4 = hidePersonalInformation;
|
|
}
|
|
r4 = r4 && a0.discriminator === '0';
|
|
return r4 ? conceal(value3) : value3;
|
|
}
|
|
return value2;
|
|
}
|
|
|
|
function getGlobalName(a0) { // fn#32812, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:944, offset: 0x0101eeb7, size: 72 bytes, params: 2, frame: 13
|
|
var global_name;
|
|
var r0;
|
|
var presentBinding;
|
|
if (a0 != null) {
|
|
presentBinding = present;
|
|
if (presentBinding(a0.globalName)) {
|
|
r0 = a0.globalName;
|
|
} else {
|
|
presentBinding = present;
|
|
global_name = a0.global_name;
|
|
global_name = presentBinding(global_name) ? a0.global_name : undefined;
|
|
r0 = global_name;
|
|
}
|
|
return r0;
|
|
}
|
|
}
|
|
|
|
function getFormattedName(a0) { // fn#32813, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:1067, offset: 0x0101eeff, size: 127 bytes, params: 2, frame: 19
|
|
const value = a1;
|
|
const r4 = value !== undefined ? value : false;
|
|
if (a0 == null) {
|
|
return env0_7;
|
|
}
|
|
const globalName = getGlobalName(a0);
|
|
const r6 = r4 ? getUserTag(a0) : a0.username ?? env0_7;
|
|
return globalName === r6 ? globalName : globalName == null ? r6 : '' + globalName + ' (' + r6 + ')';
|
|
}
|
|
|
|
function humanizeStatus(a0) { // fn#32814, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:1232, offset: 0x0101ef7e, size: 545 bytes, params: 2, frame: 17
|
|
const intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
var string;
|
|
const t = (require(1244) /* metro dependency 1244: indexNative */).t;
|
|
const value = a1;
|
|
const r1 = value !== undefined ? value : {};
|
|
const isMobile = r1.isMobile;
|
|
let r0 = isMobile !== undefined && isMobile;
|
|
const isVR = r1.isVR;
|
|
const r4 = isVR !== undefined && isVR;
|
|
const ONLINE = StatusTypes.ONLINE;
|
|
if (ONLINE === a0) {
|
|
string = intl.string;
|
|
r0 = r4 ? Reflect.apply(string, intl, [t.SWnU0R]) : r0 ? Reflect.apply(string, intl,
|
|
[t['9hghLD']]) : Reflect.apply(string, intl, [t.WbGtnH]);
|
|
return r0;
|
|
}
|
|
const OFFLINE = StatusTypes.OFFLINE;
|
|
if (OFFLINE === a0) {
|
|
return intl.string(t.Vv0abJ);
|
|
}
|
|
const IDLE = StatusTypes.IDLE;
|
|
if (IDLE === a0) {
|
|
return intl.string(t.qWbtVU);
|
|
}
|
|
const DND = StatusTypes.DND;
|
|
if (DND === a0) {
|
|
return intl.string(t.jaNpQH);
|
|
}
|
|
const INVISIBLE = StatusTypes.INVISIBLE;
|
|
if (INVISIBLE === a0) {
|
|
return intl.string(t.bg24HO);
|
|
}
|
|
const STREAMING = StatusTypes.STREAMING;
|
|
if (STREAMING === a0) {
|
|
return intl.string(t.XKYej5);
|
|
}
|
|
StatusTypes.UNKNOWN;
|
|
return null;
|
|
}
|
|
|
|
function accountAgeInRange(a0, {maxDaysOld, minDaysOld}) { // fn#32815, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:1807, offset: 0x0101f19f, size: 115 bytes, params: 3, frame: 13
|
|
minDaysOld = minDaysOld === undefined ? 0 : minDaysOld;
|
|
if (a0 == null) {
|
|
return false;
|
|
}
|
|
const Date = global.Date;
|
|
let value = Date.now();
|
|
const createdAt = a0.createdAt;
|
|
const getTime = createdAt.getTime;
|
|
value -= Reflect.apply(getTime, createdAt, []);
|
|
return (maxDaysOld == null || value <= env0_6 * maxDaysOld) && value >= env0_6 * minDaysOld;
|
|
}
|
|
|
|
function presentUserTag(a0, a1, a2) { // fn#32816, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:1958, offset: 0x0101f212, size: 311 bytes, params: 4, frame: 18
|
|
var r0;
|
|
var r6;
|
|
var discriminator;
|
|
var intl;
|
|
let value = a2;
|
|
if (a0 == null) {
|
|
value = environment;
|
|
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
|
|
return intl.string((require(1244) /* metro dependency 1244: indexNative */).t.sKdZ6U);
|
|
}
|
|
const presentBinding = present;
|
|
const username = a0.username;
|
|
if (presentBinding(username)) {
|
|
r0 = !(a1.identifiable === 'always') && (!(a1.identifiable !== 'never') || value);
|
|
discriminator = a0.discriminator;
|
|
if (discriminator === '0') {
|
|
r6 = r0 ? conceal(a0.username) : a0.username;
|
|
return a1.decoration === 'never' ? r6 : '@' + r6;
|
|
}
|
|
discriminator = a0.discriminator;
|
|
if (discriminator !== NON_USER_BOT_DISCRIMINATOR) {
|
|
r0 = a1.mode === 'username' || r0 ? a0.username : '' + a0.username + '#' + a0.discriminator;
|
|
return r0;
|
|
}
|
|
r6 = r0 ? conceal(a0.username) : a0.username;
|
|
return a1.decoration === 'never' ? r6 : '@' + r6;
|
|
}
|
|
return env0_7;
|
|
}
|
|
|
|
function getUserTag(a0, a1) { // fn#32817, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:2380, offset: 0x0101f349, size: 71 bytes, params: 3, frame: 15
|
|
const object2 = {};
|
|
copyDataProperties(object2, env0_8, undefined);
|
|
copyDataProperties(object2, a1, undefined);
|
|
return presentUserTag(a0, object2, object2.identifiable !== 'auto' || StreamerModeStore.hidePersonalInformation);
|
|
}
|
|
|
|
function useUserTag(a0, a1) { // fn#32818, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:2501, offset: 0x0101f390, size: 94 bytes, params: 3, frame: 17
|
|
const presentUserTagBinding = presentUserTag;
|
|
const object2 = {};
|
|
copyDataProperties(object2, env0_8, undefined);
|
|
copyDataProperties(object2, a1, undefined);
|
|
const hidePersonalInformation = (require(566) /* metro dependency 566: flux */).useStateFromStores([StreamerModeStore],
|
|
function() {
|
|
return StreamerModeStore.hidePersonalInformation;
|
|
});
|
|
return presentUserTagBinding(a0, object2, hidePersonalInformation);
|
|
}
|
|
|
|
function useDirectMessageRecipient(a0) { // fn#32820, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:2627, offset: 0x0101f3ee, size: 64 bytes, params: 2, frame: 14
|
|
const env0_0 = a0;
|
|
return (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], _fun32821);
|
|
}
|
|
|
|
function getUserIsStaff() { // fn#32822, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:2789, offset: 0x0101f487, size: 37 bytes, params: 1, frame: 10
|
|
var r0;
|
|
var isStaff;
|
|
const value2 = UserStore.getCurrentUser() != null;
|
|
if (value2) {
|
|
isStaff = isStaff.isStaff();
|
|
r0 = isStaff;
|
|
} else {
|
|
r0 = value2;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function _fun32821() { // fn#32821, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4153:2704, offset: 0x0101f42e, size: 89 bytes, params: 1, frame: 13
|
|
var binding;
|
|
const value2 = null;
|
|
if (value2 != env0_0) {
|
|
binding = env0_0;
|
|
return binding.isPrivate() && env0_0.isDM() ? UserStore.getUser(env0_0.getRecipientId()) : value2;
|
|
}
|
|
}
|
|
|