Files
discord-decomp/sources/stores/IdleStore.tsx
T
2026-07-27 16:20:00 +03:00

243 lines
11 KiB
TypeScript

/* Metro module 4795; source: stores/IdleStore.tsx; dependencies: [6, 7, 15, 17, 18, 1226, 661, 4291, 477, 3829, 672, 694, 3767, 4796, 6949, 566, 2] */
function _fun41515(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#41515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:6, offset: 0x011201a3, size: 783 bytes, params: 8, frame: 23
var powerMonitor;
const env0_0 = require;
const closure = checkIdleAFK;
const closure2 = OVERLAY_SET_NOT_IDLE;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const value = undefined;
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 authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */;
const constantsModule = require(661) /* metro dependency 661: Constants */;
const env0_9 = constantsModule.IDLE_DURATION;
const env0_10 = constantsModule.AppStates;
const env0_11 = (require(4291) /* metro dependency 4291: Constants */).SpeakingFlags;
const Date = global.Date;
let env0_13 = Date.now();
if ((require(477) /* metro dependency 477: PlatformUtils */).isPlatformEmbedded) {
powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */) == null ? value : (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor;
if (powerMonitor != null) {
checkNativeIdle();
powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor;
powerMonitor.on('resume', function() {
env0_16 = false;
handlePowerEvent(false);
});
powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor;
powerMonitor.on('suspend', _fun41526);
powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor;
powerMonitor.on('lock-screen', _fun41527);
powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor;
powerMonitor.on('unlock-screen', _fun41528);
} else {
global.setInterval(closure, 30 * (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND);
}
} else {
global.setInterval(closure, 30 * (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND);
}
(importDefault(6949) /* metro dependency 6949 */)(function() {
OVERLAY_SET_NOT_IDLE({});
}, 500);
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
const value5 = _fun41530(Store);
value5.displayName = 'IdleStore';
const value8 = new value5(importDefault(694) /* metro dependency 694: Dispatcher */, {IDLE: function(a0) {
env0_14 = a0.idle;
}, AFK: function(a0) {
env0_15 = a0.afk;
}, SPEAKING: function({userId, speakingFlags}) {
if (speakingFlags !== SpeakingFlags.NONE && userId === AuthenticationStore.getId()) {
OVERLAY_SET_NOT_IDLE({});
}
return false;
}, APP_STATE_UPDATE: function({state}) {
env0_18 = state === AppStates.BACKGROUND;
env0_12 = null;
env0_13 = global.Date.now();
checkIdleAFK();
return false;
}, OVERLAY_SET_NOT_IDLE: closure2, CHANNEL_SELECT: closure2, VOICE_CHANNEL_SELECT: closure2, WINDOW_FOCUS: closure2,
OVERLAY_INITIALIZE: closure2, OVERLAY_SET_INPUT_LOCKED: closure2});
(require(2) /* metro dependency 2 */).fileFinishedImporting('stores/IdleStore.tsx');
exports.default = value8;
return value;
}
function _isNativeReflectConstruct_41516() { // fn#41516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:224, offset: 0x011204b2, size: 94 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_41516_isNativeReflectConstruct = function() {
return !!result;
})();
}
function isSystemIdle() { // fn#41519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:461, offset: 0x01120510, size: 61 bytes, params: 1, frame: 13
let r0 = env0_16 || env0_17;
r0 = !r0 ? (require(477) /* metro dependency 477: PlatformUtils */).isAndroid() && env0_18 : r0;
return r0;
}
function checkIdleAFK() { // fn#41520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:521, offset: 0x0112054d, size: 427 bytes, params: 1, frame: 18
var value4;
var Math;
var min;
const Date = global.Date;
let value = Date.now();
value -= env0_13;
if (value > IDLE_DURATION) {
if (!env0_14) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'IDLE', 'idle': true,
idleSince: env0_13});
}
} else if (isSystemIdle()) {
if (!env0_14) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'IDLE', 'idle': true,
idleSince: env0_13});
}
} else if (env0_14) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'IDLE', 'idle': false});
}
const AfkTimeout = (require(3829) /* metro dependency 3829: UserSettings */).AfkTimeout;
value = AfkTimeout.getSetting();
if (value === 0) {
if (!env0_15) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true});
}
} else if (env0_12 != null) {
if (!env0_15) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true});
}
} else {
value4 = global.Date.now() - env0_13;
Math = global.Math;
min = Math.min;
value *= (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND;
if (value4 > Reflect.apply(min, Math, [value, IDLE_DURATION])) {
if (!env0_15) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true});
}
} else if (isSystemIdle()) {
if (!env0_15) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true});
}
} else if (env0_15) {
(importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': false});
}
}
}
function handlePowerEvent(a0) { // fn#41521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:928, offset: 0x011206f8, size: 45 bytes, params: 2, frame: 9
var value;
if (a0) {
value = global.Date.now();
}
checkIdleAFK();
}
function CHANNEL_SELECT_41522({timestamp, type, bypassIdleUpdate}) { // fn#41522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1869, offset: 0x01120725, size: 112 bytes, params: 2, frame: 12
var value2;
const r2 = type === 'OVERLAY_SET_NOT_IDLE' && timestamp != null;
let r0 = r2 && timestamp <= env0_13;
r0 = !r0 ? bypassIdleUpdate : r0;
if (!r0) {
if (!r2) {
value2 = global.Date.now();
}
checkIdleAFK();
}
return false;
}
function checkNativeIdle() { // fn#41523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1072, offset: 0x01120795, size: 152 bytes, params: 1, frame: 16
var getSystemIdleTimeMs;
var powerMonitor;
const closure = handleIdleTime;
var systemIdleTimeMs;
const value2 = undefined;
if ((importDefault(3767) /* metro dependency 3767: DiscordNative */) == null) {
getSystemIdleTimeMs = value2;
} else {
powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor;
getSystemIdleTimeMs = powerMonitor == null ? value2 : powerMonitor.getSystemIdleTimeMs;
}
if (getSystemIdleTimeMs != null) {
systemIdleTimeMs = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor.getSystemIdleTimeMs();
if (systemIdleTimeMs instanceof global.Promise) {
systemIdleTimeMs.then(closure);
} else {
closure(systemIdleTimeMs);
}
}
return value2;
}
function _fun41526() { // fn#41526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1564, offset: 0x011208d3, size: 52 bytes, params: 1, frame: 12
handlePowerEvent(true);
(importDefault(4796) /* metro dependency 4796: SelectedChannelActionCreators */).disconnect();
}
function _fun41527() { // fn#41527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1660, offset: 0x01120907, size: 22 bytes, params: 1, frame: 11
handlePowerEvent(true);
}
function _fun41528() { // fn#41528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1736, offset: 0x0112091d, size: 22 bytes, params: 1, frame: 11
handlePowerEvent(false);
}
function _fun41530(a0) { // fn#41530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:2050, offset: 0x01120945, size: 187 bytes, params: 2, frame: 16
const closure = IdleStore;
env0_7(closure, a0);
return env0_4(closure, [{key: 'initialize', value: function() {
this.waitFor(AuthenticationStore);
}}, {key: 'isIdle', value: value_41533}, {key: 'isAFK', value: value_41534}, {key: 'getIdleSince',
value: value_41535}, {key: 'getSystemSuspended', value: value_41536}, {key: 'getSystemLocked',
value: value_41537}]);
}
function handleIdleTime(a0) { // fn#41524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1120, owner: checkNativeIdle.handleIdleTime, offset: 0x0112082d, size: 144 bytes, params: 2, frame: 16
const Date = global.Date;
let value = Date.now();
value -= a0;
if (env1_12 == null || value > env1_12) {
env1_13 = global.Math.max(value, env1_13);
}
checkIdleAFK();
const setTimeout = global.setTimeout;
const checkNativeIdleBinding = checkNativeIdle;
const Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis;
const SECOND = Millis.SECOND;
setTimeout(checkNativeIdleBinding, 10 * SECOND);
}
function value_41535() { // fn#41535, offset: 0x01120a00, size: 18 bytes, params: 1, frame: 3
return env1_14 ? env1_13 : null;
}