Files
discord-decomp/sources/modules/notifications/friend_online/FriendOnlineTimer.tsx
T
2026-07-27 16:20:00 +03:00

480 lines
21 KiB
TypeScript

/* Metro module 16144; source: modules/notifications/friend_online/FriendOnlineTimer.tsx; dependencies: [6, 7, 15, 17, 18, 5, 6876, 16145, 661, 482, 672, 507, 1216, 694, 3829, 4860, 2] */
function _fun124724(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#124724, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:6, offset: 0x025c1bcb, size: 376 bytes, params: 8, frame: 19
const env0_0 = require;
const isStatusEffectivelyOnline = function(a0) {
var ONLINE = StatusTypes.ONLINE;
return [ONLINE, StatusTypes.STREAMING].includes(a0);
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importDefault(6) /* metro dependency 6 */;
const env0_4 = importDefault(7) /* metro dependency 7 */;
const env0_5 = importDefault(15) /* metro dependency 15 */;
const env0_6 = importDefault(17) /* metro dependency 17 */;
const env0_7 = importDefault(18) /* metro dependency 18 */;
const env0_8 = importDefault(5) /* metro dependency 5 */;
const selfPresenceStore = importDefault(6876) /* metro dependency 6876: SelfPresenceStore */;
const friendOnlineTimerStore = importDefault(16145) /* metro dependency 16145: FriendOnlineTimerStore */;
const env0_11 = (require(661) /* metro dependency 661: Constants */).Endpoints;
const env0_12 = (require(482) /* metro dependency 482: Constants */).StatusTypes;
const Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
const MINUTE = Millis.MINUTE;
const env0_13 = 5 * MINUTE;
let value = importDefault(4860) /* metro dependency 4860: AutomaticLifecycleManager */;
value = _fun124732(value);
value = new value();
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/notifications/friend_online/FriendOnlineTimer.tsx');
exports.default = value;
}
function _isNativeReflectConstruct_124725() { // fn#124725, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:220, offset: 0x025c1d43, size: 98 bytes, params: 1, frame: 18
var Boolean;
var prototype;
var valueOf;
var call;
var Reflect;
var construct;
var closure;
var value;
var error;
try {
Boolean = global.Boolean;
prototype = Boolean.prototype;
valueOf = prototype.valueOf;
call = valueOf.call;
Reflect = global.Reflect;
construct = Reflect.construct;
Boolean = global.Boolean;
closure = function() {
};
value = Reflect.apply(construct, Reflect, [Boolean, [], closure]);
value = Reflect.apply(call, valueOf, [value]);
var result = !value;
} catch (error) {
}
return (_isNativeReflectConstruct_124725_isNativeReflectConstruct = function() {
return !!result;
})();
}
function _reportSessionMeaningfullyOnline() { // fn#124728, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:444, offset: 0x025c1da5, size: 50 bytes, params: 1, frame: 14
return env0_8(_fun124730).apply(this, arguments);
}
function _fun124732(a0) { // fn#124732, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:965, offset: 0x025c1f30, size: 97 bytes, params: 2, frame: 16
const closure = FriendOnlineTimerManager;
env0_7(closure, a0);
return env0_4(closure, [{key: '_initialize', value: function() {
}}, {key: '_terminate', value: function() {
this.clear();
}}]);
}
function* _fun124730() { // fn#124730, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:531, offset: 0x025c1de2, size: 284 bytes, params: 1, frame: 19
var binding;
var binding2;
var property;
var value3;
var HTTP;
var post;
var object2;
var USER_MEANINGFULLY_ONLINE;
var value4;
var value5;
var value6;
var error;
var HTTPResponseError;
var status;
var dispatch;
var Date;
if (true) {
value = environment.__proto__.__proto__;
try {
binding = env2_0;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
binding2 = env2_2;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
property = binding2[11];
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
value3 = binding(property);
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
HTTP = value3.HTTP;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
post = HTTP.post;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
object2 = {};
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
binding = env2_11;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
USER_MEANINGFULLY_ONLINE = binding.USER_MEANINGFULLY_ONLINE;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
object2.url = USER_MEANINGFULLY_ONLINE;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
object2.rejectWithError = true;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
try {
value4 = Reflect.apply(post, HTTP, [object2]);
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
yield value4;
try {
value5 = undefined;
value6 = false;
} catch (error) {
binding = env2_0;
HTTPResponseError = binding(env2_2[11]).HTTPResponseError;
if (error instanceof HTTPResponseError) {
status = error.status;
if (status !== 429) {
env2_1(env2_2[12]).captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
return undefined;
}
binding = env2_1;
value = binding(env2_2[12]);
value.captureException(error, {tags: {app_context: 'session_timer'}});
return undefined;
}
if (value6) {
return value5;
}
value = env2_1(env2_2[13]);
dispatch = value.dispatch;
object2 = {type: 'FRIEND_ONLINE_TIMER_REPORTED'};
Date = global.Date;
object2.timestampMs = Date.now();
Reflect.apply(dispatch, value, [object2]);
}
}
function FriendOnlineTimerManager(a0) { // fn#124733, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:977, offset: 0x025c1f91, size: 234 bytes, params: 2, frame: 20
var r0;
var Reflect;
let value = copyRestArgs(0, undefined);
let binding = env1_3;
binding(this, FriendOnlineTimerManager);
const items = [];
arraySpread(items, value, 0, items);
value = env1_6(FriendOnlineTimerManager);
binding = env1_5;
if (_isNativeReflectConstruct_124725()) {
Reflect = global.Reflect;
value = Reflect.construct(value, items, env1_6(this).constructor);
r0 = value;
} else {
value = value.apply(this, items);
r0 = value;
}
value = binding(this, r0);
value.timerId = null;
value.actions = {POST_CONNECTION_OPEN: POST_CONNECTION_OPEN_124734, CONNECTION_RESUMED: CONNECTION_RESUMED_124735,
CONNECTION_CLOSED: CONNECTION_CLOSED_124736, CONNECTION_INTERRUPTED: CONNECTION_INTERRUPTED,
SELF_PRESENCE_STORE_UPDATE: SELF_PRESENCE_STORE_UPDATE_124738};
value.start = start_124739;
value.clear = clear_124742;
return value;
}
function FriendOnlineTimerManagerPOST_CONNECTION_OPEN() { // fn#124734, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:1282, owner: FriendOnlineTimerManager.POST_CONNECTION_OPEN, offset: 0x00dc92bc, size: 18 bytes, params: 1, frame: 9
return env0_0.start();
}
function FriendOnlineTimerManagerStart() { // fn#124739, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:1448, owner: FriendOnlineTimerManager.start, offset: 0x025c207b, size: 151 bytes, params: 1, frame: 15
const NotifyFriendsOnComeOnline = (require(3829) /* metro dependency 3829: UserSettings */).NotifyFriendsOnComeOnline;
if (NotifyFriendsOnComeOnline.getSetting() && FriendOnlineTimerStore.isCooldownElapsed() && env0_0.timerId == null && isStatusEffectivelyOnline(SelfPresenceStore.getStatus())) {
env0_0.timerId = global.setTimeout(_fun124740, env2_13);
}
}
function FriendOnlineTimerManagerClear() { // fn#124742, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:1815, owner: FriendOnlineTimerManager.clear, offset: 0x025c217e, size: 54 bytes, params: 1, frame: 13
var clearTimeout;
var binding;
if (env0_0.timerId != null) {
clearTimeout = global.clearTimeout;
binding = env0_0;
clearTimeout(binding.timerId);
binding.timerId = null;
}
}
function _fun124740() { // fn#124740, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16352:1607, offset: 0x025c2112, size: 78 bytes, params: 1, frame: 12
var environment;
let value = environment.__proto__;
env1_0.timerId = null;
value = environment.__proto__.__proto__.__proto__;
if (isStatusEffectivelyOnline(SelfPresenceStore.getStatus()) && FriendOnlineTimerStore.isCooldownElapsed()) {
(function() {
return _reportSessionMeaningfullyOnline.apply(this, arguments);
})();
}
}