Files
discord-decomp/_bundle/AppStateImpl.js
T
2026-11-01 12:12:55 +02:00

65 lines
2.0 KiB
JavaScript

// Metro module 456 (f457).
import _classCallCheck from "./_classCallCheck";
import _createClass from "./_createClass";
import Module457 from "./Module457";
import NativeEventEmitter from "./NativeEventEmitter";
import _default from "./_default_459";
let env462 = {};
const AppStateImpl = function AppStateImpl() {
let c23784_0, c23784_1;
_classCallCheck(this, AppStateImpl);
this.currentState = null;
if (Module457 == null) {
this.isAvailable = false;
} else {
this.isAvailable = true;
const nativeEventEmitter = new NativeEventEmitter(null);
c23784_1 = nativeEventEmitter;
this._emitter = nativeEventEmitter;
this.currentState = Module457.getConstants().initialAppState;
c23784_0 = false;
nativeEventEmitter.addListener("appStateDidChange", (a0) => {
c23784_0 = true;
this.currentState = a0.app_state;
});
Module457.getCurrentAppState((a0) => {
if (!(c23784_0 || this.currentState === a0.app_state)) {
this.currentState = a0.app_state;
c23784_1.emit("appStateDidChange", a0);
}
}, _default);
}
};
export default new (_createClass(AppStateImpl, [{
key: "addEventListener",
value: function(a0, a1) {
let c23785_1, c23785_2;
let c23785_0 = a0;
const _emitter = this._emitter;
if (_emitter == null) {
throw new Error("Cannot use AppState when `isAvailable` is false.");
}
if (a0 === "change") {
c23785_1 = a1;
return _emitter.addListener("appStateDidChange", (a0) => {
c23785_1(a0.app_state);
});
}
if (a0 === "memoryWarning") {
return _emitter.addListener("memoryWarning", a1);
}
if (a0 !== "blur" && a0 !== "focus") {
throw new Error("Trying to subscribe to unknown event: " + a0);
}
c23785_2 = a1;
return _emitter.addListener("appStateFocusChange", (a0) => {
if (!(c23785_0 !== "blur" || a0)) {
c23785_2();
}
if (c23785_0 === "focus" && a0) {
c23785_2();
}
});
}
}]))();