33 lines
1.4 KiB
TypeScript
33 lines
1.4 KiB
TypeScript
// Metro module 10674 (f10675).
|
|
import UserStore from "../../../../stores/UserStore";
|
|
import VoiceStateStore from "../../../../stores/VoiceStateStore";
|
|
import LifecycleManager from "../../../../lib/LifecycleManager";
|
|
import Dispatcher from "../../../../Dispatcher";
|
|
import { dismissVoiceChannelScreens } from "../../../../utils/native/PrivateChannelCallUtils";
|
|
class ChannelCallModalManager extends LifecycleManager {
|
|
inVoiceChannel = false;
|
|
handleCloseModal = () => {
|
|
const channel = this.channel;
|
|
const currentUser = UserStore.getCurrentUser();
|
|
const inVoiceChannel = channel != null && currentUser != null && VoiceStateStore.isInChannel(channel.id, currentUser.id);
|
|
if (channel != null && this.inVoiceChannel && this.inVoiceChannel !== inVoiceChannel) {
|
|
Dispatcher.wait(() => {
|
|
dismissVoiceChannelScreens(channel);
|
|
});
|
|
this.terminate();
|
|
}
|
|
this.inVoiceChannel = inVoiceChannel;
|
|
};
|
|
_initialize(a0) {
|
|
this.channel = a0;
|
|
const currentUser = UserStore.getCurrentUser();
|
|
this.inVoiceChannel = a0 != null && currentUser != null && VoiceStateStore.isInChannel(a0.id, currentUser.id);
|
|
VoiceStateStore.addChangeListener(this.handleCloseModal);
|
|
}
|
|
_terminate() {
|
|
VoiceStateStore.removeChangeListener(this.handleCloseModal);
|
|
}
|
|
}
|
|
const channelCallModalManager = new ChannelCallModalManager();
|
|
export default channelCallModalManager;
|