61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
// Metro module 16335 (f16336).
|
|
import AuthenticationStore from "./AuthenticationStore";
|
|
import BitRateStore from "./BitRateStore";
|
|
import ChannelStore from "./ChannelStore";
|
|
import SelectedChannelStore from "./SelectedChannelStore";
|
|
import VideoQualityModeStore from "./VideoQualityModeStore";
|
|
import { VideoQualityMode } from "../Constants";
|
|
import Dispatcher from "../Dispatcher";
|
|
import AutomaticLifecycleManager from "../lib/AutomaticLifecycleManager";
|
|
let handleChannelUpdates, handleVoiceStateUpdates;
|
|
const updateVoiceSettings = function updateVoiceSettings() {
|
|
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
|
|
if (voiceChannelId != null) {
|
|
const channel = ChannelStore.getChannel(voiceChannelId);
|
|
if (channel != null && BitRateStore.bitrate !== channel.bitrate) {
|
|
Dispatcher.dispatch({
|
|
type: "SET_CHANNEL_BITRATE",
|
|
bitrate: channel.bitrate
|
|
});
|
|
}
|
|
}
|
|
const voiceChannelId2 = SelectedChannelStore.getVoiceChannelId();
|
|
if (voiceChannelId2 != null) {
|
|
const channel2 = ChannelStore.getChannel(voiceChannelId2);
|
|
if (channel2 != null) {
|
|
let videoQualityMode = channel2.videoQualityMode;
|
|
if (videoQualityMode == null) {
|
|
videoQualityMode = VideoQualityMode.AUTO;
|
|
}
|
|
if (VideoQualityModeStore.mode !== videoQualityMode) {
|
|
Dispatcher.dispatch({
|
|
type: "SET_CHANNEL_VIDEO_QUALITY_MODE",
|
|
mode: videoQualityMode
|
|
});
|
|
}
|
|
}
|
|
}
|
|
};
|
|
handleChannelUpdates = function handleChannelUpdates(a0) {
|
|
for (const channel of a0.channels) {
|
|
if (SelectedChannelStore.getVoiceChannelId() === channel.id) {
|
|
updateVoiceSettings();
|
|
}
|
|
}
|
|
};
|
|
handleVoiceStateUpdates = function handleVoiceStateUpdates(a0) {
|
|
a0.voiceStates.forEach((voiceState) => {
|
|
if (AuthenticationStore.getSessionId() === voiceState.sessionId) {
|
|
updateVoiceSettings();
|
|
}
|
|
});
|
|
};
|
|
class VoiceChannelSettingsManager extends AutomaticLifecycleManager {
|
|
actions = {
|
|
CHANNEL_UPDATES: handleChannelUpdates,
|
|
VOICE_STATE_UPDATES: handleVoiceStateUpdates
|
|
};
|
|
}
|
|
const voiceChannelSettingsManager = new VoiceChannelSettingsManager();
|
|
export default voiceChannelSettingsManager;
|