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,11 @@
// Metro module 10785 (f10786).
import Dispatcher from "../../../Dispatcher";
const r12 = {
setEnabled: (a0) => {
Dispatcher.dispatch({
type: "MOBILE_VOICE_OVERLAY_STATE_CHANGED",
enabled: a0
});
}
};
export default r12;
@@ -0,0 +1,408 @@
// Metro module 13582 (f13583).
import ChannelStore from "../../../stores/ChannelStore";
import { GUILD_VOCAL_CHANNELS_KEY } from "../../../stores/GuildChannelStore";
import GuildStore from "../../../stores/GuildStore";
import MediaEngineStore from "../../../stores/MediaEngineStore";
import PermissionStore from "../../../stores/PermissionStore";
import RTCConnectionStore from "../../../stores/RTCConnectionStore";
import RelationshipStore from "../../../stores/RelationshipStore";
import SpeakingStore from "../../../stores/SpeakingStore";
import UserStore from "../../../stores/UserStore";
import VoiceStateStore from "../../../stores/VoiceStateStore";
import MobileVoiceOverlayStore from "../../../stores/native/MobileVoiceOverlayStore";
import { AnalyticEvents, Permissions } from "../../../Constants";
import "../../../_bundle/Module13583";
import "../../../_bundle/Module13584";
import "../../../_bundle/Module13585";
import "../../../_bundle/Module13586";
import "../../../_bundle/Module7699";
import "../../../_bundle/Module12844";
import "../../../_bundle/Module13587";
import "../../../_bundle/Module13588";
import "../../../_bundle/Module7684";
import { intl, t } from "../../../intl/index.native";
import { isFabric } from "../../../utils/native/FabricUtils";
import Module39 from "../../../_bundle/Module39";
import Module13589 from "../../../_bundle/Module13589";
import MobileVoiceOverlayActionCreators from "./MobileVoiceOverlayActionCreators";
import ForegroundServiceManager_android from "../../foreground_service/mobile/ForegroundServiceManager.android";
import { computeChannelName } from "../../channel/useChannelName";
import AutocompleteUtils from "../../../utils/AutocompleteUtils";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { collectChannelAnalyticsMetadata, collectGuildAnalyticsMetadata } from "../../app_analytics/AppAnalyticsUtils";
import LifecycleManager from "../../../lib/LifecycleManager";
let c9436_19;
let c9436_16 = [VoiceStateStore, RTCConnectionStore, MediaEngineStore];
let c9436_17 = {
DISABLED: 0,
0: "DISABLED",
NOT_SHOWING: 1,
1: "NOT_SHOWING",
WAITING_FOR_SERVICE: 2,
2: "WAITING_FOR_SERVICE",
SHOWING: 3,
3: "SHOWING"
};
let c9436_18 = {
useSpeaker: intl.string(t.CVxXDM),
mute: intl.string(t.w4m945),
disconnectFromVoice: intl.string(t["/lEZpt"]),
getInvite: intl.string(t.JYzIWe),
switchChannels: intl.string(t.zJvWqU),
openDiscord: intl.string(t["G/Ez6p"]),
inviteLinkCopied: intl.string(t.OhctG7),
channelSelect: intl.string(t.r2ptsz),
closeWindow: intl.string(t.gaifwY),
searchChannels: intl.string(t.wM7uRI),
noResults: intl.string(t.wk3qsA)
};
class MobileVoiceOverlayManager {
currentVoiceChannelId = null;
trashedVoiceChannelId = null;
overlayState = c9436_17.DISABLED;
channelSelectorResults = [];
layoutTrashedSubscription = null;
channelQueryUpdateSubscription = null;
isBatchedBridgeInitialized = false;
handleMobileVoiceOverlayStoreUpdate = () => {
const enabled = MobileVoiceOverlayStore.getEnabled();
if (enabled) {
this.handleOverlayEnable();
} else {
this.unsubscribeFromVoiceStateStoreUpdates();
this.unsubscribeFromNativeEvents();
const isOverlayShowing2 = this.isOverlayShowing();
this.overlayState = c9436_17.DISABLED;
if (isOverlayShowing2) {
if (Module13589 != null) {
Module13589.hideOverlay();
}
}
}
};
handleOverlayEnable = () => {
if (Module13589 != null) {
Module13589.enableOverlay().then((result) => {
if (result) {
this.subscribeToVoiceStateStoreUpdates();
this.subscribeToNativeEvents();
this.overlayState = c9436_17.NOT_SHOWING;
} else {
MobileVoiceOverlayActionCreators.setEnabled(false);
this.overlayState = c9436_17.DISABLED;
}
}).catch(() => {
MobileVoiceOverlayActionCreators.setEnabled(false);
this.overlayState = c9436_17.DISABLED;
});
}
};
subscribeToVoiceStateStoreUpdates = () => {
if (!this.isSubscribedToVoiceStateStoreUpdates()) {
c9436_16.forEach((item) => {
item.addChangeListener(this.handleOverlayUIStoreUpdate);
});
}
};
unsubscribeFromVoiceStateStoreUpdates = () => {
if (this.isSubscribedToVoiceStateStoreUpdates()) {
c9436_16.forEach((item) => {
item.removeChangeListener(this.handleOverlayUIStoreUpdate);
});
}
};
isSubscribedToVoiceStateStoreUpdates = () => c9436_16.find((item) => item._changeCallbacks.has(this.handleOverlayUIStoreUpdate)) != null;
subscribeToNativeEvents = () => {
if (isFabric()) {
this.layoutTrashedSubscription = Module13589.onLayoutTrashed(this.handleLayoutTrashed);
this.channelQueryUpdateSubscription = Module13589.onChannelQueryUpdate(this.handleChannelQueryUpdate);
}
};
unsubscribeFromNativeEvents = () => {
if (isFabric()) {
const layoutTrashedSubscription = this.layoutTrashedSubscription;
if (layoutTrashedSubscription != null) {
layoutTrashedSubscription.remove();
}
const channelQueryUpdateSubscription = this.channelQueryUpdateSubscription;
if (channelQueryUpdateSubscription != null) {
channelQueryUpdateSubscription.remove();
}
}
};
handleOverlayUIStoreUpdate = () => {
L12: {
if (this.overlayState !== c9436_17.DISABLED) {
const currentVoiceChannelId = this.getVoiceConnectedGuildAndChannel().currentVoiceChannelId;
if (currentVoiceChannelId !== this.currentVoiceChannelId) {
this.currentVoiceChannelId = currentVoiceChannelId;
this.trashedVoiceChannelId = null;
}
if (currentVoiceChannelId != null && currentVoiceChannelId !== this.trashedVoiceChannelId) {
const overlayState = this.overlayState;
if (c9436_17.WAITING_FOR_SERVICE === overlayState) {
return void 0;
}
if (c9436_17.NOT_SHOWING === overlayState) {
ForegroundServiceManager_android.isForegroundServiceRunning((a0) => {
if (a0) {
this.showOverlay();
} else {
this.overlayState = c9436_17.NOT_SHOWING;
}
});
this.overlayState = c9436_17.WAITING_FOR_SERVICE;
return void 0;
}
if (c9436_17.SHOWING === overlayState) {
this.updateOverlayUI();
break L12;
}
this.overlayState;
break L12;
}
if (this.isOverlayShowing()) {
this.hideOverlay();
}
}
}
};
updateOverlayUI = () => {
let r34;
const id = UserStore.getCurrentUser()?.id;
if (id != null) {
const voiceConnectedGuildAndChannel = this.getVoiceConnectedGuildAndChannel();
const { currentGuildId, currentVoiceChannelId } = voiceConnectedGuildAndChannel;
const channel = ChannelStore.getChannel(currentVoiceChannelId);
if (currentVoiceChannelId != null && channel != null) {
const overlayUser = this.getOverlayUser(id);
if (overlayUser != null) {
const r49 = Object.keys(VoiceStateStore.getVoiceStatesForChannel(currentVoiceChannelId));
let r50 = null;
if (overlayUser.speaking) {
r50 = overlayUser;
} else {
for (const item of r49) {
const overlayUser2 = this.getOverlayUser(item);
if (!overlayUser2?.speaking) {
continue;
}
r50 = overlayUser2;
break;
}
}
if (r50 == null) {
r50 = overlayUser;
}
const r65 = r50;
const users = [r65];
if (r65.userId !== overlayUser.userId) {
users.push(overlayUser);
}
let r72 = r49[Symbol.iterator]();
const next = r72.next;
while (true) {
const r76 = r72 === void 0 ? void 0 : (r34 = next.call(r72)).done ? r72 = void 0 : r34.value;
if (r72 !== void 0) {
L30: {
try {
if (r76 === id) {
continue;
}
if (r76 === r50?.userId) {
continue;
}
const overlayUser3 = this.getOverlayUser(r76);
if (overlayUser3 == null) {
continue;
}
users.push(overlayUser3);
if (users.length >= 3) {
break L30;
}
continue;
} catch (r93) {
if (r72 !== void 0 && typeof r72.return === "function") {
try {
r72.return();
} catch {}
}
throw r93;
}
}
const r92 = r72;
if (r92 !== void 0 && typeof r92.return === "function") {
r92.return();
}
}
if (this.overlayState !== c9436_17.SHOWING) {
this.refreshChannelSelectorResults("");
}
this.currentVoiceChannelId = currentVoiceChannelId;
if (Module13589 == null) {
break;
}
const r116 = {
users,
channelName: computeChannelName(channel, UserStore, RelationshipStore),
guildName: null,
guildId: null,
channelId: null,
extraUsers: null,
deafened: null,
muted: null,
connectionQuality: null,
canGenerateInvite: null,
channelSelectorResults: null
};
let guildName = GuildStore.getGuild(currentGuildId)?.name;
if (guildName == null) {
guildName = "";
}
r116.guildName = guildName;
r116.guildId = currentGuildId;
r116.channelId = currentVoiceChannelId;
r116.extraUsers = r49.length - users.length;
r116.deafened = MediaEngineStore.isSelfDeaf();
r116.muted = MediaEngineStore.isSelfMute();
r116.connectionQuality = RTCConnectionStore.getQuality();
r116.canGenerateInvite = PermissionStore.can(Permissions.CREATE_INSTANT_INVITE, channel);
r116.channelSelectorResults = this.channelSelectorResults;
Module13589.setData(r116);
break;
}
}
}
}
};
getVoiceConnectedGuildAndChannel = () => {
let currentGuildId = RTCConnectionStore.getGuildId();
if (currentGuildId == null) {
currentGuildId = null;
}
let currentVoiceChannelId = RTCConnectionStore.getChannelId();
if (currentVoiceChannelId == null) {
currentVoiceChannelId = null;
}
return {
currentGuildId,
currentVoiceChannelId
};
};
refreshChannelSelectorResults = (a0) => {
this.channelSelectorResults = AutocompleteUtils.queryChannels({
query: a0,
guildId: a0.length === 0 ? this.getVoiceConnectedGuildAndChannel().currentGuildId : null,
limit: 15,
fuzzy: true,
filter: (a0) => a0.id !== this.currentVoiceChannelId && !a0.isGuildStageVoice(),
type: GUILD_VOCAL_CHANNELS_KEY,
allowEmptyQueries: true
}).map(({ record }) => {
const r13 = {
channelId: record.id,
guildId: record.guild_id,
channelName: computeChannelName(record, UserStore, RelationshipStore),
guildName: null,
categoryName: null
};
let guildName = GuildStore.getGuild(record.guild_id)?.name;
if (guildName == null) {
guildName = "";
}
r13.guildName = guildName;
const channel = ChannelStore.getChannel(record.parent_id);
r13.categoryName = channel != null ? computeChannelName(channel, UserStore, RelationshipStore) : "";
return r13;
});
};
showOverlay = () => {
const voiceConnectedGuildAndChannel = this.getVoiceConnectedGuildAndChannel();
const currentGuildId = voiceConnectedGuildAndChannel.currentGuildId;
const channel = ChannelStore.getChannel(voiceConnectedGuildAndChannel.currentVoiceChannelId);
AnalyticsUtils.track(AnalyticEvents.MOBILE_OVERLAY_OPENED, {
type: "voice",
rtc_connection_id: RTCConnectionStore.getRTCConnectionId(),
...collectChannelAnalyticsMetadata(channel),
...collectGuildAnalyticsMetadata(currentGuildId)
});
if (Module13589 != null) {
Module13589.showOverlay(c9436_18);
}
this.updateOverlayUI();
this.overlayState = c9436_17.SHOWING;
};
hideOverlay = () => {
AnalyticsUtils.track(AnalyticEvents.MOBILE_OVERLAY_CLOSED, {
type: "voice",
rtc_connection_id: RTCConnectionStore.getRTCConnectionId()
});
AnalyticsUtils.track(AnalyticEvents.MOBILE_OVERLAY_CLOSED, {});
if (Module13589 != null) {
Module13589.hideOverlay();
}
this.overlayState = c9436_17.NOT_SHOWING;
};
isOverlayShowing = () => this.overlayState === c9436_17.SHOWING || this.overlayState === c9436_17.WAITING_FOR_SERVICE;
getOverlayUser = (a0) => {
const user = UserStore.getUser(a0);
if (user == null) {
return null;
}
return {
userId: a0,
avatar: user.avatar,
speaking: SpeakingStore.isSpeaking(a0),
discriminator: user.discriminator
};
};
handleLayoutTrashed = () => {
this.trashedVoiceChannelId = this.currentVoiceChannelId;
this.handleOverlayUIStoreUpdate();
};
handleChannelQueryUpdate = (a0) => {
this.refreshChannelSelectorResults(a0);
this.handleOverlayUIStoreUpdate();
};
initialize() {
if (!(isFabric() || this.isBatchedBridgeInitialized)) {
const r20 = {
__proto__: NativeCallableInterface.prototype
};
r20.manager = this;
Module39.registerCallableModule("MobileVoiceOverlayManager", r20);
this.isBatchedBridgeInitialized = true;
}
if (MobileVoiceOverlayStore.getEnabled()) {
this.handleOverlayEnable();
}
MobileVoiceOverlayStore.addChangeListener(this.handleMobileVoiceOverlayStoreUpdate);
}
terminate() {
MobileVoiceOverlayStore.removeChangeListener(this.handleMobileVoiceOverlayStoreUpdate);
this.unsubscribeFromVoiceStateStoreUpdates();
this.unsubscribeFromNativeEvents();
}
}
c9436_19 = new MobileVoiceOverlayManager();
class NativeCallableInterface {
constructor(a0) {
this.manager = a0;
}
onLayoutTrashed() {
this.manager.handleLayoutTrashed();
}
onChannelQueryUpdate(a0) {
this.manager.handleChannelQueryUpdate(a0);
}
}
class MobileVoiceOverlayLifecycleManager extends LifecycleManager {
_initialize() {
c9436_19.initialize();
}
_terminate() {
c9436_19.terminate();
}
}
const mobileVoiceOverlayLifecycleManager = new MobileVoiceOverlayLifecycleManager();
export default mobileVoiceOverlayLifecycleManager;