Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/05xxx/module_5014.js (118.4 MB)
288 lines
8.4 KiB
TypeScript
288 lines
8.4 KiB
TypeScript
// Module ID: 5715
|
|
// Function ID: 5716
|
|
// Name: IdleStore
|
|
// Dependencies: [502, 1074, 4854, 1364, 2020, 1091, 573, 4445, 5716, 551, 504, 2]
|
|
|
|
// Module 5715 (IdleStore)
|
|
import initializeDefault from "initialize" /* 504 */;
|
|
import debounceDefault from "debounce" /* 551 */;
|
|
import DispatcherDefault from "Dispatcher" /* 573 */;
|
|
import DurationsDefault from "Durations" /* 1091 */;
|
|
import PlatformUtils from "PlatformUtils" /* 1364 */;
|
|
import UserSettings from "UserSettings" /* 2020 */;
|
|
import DiscordNativeDefault from "DiscordNative" /* 4445 */;
|
|
import SelectedChannelActionCreatorsDefault from "SelectedChannelActionCreators" /* 5716 */;
|
|
import AuthenticationStore from "AuthenticationStore" /* 502 */;
|
|
|
|
require = fn;
|
|
function checkIdleAFK() {
|
|
if (Date.now() - idleSince <= hasOwnProperty) {
|
|
let tmp2 = c11;
|
|
if (!c11) {
|
|
tmp2 = c12;
|
|
}
|
|
if (!tmp2) {
|
|
tmp2 = PlatformUtils.isAndroid() && closure_13;
|
|
const tmp5 = PlatformUtils.isAndroid() && closure_13;
|
|
}
|
|
if (!tmp2) {
|
|
if (idle) {
|
|
DispatcherDefault.dispatch({ type: "IDLE", idle: false });
|
|
}
|
|
}
|
|
const AfkTimeout = UserSettings.AfkTimeout;
|
|
const setting = AfkTimeout.getSetting();
|
|
if (0 !== setting) {
|
|
if (null == c3) {
|
|
const _Date = Date;
|
|
const _Math = Math;
|
|
const diff = Date.now() - idleSince;
|
|
if (diff <= Math.min(setting * DurationsDefault.Millis.SECOND, tmp)) {
|
|
let tmp17 = c11;
|
|
if (!c11) {
|
|
tmp17 = c12;
|
|
}
|
|
if (!tmp17) {
|
|
const tmp14Result = tmp14(1364);
|
|
tmp17 = tmp14(1364).isAndroid() && closure_13;
|
|
const tmp18 = tmp14(1364).isAndroid() && closure_13;
|
|
}
|
|
if (!tmp17) {
|
|
if (afk) {
|
|
tmp28(573).dispatch({ type: "AFK", afk: false });
|
|
const tmp28Result = tmp28(573);
|
|
}
|
|
}
|
|
}
|
|
tmp28 = importDefault;
|
|
}
|
|
}
|
|
if (!afk) {
|
|
DispatcherDefault.dispatch({ type: "AFK", afk: true });
|
|
}
|
|
tmp14 = require;
|
|
}
|
|
if (!idle) {
|
|
const obj4 = { type: "IDLE", idle: true, idleSince };
|
|
DispatcherDefault.dispatch(obj4);
|
|
}
|
|
}
|
|
const Constants = fn(1074);
|
|
({ IDLE_DURATION: hasOwnProperty, AppStates: metroRequire } = Constants);
|
|
const SpeakingFlags = fn(4854).SpeakingFlags;
|
|
const idleSince = Date.now();
|
|
let idle = false;
|
|
let afk = false;
|
|
let c11 = false;
|
|
let c12 = false;
|
|
let closure_13 = false;
|
|
if (fn(1364).isPlatformEmbedded) {
|
|
const importDefaultResult = DiscordNativeDefault;
|
|
let powerMonitor1;
|
|
if (importDefaultResult != null) {
|
|
powerMonitor1 = importDefaultResult.powerMonitor;
|
|
}
|
|
if (null != powerMonitor1) {
|
|
function checkNativeIdle() {
|
|
const tmp3 = DiscordNativeDefault;
|
|
let getSystemIdleTimeMs;
|
|
if (tmp3 != null) {
|
|
const powerMonitor = tmp3.powerMonitor;
|
|
if (powerMonitor != null) {
|
|
getSystemIdleTimeMs = powerMonitor.getSystemIdleTimeMs;
|
|
}
|
|
}
|
|
if (null != getSystemIdleTimeMs) {
|
|
const powerMonitor2 = tmp(4445).powerMonitor;
|
|
const systemIdleTimeMs = powerMonitor2.getSystemIdleTimeMs();
|
|
if (systemIdleTimeMs instanceof Promise) {
|
|
systemIdleTimeMs.then(function handleIdleTime(result) {
|
|
const diff = Date.now() - result;
|
|
let tmp2 = null == c3;
|
|
if (!tmp2) {
|
|
tmp2 = diff > c3;
|
|
}
|
|
if (tmp2) {
|
|
const _Math = Math;
|
|
closure_8 = Math.max(diff, closure_8);
|
|
c3 = null;
|
|
}
|
|
checkIdleAFK();
|
|
const timerId = setTimeout(checkNativeIdle, 10 * DurationsDefault.Millis.SECOND);
|
|
});
|
|
} else {
|
|
const _Date = Date;
|
|
let diff = Date.now() - systemIdleTimeMs;
|
|
let tmp7 = null == c3;
|
|
if (!tmp7) {
|
|
tmp7 = diff > c3;
|
|
}
|
|
if (tmp7) {
|
|
let _Math = Math;
|
|
closure_8 = Math.max(diff, closure_8);
|
|
c3 = null;
|
|
}
|
|
checkIdleAFK();
|
|
const _setTimeout = setTimeout;
|
|
let timerId = setTimeout(checkNativeIdle, 10 * tmp(1091).Millis.SECOND);
|
|
}
|
|
}
|
|
}
|
|
checkNativeIdle();
|
|
let powerMonitor = DiscordNativeDefault.powerMonitor;
|
|
powerMonitor.on("resume", () => {
|
|
c11 = false;
|
|
checkIdleAFK();
|
|
});
|
|
let powerMonitor2 = DiscordNativeDefault.powerMonitor;
|
|
powerMonitor2.on("suspend", () => {
|
|
c11 = true;
|
|
c3 = Date.now();
|
|
checkIdleAFK();
|
|
SelectedChannelActionCreatorsDefault.disconnect();
|
|
});
|
|
const powerMonitor3 = DiscordNativeDefault.powerMonitor;
|
|
class IdleStore extends r10079 {
|
|
}
|
|
powerMonitor3.on("lock-screen", () => {
|
|
c12 = true;
|
|
c3 = Date.now();
|
|
checkIdleAFK();
|
|
});
|
|
obj.on("unlock-screen", () => {
|
|
c12 = false;
|
|
checkIdleAFK();
|
|
});
|
|
}
|
|
function handleGenericAction(timestamp) {
|
|
timestamp = timestamp.timestamp;
|
|
let tmp = "OVERLAY_SET_NOT_IDLE" === timestamp.type;
|
|
if (tmp) {
|
|
tmp = null != timestamp;
|
|
}
|
|
let bypassIdleUpdate = tmp;
|
|
if (tmp) {
|
|
bypassIdleUpdate = timestamp <= closure_8;
|
|
}
|
|
if (!bypassIdleUpdate) {
|
|
bypassIdleUpdate = timestamp.bypassIdleUpdate;
|
|
}
|
|
if (!bypassIdleUpdate) {
|
|
c3 = null;
|
|
if (!tmp) {
|
|
const _Date = Date;
|
|
timestamp = Date.now();
|
|
}
|
|
closure_8 = timestamp;
|
|
checkIdleAFK();
|
|
}
|
|
return false;
|
|
}
|
|
debounceDefault(() => {
|
|
const obj = {};
|
|
let timestamp = obj.timestamp;
|
|
let tmp = "OVERLAY_SET_NOT_IDLE" === obj.type;
|
|
if (tmp) {
|
|
tmp = null != timestamp;
|
|
}
|
|
let bypassIdleUpdate = tmp;
|
|
if (tmp) {
|
|
bypassIdleUpdate = timestamp <= closure_8;
|
|
}
|
|
if (!bypassIdleUpdate) {
|
|
bypassIdleUpdate = obj.bypassIdleUpdate;
|
|
}
|
|
if (!bypassIdleUpdate) {
|
|
c3 = null;
|
|
if (!tmp) {
|
|
const _Date = Date;
|
|
timestamp = Date.now();
|
|
}
|
|
closure_8 = timestamp;
|
|
checkIdleAFK();
|
|
}
|
|
}, 500);
|
|
const Store = initializeDefault.Store;
|
|
class IdleStore extends r10079 {
|
|
}
|
|
const prototype = IdleStore.prototype;
|
|
prototype["initialize"] = function initialize() {
|
|
this.waitFor(AuthenticationStore);
|
|
};
|
|
prototype["isIdle"] = function isIdle() {
|
|
return idle;
|
|
};
|
|
prototype["isAFK"] = function isAFK() {
|
|
return afk;
|
|
};
|
|
prototype["getIdleSince"] = function getIdleSince() {
|
|
let tmp = null;
|
|
if (idle) {
|
|
tmp = closure_8;
|
|
}
|
|
return tmp;
|
|
};
|
|
prototype["getSystemSuspended"] = function getSystemSuspended() {
|
|
return c11;
|
|
};
|
|
prototype["getSystemLocked"] = function getSystemLocked() {
|
|
return c12;
|
|
};
|
|
IdleStore.displayName = "IdleStore";
|
|
let obj2 = {
|
|
IDLE: function handleIdle(idle) {
|
|
idle = idle.idle;
|
|
},
|
|
AFK: function handleAFK(afk) {
|
|
afk = afk.afk;
|
|
},
|
|
SPEAKING: function handleSpeaking(speakingFlags) {
|
|
let tmp2 = speakingFlags.speakingFlags !== SpeakingFlags.NONE;
|
|
if (tmp2) {
|
|
tmp2 = tmp === AuthenticationStore.getId();
|
|
}
|
|
if (tmp2) {
|
|
const obj = {};
|
|
let timestamp = obj.timestamp;
|
|
let tmp4 = "OVERLAY_SET_NOT_IDLE" === obj.type;
|
|
if (tmp4) {
|
|
tmp4 = null != timestamp;
|
|
}
|
|
let bypassIdleUpdate = tmp4;
|
|
if (tmp4) {
|
|
bypassIdleUpdate = timestamp <= closure_8;
|
|
}
|
|
if (!bypassIdleUpdate) {
|
|
bypassIdleUpdate = obj.bypassIdleUpdate;
|
|
}
|
|
if (!bypassIdleUpdate) {
|
|
c3 = null;
|
|
if (!tmp4) {
|
|
const _Date = Date;
|
|
timestamp = Date.now();
|
|
}
|
|
closure_8 = timestamp;
|
|
checkIdleAFK();
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
APP_STATE_UPDATE: function handleAppStateUpdate(state) {
|
|
closure_13 = state.state === constants.BACKGROUND;
|
|
c3 = null;
|
|
closure_8 = Date.now();
|
|
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
|
|
};
|
|
const idleStore = new IdleStore(DispatcherDefault, obj2);
|
|
const result = fn(2).fileFinishedImporting("stores/IdleStore.tsx");
|
|
exports.default = idleStore;
|
|
}
|
|
let timerId = setInterval(checkIdleAFK, 30 * DurationsDefault.Millis.SECOND);
|