decord/alpha/source/stores/IdleStore.tsx

299 lines
8.6 KiB
TypeScript
Raw Permalink Normal View History

2026-10-10 08:08:14 +00:00
// Module ID: 5888
// Function ID: 5889
// Name: IdleStore
2026-10-10 08:08:14 +00:00
// Dependencies: [502, 1085, 5117, 1382, 2041, 1102, 584, 4731, 5889, 551, 504, 2]
2026-07-20 16:05:17 +00:00
2026-10-10 08:08:14 +00:00
// Module 5888 (IdleStore)
2026-10-03 08:58:59 +00:00
import _mod2 from "module_2" /* 2 */;
import get_initializedDefault from "get initialized" /* 504 */;
import debounceDefault from "debounce" /* 551 */;
2026-10-03 08:58:59 +00:00
import DispatcherDefault from "Dispatcher" /* 584 */;
import DurationsDefault from "Durations" /* 1102 */;
2026-10-09 10:00:15 +00:00
import PlatformUtils from "PlatformUtils" /* 1382 */;
import UserSettings from "UserSettings" /* 2041 */;
2026-10-10 08:08:14 +00:00
import DiscordNativeDefault from "DiscordNative" /* 4731 */;
import Constants2 from "Constants" /* 5117 */;
import SelectedChannelActionCreatorsDefault from "SelectedChannelActionCreators" /* 5889 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
2026-10-03 08:58:59 +00:00
import Constants from "Constants" /* 1085 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
let c3;
let hasOwnProperty;
let metroRequire;
let obj;
2026-07-20 16:05:17 +00:00
function checkIdleAFK() {
if (Date.now() - idleSince <= hasOwnProperty) {
2026-10-03 08:58:59 +00:00
let tmp2 = c11 || c12;
2026-07-29 08:29:29 +00:00
if (!tmp2) {
2026-10-03 08:58:59 +00:00
const obj = PlatformUtils;
tmp2 = obj.isAndroid() && closure_13;
obj.isAndroid() && closure_13;
2026-07-29 08:29:29 +00:00
}
if (!tmp2) {
2026-10-03 08:58:59 +00:00
const tmp6 = idle;
if (tmp6) {
const obj2 = DispatcherDefault;
obj2.dispatch({ type: "IDLE", idle: false });
2026-07-20 16:05:17 +00:00
}
}
const AfkTimeout = UserSettings.AfkTimeout;
2026-07-20 16:05:17 +00:00
const setting = AfkTimeout.getSetting();
2026-10-03 08:58:59 +00:00
const tmp15 = require;
2026-07-20 16:05:17 +00:00
if (0 !== setting) {
if (null == c3) {
2026-07-20 16:05:17 +00:00
const _Date = Date;
const _Math = Math;
const diff = Date.now() - idleSince;
2026-10-03 08:58:59 +00:00
const tmp29 = importDefault;
if (diff <= Math.min(setting * DurationsDefault.Millis.SECOND, tmp)) {
2026-10-03 08:58:59 +00:00
let tmp18 = c11 || c12;
if (!tmp18) {
2026-10-09 10:00:15 +00:00
const tmp15Result = tmp15(1382);
2026-10-03 08:58:59 +00:00
tmp18 = tmp15Result.isAndroid() && closure_13;
tmp15Result.isAndroid() && closure_13;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
if (!tmp18) {
const tmp20 = afk;
if (tmp20) {
const tmp29Result = tmp29(584);
tmp29Result.dispatch({ type: "AFK", afk: false });
2026-07-20 16:05:17 +00:00
}
}
}
}
}
2026-10-03 08:58:59 +00:00
const tmp22 = afk;
if (!tmp22) {
const obj7 = DispatcherDefault;
obj7.dispatch({ type: "AFK", afk: true });
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
const tmp10 = idle;
if (!tmp10) {
const obj4 = { type: "IDLE", idle: true, idleSince };
2026-10-03 08:58:59 +00:00
const obj3 = DispatcherDefault;
obj3.dispatch(obj4);
2026-07-20 16:05:17 +00:00
}
}
({ IDLE_DURATION: hasOwnProperty, AppStates: metroRequire } = Constants);
2026-10-03 08:58:59 +00:00
const SpeakingFlags = Constants2.SpeakingFlags;
const idleSince = Date.now();
let idle = false;
let afk = false;
2026-07-29 08:29:29 +00:00
let c11 = false;
let c12 = false;
let closure_13 = false;
2026-10-03 08:58:59 +00:00
if (PlatformUtils.isPlatformEmbedded) {
const importDefaultResult = DiscordNativeDefault;
2026-10-03 08:58:59 +00:00
let tmp4 = null;
let powerMonitor1;
2026-07-29 08:29:29 +00:00
if (importDefaultResult != null) {
powerMonitor1 = importDefaultResult.powerMonitor;
2026-07-20 16:05:17 +00:00
}
if (null != powerMonitor1) {
2026-07-20 16:05:17 +00:00
function checkNativeIdle() {
2026-10-03 08:58:59 +00:00
let tmp2 = dependencyMap;
const tmp3 = DiscordNativeDefault;
2026-07-20 16:05:17 +00:00
let getSystemIdleTimeMs;
2026-07-29 08:29:29 +00:00
if (tmp3 != null) {
const powerMonitor = tmp3.powerMonitor;
if (powerMonitor != null) {
2026-07-20 16:05:17 +00:00
getSystemIdleTimeMs = powerMonitor.getSystemIdleTimeMs;
}
}
if (null != getSystemIdleTimeMs) {
2026-10-10 08:08:14 +00:00
const powerMonitor2 = tmp(4731).powerMonitor;
2026-07-20 16:05:17 +00:00
const systemIdleTimeMs = powerMonitor2.getSystemIdleTimeMs();
if (systemIdleTimeMs instanceof Promise) {
systemIdleTimeMs.then(function handleIdleTime(result) {
const diff = Date.now() - result;
2026-10-03 08:58:59 +00:00
const tmp2 = null == c3 || diff > c3;
2026-07-29 08:29:29 +00:00
if (tmp2) {
const _Math = Math;
closure_8 = Math.max(diff, closure_8);
c3 = null;
}
checkIdleAFK();
const timerId = setTimeout(checkNativeIdle, 10 * DurationsDefault.Millis.SECOND);
2026-07-29 08:29:29 +00:00
});
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
const _Date = Date;
let diff = Date.now() - systemIdleTimeMs;
2026-10-03 08:58:59 +00:00
const tmp7 = null == c3 || diff > c3;
2026-07-29 08:29:29 +00:00
if (tmp7) {
let _Math = Math;
closure_8 = Math.max(diff, closure_8);
c3 = null;
}
checkIdleAFK();
const _setTimeout = setTimeout;
2026-10-03 08:58:59 +00:00
let timerId = setTimeout(checkNativeIdle, 10 * tmp(1102).Millis.SECOND);
2026-07-20 16:05:17 +00:00
}
}
}
checkNativeIdle();
let powerMonitor = DiscordNativeDefault.powerMonitor;
2026-07-20 16:05:17 +00:00
powerMonitor.on("resume", () => {
2026-08-24 06:08:38 +00:00
c11 = false;
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-07-20 16:05:17 +00:00
});
let powerMonitor2 = DiscordNativeDefault.powerMonitor;
2026-07-20 16:05:17 +00:00
powerMonitor2.on("suspend", () => {
2026-08-24 06:08:38 +00:00
c11 = true;
c3 = Date.now();
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-10-03 08:58:59 +00:00
const obj = SelectedChannelActionCreatorsDefault;
obj.disconnect();
2026-07-20 16:05:17 +00:00
});
const powerMonitor3 = DiscordNativeDefault.powerMonitor;
2026-10-03 08:58:59 +00:00
class IdleStore extends Store {
initialize() {
this.waitFor(AuthenticationStore);
}
isIdle() {
return idle;
}
isAFK() {
return afk;
}
getIdleSince() {
let tmp = null;
if (idle) {
tmp = idleSince;
}
return tmp;
}
getSystemSuspended() {
return c11;
}
getSystemLocked() {
return c12;
}
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
powerMonitor3.on("lock-screen", () => {
2026-08-24 06:08:38 +00:00
c12 = true;
c3 = Date.now();
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-07-20 16:05:17 +00:00
});
2026-07-29 08:29:29 +00:00
obj.on("unlock-screen", () => {
2026-08-24 06:08:38 +00:00
c12 = false;
2026-07-29 08:29:29 +00:00
checkIdleAFK();
2026-07-20 16:05:17 +00:00
});
}
2026-07-29 08:29:29 +00:00
function handleGenericAction(timestamp) {
timestamp = timestamp.timestamp;
let tmp = "OVERLAY_SET_NOT_IDLE" === timestamp.type;
2026-10-03 08:58:59 +00:00
const bypassIdleUpdate = timestamp.bypassIdleUpdate;
2026-07-29 08:29:29 +00:00
if (tmp) {
tmp = null != timestamp;
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
const tmp3 = tmp && timestamp <= closure_8 || bypassIdleUpdate;
if (!tmp3) {
2026-08-24 06:08:38 +00:00
c3 = null;
2026-07-29 08:29:29 +00:00
if (!tmp) {
const _Date = Date;
timestamp = Date.now();
2026-07-20 16:05:17 +00:00
}
closure_8 = timestamp;
2026-07-29 08:29:29 +00:00
checkIdleAFK();
}
return false;
}
2026-08-24 06:08:38 +00:00
debounceDefault(() => {
2026-07-29 08:29:29 +00:00
const obj = {};
let timestamp = obj.timestamp;
let tmp = "OVERLAY_SET_NOT_IDLE" === obj.type;
2026-10-03 08:58:59 +00:00
const bypassIdleUpdate = obj.bypassIdleUpdate;
2026-07-29 08:29:29 +00:00
if (tmp) {
tmp = null != timestamp;
}
2026-10-03 08:58:59 +00:00
const tmp3 = tmp && timestamp <= closure_8 || bypassIdleUpdate;
if (!tmp3) {
2026-08-24 06:08:38 +00:00
c3 = null;
2026-07-29 08:29:29 +00:00
if (!tmp) {
const _Date = Date;
timestamp = Date.now();
2026-07-20 16:05:17 +00:00
}
closure_8 = timestamp;
2026-07-29 08:29:29 +00:00
checkIdleAFK();
}
}, 500);
2026-10-03 08:58:59 +00:00
const Store = get_initializedDefault.Store;
class IdleStore extends Store {
initialize() {
this.waitFor(AuthenticationStore);
}
isIdle() {
return idle;
}
isAFK() {
return afk;
}
getIdleSince() {
let tmp = null;
if (idle) {
tmp = idleSince;
}
return tmp;
}
getSystemSuspended() {
return c11;
}
getSystemLocked() {
return c12;
}
2026-07-29 08:29:29 +00:00
}
const prototype = IdleStore.prototype;
IdleStore.displayName = "IdleStore";
let obj2 = {
IDLE: function handleIdle(idle) {
idle = idle.idle;
},
AFK: function handleAFK(afk) {
afk = afk.afk;
},
SPEAKING: function handleSpeaking(speakingFlags) {
2026-10-03 08:58:59 +00:00
const tmp2 = speakingFlags.speakingFlags !== SpeakingFlags.NONE && tmp === AuthenticationStore.getId();
if (tmp2) {
const obj = {};
let timestamp = obj.timestamp;
let tmp4 = "OVERLAY_SET_NOT_IDLE" === obj.type;
2026-10-03 08:58:59 +00:00
const bypassIdleUpdate = obj.bypassIdleUpdate;
if (tmp4) {
tmp4 = null != timestamp;
}
2026-10-03 08:58:59 +00:00
const tmp6 = tmp4 && timestamp <= closure_8 || bypassIdleUpdate;
if (!tmp6) {
c3 = null;
if (!tmp4) {
const _Date = Date;
timestamp = Date.now();
}
closure_8 = timestamp;
checkIdleAFK();
}
}
return false;
},
APP_STATE_UPDATE: function handleAppStateUpdate(state) {
2026-10-03 08:58:59 +00:00
closure_13 = state.state === metroRequire.BACKGROUND;
c3 = null;
2026-10-03 08:58:59 +00:00
let closure_8 = Date.now();
2026-07-20 16:05:17 +00:00
checkIdleAFK();
return false;
},
OVERLAY_SET_NOT_IDLE: handleGenericAction,
CHANNEL_SELECT: handleGenericAction,
VOICE_CHANNEL_SELECT: handleGenericAction,
WINDOW_FOCUS: handleGenericAction,
OVERLAY_INITIALIZE: handleGenericAction,
OVERLAY_SET_INPUT_LOCKED: handleGenericAction
2026-07-20 16:05:17 +00:00
};
const idleStore = new IdleStore(DispatcherDefault, obj2);
2026-10-03 08:58:59 +00:00
const _module1 = _mod2;
const result = _module1.fileFinishedImporting("stores/IdleStore.tsx");
2026-07-29 08:29:29 +00:00
exports.default = idleStore;
2026-07-20 16:05:17 +00:00
}
let timerId = setInterval(checkIdleAFK, 30 * DurationsDefault.Millis.SECOND);