52 lines
2.0 KiB
TypeScript
52 lines
2.0 KiB
TypeScript
// Metro module 16255 (f16256).
|
|
import MediaEngineStore from "../../../stores/MediaEngineStore";
|
|
import AppStateStore from "../../../stores/native/AppStateStore";
|
|
import { AppStates } from "../../../Constants";
|
|
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
|
|
import Module16256 from "../../../_bundle/Module16256";
|
|
import AudioActionCreators from "../../../actions/AudioActionCreators";
|
|
class NativeOnDemandResourceManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
POST_CONNECTION_OPEN: () => this.handlePostConnectionOpen(),
|
|
APP_STATE_UPDATE: () => this.handleAppStateUpdate()
|
|
};
|
|
isPastConnectionOpen = false;
|
|
hasFetchedKrisp = false;
|
|
handlePostConnectionOpen = () => {
|
|
this.isPastConnectionOpen = true;
|
|
this.maybeLoadKrisp();
|
|
};
|
|
handleAppStateUpdate = () => {
|
|
this.maybeLoadKrisp();
|
|
};
|
|
maybeLoadKrisp = () => {
|
|
if (this.isPastConnectionOpen && AppStateStore.getState() === AppStates.ACTIVE) {
|
|
if (!(Module16256 == null ? void 0 : Module16256.hasOnDemandResource("krisp")) && !this.hasFetchedKrisp) {
|
|
this.hasFetchedKrisp = true;
|
|
const mode = MediaEngineStore.getMode();
|
|
const autoThreshold = MediaEngineStore.getModeOptions().autoThreshold;
|
|
AudioActionCreators.setMode(mode, {
|
|
autoThreshold: false
|
|
});
|
|
if (Module16256 != null) {
|
|
const r37 = Module16256.fetchOnDemandResource("krisp");
|
|
if (r37 != null) {
|
|
r37.then((result) => {
|
|
const r9 = Module16256 == null ? void 0 : Module16256.isOnDemandResourcingAvailable();
|
|
if (!result && r9) {
|
|
this.hasFetchedKrisp = false;
|
|
} else {
|
|
AudioActionCreators.setMode(mode, {
|
|
autoThreshold
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
}
|
|
const nativeOnDemandResourceManager = new NativeOnDemandResourceManager();
|
|
export default nativeOnDemandResourceManager;
|