This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,703 @@
// Metro module 16324 (f16325).
import { NativeEventEmitter, DeviceEventEmitter } from "react-native";
import SoundpackStore from "../../soundpacks/SoundpackStore";
import ApplicationStreamingStore from "../../../stores/ApplicationStreamingStore";
import AuthenticationStore from "../../../stores/AuthenticationStore";
import CallStore from "../../../stores/CallStore";
import ChannelStore from "../../../stores/ChannelStore";
import MediaEngineStore from "../../../stores/MediaEngineStore";
import NotificationSettingsStore from "../../../stores/NotificationSettingsStore";
import RTCConnectionStore from "../../../stores/RTCConnectionStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import StreamerModeStore from "../../../stores/StreamerModeStore";
import UserStore from "../../../stores/UserStore";
import { ApplicationStreamStates } from "../../../Constants";
import { MediaEngineContextTypes } from "../../../_bundle/Module4250";
import Logger from "../../debug/Logger";
import Module10610 from "../../../_bundle/Module10610";
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
import Module16325 from "../../../_bundle/Module16325";
import SelectedChannelActionCreators from "../../../actions/SelectedChannelActionCreators";
import CallActionCreators from "../../../actions/CallActionCreators";
import { navigateToVoiceChannel } from "../../../utils/native/PrivateChannelCallUtils";
import AudioActionCreators from "../../../actions/AudioActionCreators";
import { getVideoPermission } from "../../video_calls/useHasVideoPermission";
import { getOSRequirement, startStream, stopScreenshare } from "../../video_calls/native/useScreenshareUtils";
import { isMetaQuest } from "../../device/MetaQuestUtils.android";
import { computeChannelName } from "../../channel/useChannelName";
import { createSoundForPack } from "../../sound_playback/SoundUtils";
function $mk117270($env) {
return (a0) => {
c11741_25.warn("Failed to end orphaned call:", a0);
};
}
let c11741_28;
let env11741 = {};
const c11741_18 = "telecom-end-call-requested";
const c11741_19 = "telecom-set-foreground-requested";
const c11741_20 = "telecom-mic-mute-requested";
const c11741_21 = "telecom-screen-share-requested";
const c11741_22 = "telecom-incoming-call-answered";
const c11741_23 = "telecom-incoming-call-rejected";
const c11741_24 = "telecom-answer-call-requested";
const logger = new Logger("TelecomManager");
const c11741_25 = logger;
logger.enableNativeLogger(true);
const c11741_26 = {
Ringing: 0,
0: "Ringing",
Connecting: 1,
1: "Connecting",
Connected: 2,
2: "Connected"
};
const c11741_27 = new NativeEventEmitter(Module10610);
class TelecomManager extends AutomaticLifecycleManager {
stores = new Map().set(RTCConnectionStore, () => this.reconcileTelecomState()).set(MediaEngineStore, () => this.handleMuteStoreChange()).set(ApplicationStreamingStore, () => this.handleScreenShareStoreChange()).set(CallStore, () => this.handleIncomingCallStoreChange());
actions = {
CALL_CREATE: (a0) => this.handleCallCreate(a0),
CALL_UPDATE: (a0) => this.handleCallUpdate(a0),
CALL_DELETE: (a0) => this.handleCallDelete(a0)
};
currentCall = null;
isInitialized = false;
lastMuteState = null;
registeredIncomingCallIds = new Set();
lastScreenShareActive = null;
pendingScreenShareOffSyncTimeout = null;
reconcilePromise = null;
needsReconcile = false;
hostDestroySubscription = null;
pendingMutePreference = null;
ringtone = null;
handleHostDestroy = () => {
if (this.isEnabled() && this.currentCall != null) {
if (this.currentCall.state === c11741_26.Ringing) {
c11741_25.info("Activity destroyed with ringing call, cancelling incoming call");
this.cancelIncomingCall(this.currentCall.channelId);
return void 0;
}
c11741_25.info("Activity destroyed with active call, disconnecting from voice channel");
SelectedChannelActionCreators.disconnect();
}
};
handleEndCallRequested = (a0) => {
c11741_25.info("Received end call request from Call Bar:", a0.callId);
if (this.currentCall != null && a0.callId === this.currentCall.channelId) {
if (this.currentCall.state === c11741_26.Ringing) {
c11741_25.info("Rejecting ringing call from Call Bar:", this.currentCall.channelId);
CallActionCreators.stopRinging(this.currentCall.channelId);
this.clearCall(this.currentCall.channelId);
} else {
SelectedChannelActionCreators.disconnect();
}
return void 0;
}
};
handleSetForegroundRequested = (a0) => {
c11741_25.info("Received set foreground request from Call Bar");
if (this.currentCall != null && a0.callId === this.currentCall.channelId) {
const channel = ChannelStore.getChannel(this.currentCall.channelId);
if (channel != null) {
navigateToVoiceChannel(channel, "Call Bar");
}
}
};
handleMicMuteRequested = (a0) => {
c11741_25.info("Received mic mute request from Call Bar:", a0.callId, "isMuted:", a0.isMuted);
if (this.currentCall != null && a0.callId === this.currentCall.channelId) {
const state = this.currentCall.state;
if (!(state !== c11741_26.Ringing && this.currentCall.state !== c11741_26.Connecting)) {
this.pendingMutePreference = a0.isMuted;
}
if (MediaEngineStore.isSelfMute() !== a0.isMuted) {
c11741_25.info("Updating Call Bar -> Discord mute state:", a0.isMuted);
AudioActionCreators.toggleSelfMute();
}
}
};
handleScreenShareRequested = (a0) => {
L16: {
c11741_25.info("Received screen share request from Call Bar:", a0.callId, "isEnabled:", a0.isEnabled);
if (this.currentCall != null && a0.callId === this.currentCall.channelId) {
const channel = ChannelStore.getChannel(this.currentCall.channelId);
if (channel != null) {
const currentUserActiveStream = ApplicationStreamingStore.getCurrentUserActiveStream();
const r1 = currentUserActiveStream != null && currentUserActiveStream.state === ApplicationStreamStates.ACTIVE;
if (a0.isEnabled && !r1) {
const videoPermission = getVideoPermission(channel);
if (getOSRequirement()) {
if (videoPermission) {
c11741_25.info("Starting screen share from Call Bar");
startStream();
break L16;
}
c11741_25.warn("Cannot start screen share from Call Bar: user lacks streaming permission in this channel");
return void 0;
}
c11741_25.warn("Cannot start screen share from Call Bar: OS version does not meet requirements");
return void 0;
}
const isEnabled2 = a0.isEnabled;
if (isEnabled2 ? !isEnabled2 : r1) {
c11741_25.info("Stopping screen share from Call Bar");
stopScreenshare();
}
}
}
}
};
handleAnswerCallRequested = (a0) => {
c11741_25.info("Received answer call request from Call Bar:", a0.callId);
if (this.currentCall != null && a0.callId === this.currentCall.channelId) {
const state = this.currentCall.state;
if (state === c11741_26.Ringing) {
this.stopRingtone();
this.currentCall.state = c11741_26.Connecting;
c11741_25.info("Answering incoming call, joining voice channel:", this.currentCall.channelId);
SelectedChannelActionCreators.selectVoiceChannel(this.currentCall.channelId);
} else {
c11741_25.warn("Answer requested but call is not ringing:", this.currentCall.state);
}
}
};
handleCallCreate = (a0) => {
if (this.isEnabled() && isMetaQuest()) {
this.processIncomingRing(a0.channelId, a0.ongoingRings);
}
};
handleCallUpdate = (a0) => {
if (this.isEnabled() && isMetaQuest()) {
this.processIncomingRing(a0.channelId, a0.ongoingRings);
}
};
handleCallDelete = (a0) => {
if (this.isEnabled() && isMetaQuest() && this.currentCall?.channelId === a0.channelId && this.isPendingIncomingCall(this.currentCall)) {
c11741_25.info("Pending incoming call deleted, cancelling incoming call:", a0.channelId);
this.cancelIncomingCall(a0.channelId);
}
};
handleIncomingCallAnswered = (a0) => {
c11741_25.info("Received incoming call answered from telecom:", a0.callId);
this.registeredIncomingCallIds.delete(a0.callId);
Module16325.endCall(a0.callId).catch((error) => {
c11741_25.warn("Failed to end answered telecom call:", error);
});
SelectedChannelActionCreators.selectVoiceChannel(a0.callId);
};
handleIncomingCallRejected = (a0) => {
c11741_25.info("Received incoming call rejected from telecom:", a0.callId);
this.registeredIncomingCallIds.delete(a0.callId);
CallActionCreators.stopRinging(a0.callId).catch((error) => {
c11741_25.warn("Failed to stop ringing after telecom reject:", error);
});
};
_initialize() {
if (!this.isInitialized) {
c11741_25.info("Initializing CallKitManager using Telecom framework");
const hostDestroySubscription = this.hostDestroySubscription;
if (hostDestroySubscription != null) {
hostDestroySubscription.remove();
}
this.hostDestroySubscription = c11741_27.addListener("onHostDestroy", this.handleHostDestroy);
DeviceEventEmitter.addListener(c11741_18, this.handleEndCallRequested);
DeviceEventEmitter.addListener(c11741_19, this.handleSetForegroundRequested);
DeviceEventEmitter.addListener(c11741_20, this.handleMicMuteRequested);
DeviceEventEmitter.addListener(c11741_21, this.handleScreenShareRequested);
DeviceEventEmitter.addListener(c11741_22, this.handleIncomingCallAnswered);
DeviceEventEmitter.addListener(c11741_23, this.handleIncomingCallRejected);
DeviceEventEmitter.addListener(c11741_24, this.handleAnswerCallRequested);
this.isInitialized = true;
}
}
_terminate() {
if (this.isInitialized) {
const hostDestroySubscription = this.hostDestroySubscription;
if (hostDestroySubscription != null) {
hostDestroySubscription.remove();
}
this.hostDestroySubscription = null;
DeviceEventEmitter.removeAllListeners(c11741_18);
DeviceEventEmitter.removeAllListeners(c11741_19);
DeviceEventEmitter.removeAllListeners(c11741_20);
DeviceEventEmitter.removeAllListeners(c11741_21);
DeviceEventEmitter.removeAllListeners(c11741_22);
DeviceEventEmitter.removeAllListeners(c11741_23);
DeviceEventEmitter.removeAllListeners(c11741_24);
for (const registeredIncomingCallId of this.registeredIncomingCallIds) {
Module16325.endCall(registeredIncomingCallId).catch((error) => {
c11741_25.warn("Failed to end telecom incoming call on terminate:", error);
});
}
this.registeredIncomingCallIds.clear();
this.clearPendingScreenShareOffSync();
this.stopRingtone();
this.reportCallEnded();
this.reconcilePromise = null;
this.needsReconcile = false;
this.isInitialized = false;
}
}
isEnabled() {
return this.isInitialized;
}
processIncomingRing(a0, a1) {
const id = AuthenticationStore.getId();
if (id in a1 && a1[id] != null) {
if (this.currentCall?.channelId === a0 && this.currentCall.state !== c11741_26.Ringing) {
return void 0;
}
if (RTCConnectionStore.getChannelId() != null) {
return void 0;
}
if (this.currentCall?.channelId === a0 && this.currentCall.state === c11741_26.Ringing) {
return void 0;
}
this.reportIncomingCall(a0);
} else if (this.currentCall?.channelId === a0 && this.currentCall.state === c11741_26.Ringing) {
c11741_25.info("Call no longer ringing, cancelling incoming call:", a0);
this.cancelIncomingCall(a0);
}
}
reportIncomingCall(a0) {
const channel = ChannelStore.getChannel(a0);
if (channel != null) {
if (this.currentCall != null && this.currentCall.channelId !== a0 && this.isPendingIncomingCall(this.currentCall)) {
this.cancelIncomingCall(this.currentCall.channelId);
}
const channelName = computeChannelName(channel, UserStore, RelationshipStore);
let guildId2 = channel.getGuildId();
if (guildId2 == null) {
guildId2 = null;
}
this.currentCall = {
channelId: a0,
guildId: guildId2,
channelName,
state: c11741_26.Ringing
};
c11741_25.info("Reporting incoming call to Telecom:", a0, "callerName:", channelName);
this.startRingtone();
Module16325.reportIncomingCall(a0, channelName, guildId2 != null ? {
guildId: guildId2
} : null).then((result) => {
if (!result) {
c11741_25.warn("Failed to report incoming call: resolved false");
this.clearCall(a0);
}
}).catch((error) => {
c11741_25.warn("Failed to report incoming call:", error);
this.clearCall(a0);
});
} else {
c11741_25.warn("Cannot report incoming call: channel not found:", a0);
}
}
cancelIncomingCall(a0) {
c11741_25.info("Cancelling incoming call:", a0);
return Module16325.cancelIncomingCall(a0).then(() => {
this.clearCall(a0);
return true;
}).catch((error) => {
c11741_25.warn("Failed to cancel incoming call:", error);
this.clearCall(a0);
return false;
});
}
isPendingIncomingCall(a0) {
const state = a0.state;
return state === c11741_26.Ringing || a0.state === c11741_26.Connecting;
}
reconcileTelecomState() {
if (this.isEnabled() && isMetaQuest()) {
if (this.reconcilePromise == null) {
this.reconcilePromise = this.doReconcile().finally(() => {
this.reconcilePromise = null;
if (this.needsReconcile) {
this.needsReconcile = false;
this.reconcileTelecomState();
}
});
} else {
this.needsReconcile = true;
}
}
}
async doReconcile() {
let r216;
const _this = this;
let guildId, c28338_1, c28338_2;
L64: {
L63: {
L62: {
L77: {
L24: {
L48: {
L35: {
let env31031;
c28338_2 = void 0;
const r14 = env31031 = {
$parent: env11741
};
c28338_1 = r14;
env31031[0] = void 0;
env31031[1] = void 0;
env31031[2] = void 0;
const channelId2 = RTCConnectionStore.getChannelId();
const isConnected = RTCConnectionStore.isConnected();
const r58 = isConnected ? channelId2 ?? null : null;
env31031[0] = r58;
c11741_25.info("Reconcile: rtc=", channelId2, "connected=", isConnected, "target=", r58, "current=", _this.currentCall?.channelId, "state=", _this.currentCall?.state);
if (r58 != null) {
if (_this.currentCall?.channelId === r58 && _this.currentCall.state === c11741_26.Connected) {
break L24;
}
const channelId3 = _this.currentCall?.channelId;
L31: {
if (channelId3 === r58) {
if (_this.currentCall.state !== c11741_26.Ringing && _this.currentCall.state !== c11741_26.Connecting) {
break L31;
}
c11741_25.info("Incoming call answered, transitioning to active:", r58);
_this.stopRingtone();
_this.currentCall.state = c11741_26.Connected;
_this.setIncomingCallActive(r58);
break L35;
}
}
if (_this.currentCall != null && _this.currentCall.channelId !== r58) {
if (_this.isPendingIncomingCall(_this.currentCall)) {
await _this.cancelIncomingCall(_this.currentCall.channelId);
} else {
await _this.endCall(_this.currentCall);
}
if (_this.currentCall?.channelId !== env31031[0]) {
env31031[1] = ChannelStore.getChannel(env31031[0]);
if (env31031[1] == null) {
break L77;
}
const guildId3 = RTCConnectionStore.getGuildId();
guildId = guildId3;
if (guildId3 == null) {
guildId = null;
}
_this.currentCall = {
channelId: env31031[0],
guildId,
channelName: computeChannelName(env31031[1], UserStore, RelationshipStore),
state: c11741_26.Connecting
};
}
if (_this.currentCall.state !== c11741_26.Connecting) {
break L64;
}
env31031[2] = _this.currentCall.channelId;
r216 = await _this.startCall({
channelId: _this.currentCall.channelId,
guildId: _this.currentCall.guildId
});
} else {
if (_this.currentCall?.channelId !== env31031[0]) {
env31031[1] = ChannelStore.getChannel(env31031[0]);
if (env31031[1] == null) {
break L48;
}
const guildId2 = RTCConnectionStore.getGuildId();
guildId = guildId2;
if (guildId2 == null) {
guildId = null;
}
_this.currentCall = {
channelId: env31031[0],
guildId,
channelName: computeChannelName(env31031[1], UserStore, RelationshipStore),
state: c11741_26.Connecting
};
}
if (_this.currentCall.state !== c11741_26.Connecting) {
break L24;
}
env31031[2] = _this.currentCall.channelId;
r216 = await _this.startCall({
channelId: _this.currentCall.channelId,
guildId: _this.currentCall.guildId
});
}
if (!r216) {
break L64;
}
if (_this.currentCall?.channelId !== env31031[2]) {
c11741_25.info("Call state changed during startCall, ending orphaned native call:", env31031[2]);
Module16325.endCall(env31031[2]).catch($mk117270(env11741));
break L63;
}
if (RTCConnectionStore.isConnected()) {
if (RTCConnectionStore.getChannelId() === env31031[2]) {
_this.currentCall.state = c11741_26.Connected;
_this.setCallActive(env31031[2]);
break L64;
}
}
c11741_25.info("RTCConnectionStore indicates disconnect after startCall, ending call:", env31031[2]);
await _this.reportCallEnded();
break L62;
}
if (!(_this.currentCall != null && _this.currentCall.state !== c11741_26.Ringing && _this.currentCall.state !== c11741_26.Connecting)) {
break L24;
}
await _this.reportCallEnded();
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
return void 0;
}
}
handleIncomingCallStoreChange() {
let r22;
let _this2;
L18: {
_this2 = this;
if (!isMetaQuest() && this.isEnabled()) {
const id = AuthenticationStore.getId();
const set = new Set();
let r40 = CallStore.getCalls()[Symbol.iterator]();
const next = r40.next;
while (true) {
const r43 = r40 === void 0 ? void 0 : (r22 = next.call(r40)).done ? r40 = void 0 : r22.value;
if (r40 === void 0) {
for (const registeredIncomingCallId of this.registeredIncomingCallIds) {
const r60 = registeredIncomingCallId;
if (!set.has(registeredIncomingCallId)) {
const registeredIncomingCallIds = this.registeredIncomingCallIds;
registeredIncomingCallIds.delete(r60);
Module16325.endCall(r60).catch((error) => {
c11741_25.warn("Failed to end telecom call:", error);
});
}
}
const _loop = function _loop(a0) {
if (!_this2.registeredIncomingCallIds.has(a0)) {
_this2.registeredIncomingCallIds.add(a0);
Module16325.registerIncomingCall(a0).then((result) => {
if (!result) {
c11741_25.warn("Failed to register incoming call with telecom: resolved false");
_this2.registeredIncomingCallIds.delete(a0);
}
}).catch((error) => {
c11741_25.warn("Failed to register incoming call with telecom:", error);
_this2.registeredIncomingCallIds.delete(a0);
});
}
};
for (const item of set) {
_loop(item);
}
break L18;
} else {
try {
if (r43.ringing.includes(id)) {
set.add(r43.channelId);
}
} catch (r52) {
if (r40 !== void 0 && typeof r40.return === "function") {
try {
r40.return();
} catch {}
}
throw r52;
}
}
}
}
}
}
async startCall(c22976_0) {
let r82;
const _this3 = this;
let c28340_2;
let c28340_3 = 0;
let c31032_0, c31032_1, c31032_2;
L19: {
L12: {
try {
c31032_0 = void 0;
c31032_1 = void 0;
const channelId2 = c22976_0.channelId;
c31032_0 = channelId2;
const guildId2 = c22976_0.guildId;
if (_this3.currentCall?.channelId === channelId2 && _this3.currentCall.state === c11741_26.Connected) {
c11741_25.info("Call already active for channel:", channelId2);
break L12;
}
c11741_25.info("Starting Telecom call:", channelId2);
c28340_3 = 1;
const r64 = await Module16325.startCall(channelId2, guildId2 != null ? {
guildId: guildId2
} : null);
const r76 = "Native startCall returned false, clearing call state";
c31032_1 = r64;
if (!c31032_1) {
c11741_25.warn(r76);
_this3.clearCall(c31032_0);
}
r82 = c31032_1;
c28340_3 = 0;
break L19;
} catch ($e) {
const r32 = $e;
let r8 = r32;
c28340_2 = r32;
if (c28340_3 !== 0) {
while (true) {
try {
const r100 = c28340_2;
c28340_3 = 0;
c31032_2 = r100;
c11741_25.warn("Failed to register call with Telecom:", c31032_2);
_this3.clearCall(c31032_0);
} catch (r96) {
r8 = r96;
c28340_2 = r96;
if (c28340_3 === 0) {
break;
}
continue;
}
return false;
}
}
throw r8;
}
}
return true;
}
return r82;
}
endCall(a0) {
c11741_25.info("Ending call:", a0.channelId);
return Module16325.endCall(a0.channelId).then((result) => {
this.clearCall(a0.channelId);
return result;
}).catch((error) => {
c11741_25.warn("Failed to end call:", error);
this.clearCall(a0.channelId);
return false;
});
}
reportCallEnded() {
c11741_25.info("Reporting call ended");
return this.currentCall == null ? Promise.resolve(true) : this.currentCall.state === c11741_26.Ringing ? this.cancelIncomingCall(this.currentCall.channelId) : this.endCall(this.currentCall);
}
setCallActive(a0) {
if (this.currentCall?.channelId === a0) {
c11741_25.info("Setting call active:", a0);
const isSelfMute = MediaEngineStore.isSelfMute();
Module16325.setCallActive(a0, isSelfMute);
this.lastMuteState = isSelfMute;
this.lastScreenShareActive = false;
} else {
c11741_25.warn("setCallActive called for unknown channel:", a0);
}
}
setIncomingCallActive(a0) {
if (this.currentCall?.channelId === a0) {
c11741_25.info("Setting incoming call active:", a0);
const isSelfMute = MediaEngineStore.isSelfMute();
const pendingMutePreference = this.pendingMutePreference;
let lastMuteState = isSelfMute;
if (pendingMutePreference != null) {
const pendingMutePreference2 = this.pendingMutePreference;
this.pendingMutePreference = null;
lastMuteState = isSelfMute;
if (isSelfMute !== pendingMutePreference2) {
c11741_25.info("Re-applying Telecom Bar ringing-state mute preference:", pendingMutePreference2);
AudioActionCreators.setSelfMute(MediaEngineContextTypes.DEFAULT, pendingMutePreference2, false);
lastMuteState = pendingMutePreference2;
}
}
Module16325.setIncomingCallActive(a0, lastMuteState);
this.lastMuteState = lastMuteState;
this.lastScreenShareActive = false;
} else {
c11741_25.warn("setIncomingCallActive called for unknown channel:", a0);
}
}
clearScreenShareState() {
this.lastScreenShareActive = null;
}
clearPendingScreenShareOffSync() {
if (this.pendingScreenShareOffSyncTimeout != null) {
clearTimeout(this.pendingScreenShareOffSyncTimeout);
this.pendingScreenShareOffSyncTimeout = null;
}
}
clearCall(a0) {
if (this.currentCall?.channelId === a0) {
this.stopRingtone();
this.currentCall = null;
this.lastMuteState = null;
this.pendingMutePreference = null;
this.clearScreenShareState();
this.clearPendingScreenShareOffSync();
}
}
startRingtone() {
if (isMetaQuest() && this.ringtone == null && !(StreamerModeStore.disableSounds || NotificationSettingsStore.isSoundDisabled("call_ringing"))) {
this.ringtone = createSoundForPack("call_ringing", SoundpackStore.getSoundpack());
this.ringtone.loop();
}
}
stopRingtone() {
const ringtone = this.ringtone;
if (ringtone != null) {
this.ringtone = null;
ringtone.stop();
}
}
handleMuteStoreChange() {
if (this.isEnabled() && this.currentCall != null && this.currentCall.state === c11741_26.Connected) {
const isSelfMute = MediaEngineStore.isSelfMute();
if (this.lastMuteState !== isSelfMute) {
this.lastMuteState = isSelfMute;
c11741_25.info("Syncing Discord -> Call Bar mute state:", isSelfMute);
Module16325.setMicMuted(this.currentCall.channelId, isSelfMute);
}
}
}
handleScreenShareStoreChange() {
let channelId;
if (this.isEnabled() && this.currentCall != null && this.currentCall.state === c11741_26.Connected) {
const currentUserActiveStream = ApplicationStreamingStore.getCurrentUserActiveStream();
const lastScreenShareActive = currentUserActiveStream != null && currentUserActiveStream.state === ApplicationStreamStates.ACTIVE;
if (this.lastScreenShareActive !== lastScreenShareActive) {
this.lastScreenShareActive = lastScreenShareActive;
this.clearPendingScreenShareOffSync();
if (lastScreenShareActive) {
c11741_25.info("Syncing Discord -> Call Bar screen share state: true");
Module16325.setScreenShareState(this.currentCall.channelId, true, true);
} else {
channelId = this.currentCall.channelId;
this.pendingScreenShareOffSyncTimeout = setTimeout(() => {
this.pendingScreenShareOffSyncTimeout = null;
if (this.isEnabled() && this.currentCall?.channelId === channelId) {
c11741_25.info("Syncing Discord -> Call Bar screen share state: false (delayed)");
Module16325.setScreenShareState(channelId, true, false);
}
}, 400);
}
}
}
}
}
c11741_28 = TelecomManager;
const r128 = new TelecomManager();
export default r128;
+147
View File
@@ -0,0 +1,147 @@
// Metro module 7980 (f7981).
import _slicedToArray from "../../../_bundle/_slicedToArray";
import { useState, useEffect, memo } from "react";
import { Image as Image2, NativeModules, View } from "react-native";
import { EMPTY_STRING_SNOWFLAKE_ID, NOOP } from "../../../Constants";
import { createStyles } from "../../../design/components/Styles/native/createStyles";
import Module12 from "../../../_bundle/Module12";
import useGetIsMounted from "../../../hooks/useGetIsMounted";
import VideoBackgroundManager from "./VideoBackgroundManager";
import { hexToRgb } from "../../../utils/ColorUtils";
import Module712 from "../../../_bundle/Module712";
import MobileVisualRefreshExperiment from "../../themes/experiments/MobileVisualRefreshExperiment";
import useDisplayProfile from "../../user_profile/hooks/useDisplayProfile";
import { useVideoTileGradientColors } from "./useVideoTileGradientColors";
import maybeFetchUserProfile from "../../user_profile/maybeFetchUserProfile";
import * as _native from "../../../design/void/native";
import { Avatar } from "../../../design/void/native";
import Module4611 from "../../../_bundle/Module4611";
let useStyles, c5046_13;
const useDominantRGBFromImage = function useDominantRGBFromImage(url, source) {
let c16141_1 = source;
const isArray = Array.isArray(source);
let r11 = source;
if (isArray) {
const r18 = source[0];
c16141_1 = r18;
r11 = r18;
}
const getIsMounted = useGetIsMounted();
let c16141_2 = getIsMounted;
let r23 = url != null ? VideoBackgroundManager.cachedDominantColors[url] : void 0;
if (r23 == null) {
r23 = hexToRgb(Module712.unsafe_rawColors.PRIMARY_800);
}
const [state, setState] = useState(r23);
useEffect(() => {
if (c16141_1 != null && url != null) {
if (VideoBackgroundManager.cachedDominantColors[url] == null) {
(typeof c16141_1 === "number" ? NativeModules.ImageManager.getDominantColorsLocalAsset(Image2.resolveAssetSource(c16141_1)) : NativeModules.ImageManager.getDominantColors(Image2.resolveAssetSource(c16141_1))).then((result) => {
if (c16141_2()) {
const r10 = _slicedToArray(result[0], 3);
const r11 = {
r: r10[0],
g: r10[1],
b: r10[2]
};
setState(r11);
VideoBackgroundManager.cachedDominantColors[url] = r11;
}
}).catch(NOOP);
} else {
setState(VideoBackgroundManager.cachedDominantColors[url]);
}
}
}, [r11, url, getIsMounted]);
return state;
};
const VideoBackground = function VideoBackground(props) {
const { style, url, isStageCall = false, avatarStyle, user, guildId, renderVideoDetails, ...props2 } = props;
const styles = useStyles();
const source = c5046_13(url);
const dominantRGBFromImage = useDominantRGBFromImage(url, source);
const backgroundColor = `rgb(${dominantRGBFromImage.r}, ${dominantRGBFromImage.g}, ${dominantRGBFromImage.b})`;
const r23 = MobileVisualRefreshExperiment("VideoBackground-native");
let c16142_1 = r23;
let r46 = user?.id;
if (r46 == null) {
r46 = EMPTY_STRING_SNOWFLAKE_ID;
}
const EMPTY_STRING_SNOWFLAKE_ID2 = r46;
const displayProfile = useDisplayProfile(EMPTY_STRING_SNOWFLAKE_ID2, guildId);
const r50 = displayProfile == null;
let r51 = void 0;
if (!r50) {
const themeColors = displayProfile.themeColors;
r51 = themeColors == null ? void 0 : themeColors[0];
}
if (r51 == null) {
r51 = null;
}
const r54 = displayProfile == null;
let r24 = void 0;
if (!r54) {
const themeColors2 = displayProfile.themeColors;
r24 = themeColors2 == null ? void 0 : themeColors2[1];
}
if (r24 == null) {
r24 = null;
}
const r57 = r23 && r51 != null && r24 != null;
const videoTileGradientColors = useVideoTileGradientColors(r57 ? r51 : null, r57 ? r24 : null);
useEffect(() => {
if (EMPTY_STRING_SNOWFLAKE_ID2 !== EMPTY_STRING_SNOWFLAKE_ID && c16142_1) {
maybeFetchUserProfile(EMPTY_STRING_SNOWFLAKE_ID2, void 0, {
guildId,
dispatchWait: true
});
}
}, [r23, EMPTY_STRING_SNOWFLAKE_ID2, guildId]);
if (source == null) {
return null;
}
let r68 = renderVideoDetails == null ? void 0 : renderVideoDetails();
if (r68 == null) {
r68 = null;
}
const style2 = [style, styles.videoBackground, r57 ? null : {
backgroundColor
}, r68 != null ? styles.videoDetailsSpacer : null];
const r86 = <Avatar source={source} {...props2} avatarStyle={[avatarStyle, isStageCall ? r57 ? null : {
backgroundColor
} : null]} isStageCall={isStageCall} />;
return videoTileGradientColors != null ? <Module4611 colors={videoTileGradientColors} start={{
x: 0,
y: 0
}} end={{
x: 0,
y: 1
}} style={style2}>
{r86}
{r68}
</Module4611> : <View style={style2}>
{r86}
{r68}
</View>;
};
useStyles = createStyles({
videoBackground: {
alignItems: "center"
},
videoDetailsSpacer: {
paddingTop: 12
}
});
c5046_13 = Module12.memoize((a0) => a0 == null ? null : a0 !== "" ? typeof a0 !== "number" ? {
uri: a0
} : a0 : null);
VideoBackground.AvatarSizes = _native.AvatarSizes;
const r48 = memo(VideoBackground);
export default r48;
export const AvatarSizes = _native.AvatarSizes;
export { c5046_13 as memoizedImageSource };
export { useDominantRGBFromImage };
export function useDominantColorFromImage(a0, a1) {
const dominantRGBFromImage = useDominantRGBFromImage(a0, a1);
return `rgb(${dominantRGBFromImage.r}, ${dominantRGBFromImage.g}, ${dominantRGBFromImage.b})`;
}
@@ -0,0 +1,18 @@
// Metro module 7982 (f7983).
import SelectedChannelStore from "../../../stores/SelectedChannelStore";
import AutomaticLifecycleManager from "../../../lib/AutomaticLifecycleManager";
class VideoBackgroundManager extends AutomaticLifecycleManager {
previousSelectedVoiceChannelId = SelectedChannelStore.getVoiceChannelId();
cachedDominantColors = {};
_handleSelectVoiceChannel = ({ channelId }) => {
if (this.previousSelectedVoiceChannelId !== channelId) {
this.cachedDominantColors = {};
}
this.previousSelectedVoiceChannelId = channelId;
};
actions = {
VOICE_CHANNEL_SELECT: this._handleSelectVoiceChannel
};
}
const videoBackgroundManager = new VideoBackgroundManager();
export default videoBackgroundManager;
@@ -0,0 +1,55 @@
// Metro module 8830 (f8831).
import VoiceStateStore from "../../../stores/VoiceStateStore";
import { NOOP_NULL } from "../../../Constants";
import * as _PrivateChannelCallUtils from "../../../utils/native/PrivateChannelCallUtils";
import { checkIsCallActive } from "../mobile/useIsCallActive";
import { intl, t } from "../../../intl/index.native";
import { handleDisconnect } from "../../voice_calls/native/CallsUtils";
export default function getPrivateChannelCall(a0) {
let accessibilityHint, onPress, text;
let r11 = arguments[1];
if (r11 === void 0) {
r11 = false;
}
let c16817_1 = r11;
let r4 = arguments[2];
if (r4 === void 0) {
r4 = _PrivateChannelCallUtils.handleStartCall;
}
const handleStartCall = r4;
let r19 = arguments[3];
if (r19 === void 0) {
r19 = _PrivateChannelCallUtils.handleJoinCall;
}
const handleJoinCall = r19;
const isInChannel = VoiceStateStore.isInChannel(a0.id);
const r30 = checkIsCallActive(a0.id);
if (a0.isSystemDM()) {
onPress = NOOP_NULL;
text = null;
accessibilityHint = void 0;
} else if (isInChannel) {
const r72 = r11 ? null : intl.string(t["4ry6yi"]);
onPress = () => handleDisconnect(a0);
text = r72;
accessibilityHint = void 0;
} else if (r30) {
const r59 = r11 ? a0 != null ? VoiceStateStore.hasVideo(a0.id) ? intl.string(t.W68MhH) : null : null : intl.string(t.fdEeb5);
onPress = () => handleJoinCall(a0, c16817_1);
text = r59;
accessibilityHint = void 0;
} else {
text = r11 ? intl.string(t["7AWk50"]) : intl.string(t["EZgS+9"]);
accessibilityHint = r11 ? intl.string(t.oCqlGG) : intl.string(t.focH1t);
onPress = () => handleStartCall(a0, c16817_1);
}
if (accessibilityHint == null) {
accessibilityHint = text;
}
return {
text,
accessibilityHint,
inCall: isInChannel,
onPress
};
};
@@ -0,0 +1,61 @@
// Metro module 12225 (f12226).
import { useCallback } from "react";
import ChannelStore from "../../../stores/ChannelStore";
import { useStateFromStoresObject } from "../../../_bundle/Module589";
import { intl, t } from "../../../intl/index.native";
import getPrivateChannelCall from "./getPrivateChannelCall";
import ChannelActionCreators from "../../../actions/ChannelActionCreators";
export default function usePrivateChannelCall(a0, a1, a2) {
const stateFromStoresObject = useStateFromStoresObject([ChannelStore], () => {
const channel = ChannelStore.getChannel(ChannelStore.getDMFromUserId(a0));
if (channel != null && channel.isPrivate()) {
const privateChannelCall = getPrivateChannelCall(channel, a1);
return {
text: privateChannelCall.text,
accessibilityHint: privateChannelCall.accessibilityHint,
inCall: privateChannelCall.inCall
};
}
return {
text: a1 ? intl.string(t["7AWk50"]) : intl.string(t["EZgS+9"]),
accessibilityHint: a1 ? intl.string(t.oCqlGG) : intl.string(t.focH1t),
inCall: false
};
}, [a1, a0]);
return {
text: stateFromStoresObject.text,
inCall: stateFromStoresObject.inCall,
accessibilityHint: stateFromStoresObject.accessibilityHint,
handlePress: useCallback(async () => {
let c27275_1;
let c30513_0, c30513_1;
L25: {
c27275_1 = void 0;
c30513_0 = void 0;
c30513_1 = void 0;
c30513_0 = ChannelStore.getChannel(ChannelStore.getDMFromUserId(a0));
if (c30513_0 == null) {
c30513_1 = await ChannelActionCreators.ensurePrivateChannel(a0);
c30513_0 = ChannelStore.getChannel(c30513_1);
const r82 = c30513_0;
if (r82 == null ? void 0 : r82.isPrivate()) {
getPrivateChannelCall(c30513_0, a1).onPress();
}
if (a2 == null) {
break L25;
}
a2();
break L25;
}
const r41 = c30513_0;
if (r41 == null ? void 0 : r41.isPrivate()) {
getPrivateChannelCall(c30513_0, a1).onPress();
}
if (a2 != null) {
a2();
}
return void 0;
}
}, [a0, a1, a2])
};
};
@@ -0,0 +1,29 @@
// Metro module 7988 (f7989).
import { useMemo } from "react";
import { ThemeTypes } from "../../../Constants";
import { getProfileTheme, calculateModalV2BackgroundColor, getValueInColorGradientByPercentage } from "../../user_profile/UserProfileGradientUtils";
import { int2rgbArray } from "../../../_bundle/int2hslRaw";
let computeVideoTileGradientStops;
const rgbToHex = function rgbToHex(a0) {
const [r12, r14, r15] = a0;
return `#${Math.max(0, Math.min(255, r12)).toString(16).padStart(2, "0")}${Math.max(0, Math.min(255, r14)).toString(16).padStart(2, "0")}${Math.max(0, Math.min(255, r15)).toString(16).padStart(2, "0")}`;
};
computeVideoTileGradientStops = function computeVideoTileGradientStops(a0, a1) {
if (a0 != null && a1 != null) {
let r12 = getProfileTheme(a0);
if (r12 == null) {
r12 = ThemeTypes.DARK;
}
const r21 = int2rgbArray(calculateModalV2BackgroundColor(a0, a1, r12));
const r25 = int2rgbArray(a0);
const r29 = int2rgbArray(a1);
const valueInColorGradientByPercentage = getValueInColorGradientByPercentage([r21[0], r21[1], r21[2]], [r25[0], r25[1], r25[2]], 20);
const valueInColorGradientByPercentage2 = getValueInColorGradientByPercentage([r21[0], r21[1], r21[2]], [r29[0], r29[1], r29[2]], 60);
return [rgbToHex(valueInColorGradientByPercentage), rgbToHex(valueInColorGradientByPercentage2)];
}
return null;
};
export { computeVideoTileGradientStops };
export function useVideoTileGradientColors(a0, a1) {
return useMemo(() => computeVideoTileGradientStops(a0, a1), [a0, a1]);
}