Files
discord-decomp/sources/utils/UserUtils.tsx
T
2026-07-28 01:06:53 +03:00

276 lines
13 KiB
TypeScript

/* Metro module 3995; source: utils/UserUtils.tsx; dependencies: [3996, 1878, 661, 566, 1244, 2] */
import UserStore from '../stores/UserStore.tsx'; /* Metro dependency 1878 */
import StreamerModeStore from '../stores/StreamerModeStore.tsx'; /* Metro dependency 3996 */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as FluxModule from '../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../intl/index.native.tsx'; /* Metro dependency 1244 */
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
let env0_0 = require;
const conceal = function([property]) {
return '' + property + '…';
};
const present = function(a0) {
return !!(a0 != null && a0.length > 0);
};
const nameFromUser2 = nameFromUser;
const getName_328092 = getName_32809;
const useName2 = useName;
const getGlobalName2 = getGlobalName;
const getFormattedName2 = getFormattedName;
const humanizeStatus2 = humanizeStatus;
const accountAgeInRange2 = accountAgeInRange;
const getUserTag2 = getUserTag;
const useUserTag2 = useUserTag;
const closure10 = function(a0) {
var env0_0 = a0;
return require(dependencyMap[3]).useStateFromStores([UserStore], _fun32821);
};
const getUserIsStaff2 = getUserIsStaff;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_8 = {'mode': 'full', 'decoration': 'never', 'identifiable': 'auto'};
object = {getName: getName_328092, useName: useName2, isNameConcealed: function(a0) {
return a0.length === 2 && a0.endsWith('…');
}, getUserTag: getUserTag2, useUserTag: useUserTag2, getUserIsStaff: getUserIsStaff2,
getFormattedName: getFormattedName2, getGlobalName: getGlobalName2, humanizeStatus: humanizeStatus2,
useDirectMessageRecipient: closure10};
(FileImportTrackerModule).fileFinishedImporting('utils/UserUtils.tsx');
exports.default = object;
exports.nameFromUser = nameFromUser2;
exports.getName = getName_328092;
exports.useName = useName2;
exports.getGlobalName = getGlobalName2;
exports.getFormattedName = getFormattedName2;
exports.humanizeStatus = humanizeStatus2;
exports.accountAgeInRange = accountAgeInRange2;
exports.ageEligibleForPremiumUpsell = function(a0) {
return !accountAgeInRange(a0, {'minDaysOld': 0, 'maxDaysOld': 30});
};
exports.isNewUser = function(a0) {
return accountAgeInRange(a0, {'minDaysOld': 0, 'maxDaysOld': 7});
};
exports.getUserTag = getUserTag2;
exports.useUserTag = useUserTag2;
exports.useDirectMessageRecipient = closure10;
exports.getUserIsStaff = getUserIsStaff2;
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 = (IndexNativeModule).intl;
var string;
const t = (IndexNativeModule).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 object = {};
copyDataProperties(object, env0_8, undefined);
copyDataProperties(object, a1, undefined);
return presentUserTag(a0, object, object.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 object = {};
copyDataProperties(object, env0_8, undefined);
copyDataProperties(object, a1, undefined);
const hidePersonalInformation = (require(566) /* metro dependency 566: flux */).useStateFromStores([StreamerModeStore],
function() {
return StreamerModeStore.hidePersonalInformation;
});
return presentUserTagBinding(a0, object, 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 (FluxModule).useStateFromStores([UserStore], _fun32821);
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;
}
}
}
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;
}
}
global.__d(_fun32805, 3995, [3996, 1878, 661, 566, 1244,
2]) /* metro module 3995, dependencies: [3996, 1878, 661, 566, 1244, 2] */;