Files
discord-decomp/stores/CertifiedDeviceStore.tsx
T
2026-11-01 12:12:55 +02:00

106 lines
2.9 KiB
TypeScript

// Metro module 4260 (f4261).
import { DeviceTypes } from "../_bundle/Module4250";
import { Storage } from "../_bundle/Module595";
import Module589 from "../_bundle/Module589";
import Module12 from "../_bundle/Module12";
import Dispatcher from "../Dispatcher";
function $mk74021($env) {
return (a0) => delete c2498_6[a0.id];
}
function $mk74022($env) {
return (a0) => {
c2498_6[a0.id] = a0;
return a0;
};
}
let c2498_8;
let env2498 = {};
const c2498_4 = "CertifiedDeviceStore";
const c2498_5 = {};
const c2498_6 = {};
env2498[7] = 0;
class CertifiedDeviceStore extends Module589.Store {
static displayName = "CertifiedDeviceStore";
constructor() {
super(...arguments);
}
initialize() {
const r10 = Storage.get(c2498_4);
if (r10 != null) {
Module12.forEach(r10, (a0, a1) => {
const r2 = env2498;
a0.forEach((item) => {
if (item.type === "audioinput" && item.hardwareMute) {
item.hardwareMute = false;
}
});
const r8 = c2498_5[a1];
if (r8 != null) {
r8.forEach($mk74021(r2));
}
c2498_5[a1] = a0;
a0.forEach($mk74022(r2));
});
}
}
isCertified(a0) {
return c2498_6[a0] != null;
}
getCertifiedDevice(a0) {
return c2498_6[a0];
}
getCertifiedDeviceName(a0, r1) {
const certifiedDevice = this.getCertifiedDevice(a0);
if (certifiedDevice != null) {
r1 = `${certifiedDevice.vendor.name} ${certifiedDevice.model.name}`;
}
return r1;
}
getCertifiedDeviceByType(c14035_0) {
return Module12.find(c2498_6, (a0) => a0.type === c14035_0);
}
isHardwareMute(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.hardwareMute : false;
}
hasEchoCancellation(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.echoCancellation : false;
}
hasNoiseSuppression(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.noiseSuppression : false;
}
hasAutomaticGainControl(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.automaticGainControl : false;
}
getVendor(a0) {
const r4 = c2498_6[a0];
return r4 != null ? r4.vendor : null;
}
getModel(a0) {
const r4 = c2498_6[a0];
return r4 != null ? r4.model : null;
}
getRevision() {
return env2498[7];
}
}
c2498_8 = CertifiedDeviceStore;
const r56 = new CertifiedDeviceStore(Dispatcher, {
CERTIFIED_DEVICES_SET: function handleSetCertifiedDevices(a0) {
const r3 = env2498;
const { applicationId, devices } = a0;
const r9 = c2498_5[applicationId];
if (r9 != null) {
r9.forEach($mk74021(r3));
}
c2498_5[applicationId] = devices;
devices.forEach($mk74022(r3));
Storage.set(c2498_4, c2498_5);
env2498[7] = env2498[7] + 1;
}
});
export default r56;