74 lines
3.4 KiB
TypeScript
74 lines
3.4 KiB
TypeScript
// Metro module 16142 (f16143).
|
|
import EmbeddedActivitiesStore from "../activities/EmbeddedActivitiesStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import VoiceStateStore from "../../stores/VoiceStateStore";
|
|
import SortedVoiceStateStore from "../../stores/views/SortedVoiceStateStore";
|
|
import MessageActionCreators from "../../actions/MessageActionCreators";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import SelectedChannelActionCreators from "../../actions/SelectedChannelActionCreators";
|
|
import AutomaticLifecycleManager from "../../lib/AutomaticLifecycleManager";
|
|
import { Timeout } from "../../_bundle/Timeout";
|
|
let c11563_7;
|
|
const disconnect = function disconnect() {
|
|
const currentClientVoiceChannelId = VoiceStateStore.getCurrentClientVoiceChannelId(null);
|
|
const r4 = currentClientVoiceChannelId == null;
|
|
let r2 = false;
|
|
if (!r4) {
|
|
const channel = ChannelStore.getChannel(currentClientVoiceChannelId);
|
|
const r1 = channel == null || !channel.isPrivate();
|
|
r2 = r1 ? !r1 : !(channel.recipients.length > 1) && (!(SortedVoiceStateStore.countVoiceStatesForChannel(currentClientVoiceChannelId) > 1) && EmbeddedActivitiesStore.getSelfEmbeddedActivityForChannel(currentClientVoiceChannelId) == null);
|
|
}
|
|
if (r2) {
|
|
const currentClientVoiceChannelId2 = VoiceStateStore.getCurrentClientVoiceChannelId(null);
|
|
if (currentClientVoiceChannelId2 != null) {
|
|
MessageActionCreators.sendBotMessage(currentClientVoiceChannelId2, intl.formatToPlainString(t.XYof5G, {
|
|
number: 3
|
|
}));
|
|
SelectedChannelActionCreators.selectVoiceChannel(null);
|
|
}
|
|
}
|
|
};
|
|
c11563_7 = 180000;
|
|
class CallIdleManager extends AutomaticLifecycleManager {
|
|
idleTimeout = new Timeout();
|
|
handleConnectionClosed = () => {
|
|
this.idleTimeout.stop();
|
|
};
|
|
handleEmbeddedActivityDisconnect = () => {
|
|
const currentClientVoiceChannelId = VoiceStateStore.getCurrentClientVoiceChannelId(null);
|
|
const r3 = currentClientVoiceChannelId == null;
|
|
let r2 = false;
|
|
if (!r3) {
|
|
const channel = ChannelStore.getChannel(currentClientVoiceChannelId);
|
|
const r1 = channel == null || !channel.isPrivate();
|
|
r2 = r1 ? !r1 : !(channel.recipients.length > 1) && (!(SortedVoiceStateStore.countVoiceStatesForChannel(currentClientVoiceChannelId) > 1) && EmbeddedActivitiesStore.getSelfEmbeddedActivityForChannel(currentClientVoiceChannelId) == null);
|
|
}
|
|
if (r2) {
|
|
this.idleTimeout.start(c11563_7, disconnect, true);
|
|
}
|
|
};
|
|
handleVoiceStateUpdates = () => {
|
|
const currentClientVoiceChannelId = VoiceStateStore.getCurrentClientVoiceChannelId(null);
|
|
const r4 = currentClientVoiceChannelId == null;
|
|
let r3 = false;
|
|
if (!r4) {
|
|
const channel = ChannelStore.getChannel(currentClientVoiceChannelId);
|
|
const r1 = channel == null || !channel.isPrivate();
|
|
r3 = r1 ? !r1 : !(channel.recipients.length > 1) && (!(SortedVoiceStateStore.countVoiceStatesForChannel(currentClientVoiceChannelId) > 1) && EmbeddedActivitiesStore.getSelfEmbeddedActivityForChannel(currentClientVoiceChannelId) == null);
|
|
}
|
|
const idleTimeout = this.idleTimeout;
|
|
if (r3) {
|
|
idleTimeout.start(c11563_7, disconnect, false);
|
|
} else {
|
|
idleTimeout.stop();
|
|
}
|
|
};
|
|
actions = {
|
|
VOICE_STATE_UPDATES: this.handleVoiceStateUpdates,
|
|
CONNECTION_CLOSED: this.handleConnectionClosed,
|
|
EMBEDDED_ACTIVITY_CLOSE: this.handleEmbeddedActivityDisconnect
|
|
};
|
|
}
|
|
const callIdleManager = new CallIdleManager();
|
|
export default callIdleManager;
|