decord/stable/source/stores/RTCConnectionDesyncStore.tsx
2026-10-06 22:12:49 +00:00

209 lines
7.4 KiB
TypeScript

// Module ID: 13301
// Function ID: 13302
// Name: RTCConnectionDesyncStore
// Dependencies: [4857, 2051, 4860, 1378, 4856, 4861, 1086, 4858, 2024, 4989, 7665, 4892, 504, 585, 2]
// Module 13301 (RTCConnectionDesyncStore)
import get_initializedDefault from "get initialized" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 585 */;
import CachedEntriesMapDefault from "CachedEntriesMap" /* 2024 */;
import CallConstants from "CallConstants" /* 4858 */;
import SortedVoiceStateStore from "SortedVoiceStateStore" /* 4861 */;
import BaseConnectionEvent from "BaseConnectionEvent" /* 4892 */;
import NicknameUtilsDefault from "NicknameUtils" /* 4989 */;
import useAvatarDecoration from "useAvatarDecoration" /* 7665 */;
import VoiceStateRecord from "VoiceStateRecord" /* 4857 */;
import ChannelStore from "ChannelStore" /* 2051 */;
import RTCConnectionStore from "RTCConnectionStore" /* 4860 */;
import UserStore from "UserStore" /* 1378 */;
import VoiceStateStore from "VoiceStateStore" /* 4856 */;
import Constants from "Constants" /* 1086 */;
import size from "module_2" /* 2 */;
let c10;
let c9;
function retryFailedUsers() {
const channelId = RTCConnectionStore.getChannelId();
if (null == channelId) {
return false;
} else {
const channel = ChannelStore.getChannel(channelId);
let guildId;
if (channel != null) {
guildId = channel.getGuildId();
}
let c2 = false;
const item = set.forEach(function(item) {
let obj2;
let obj3;
if (null == VoiceStateStore.getVoiceStateForChannel(channelId, item)) {
const user = UserStore.getUser(item);
if (null != user) {
c2 = true;
set.delete(item);
const self = this;
const self2 = this;
const obj4 = { userId: user.id, channelId };
const tmp21 = new VoiceStateRecord(obj4);
let tmp6 = guildId;
const tmp22 = makeSortedVoiceState;
if (guildId == null) {
tmp6 = React4;
}
const result = closure_12.set(user.id, tmp22(tmp21, tmp6, user.id));
const obj = { type: ParticipantTypes.USER, user, id: user.id, streamId: null, voiceState: tmp21, voicePlatform: null, speaking: false, lastSpoke: 0, soundsharing: false, ringing: false, userNick: obj2.getName(guildId, channelId, user), userAvatarDecoration: obj3.getAvatarDecoration(user, guildId), localVideoDisabled: false, isPoppedOut: false };
obj2 = NicknameUtilsDefault;
obj3 = useAvatarDecoration;
const result1 = set2.set(user.id, obj);
}
} else {
set.delete(item);
}
});
let tmp6 = c2;
return c2;
}
}
const makeSortedVoiceState = SortedVoiceStateStore.makeSortedVoiceState;
({ ME: c9, RTCConnectionStates: c10 } = Constants);
const ParticipantTypes = CallConstants.ParticipantTypes;
const tmp3 = new CachedEntriesMapDefault();
const tmp4 = new CachedEntriesMapDefault();
const set = new Set();
const Store = get_initializedDefault.Store;
class RTCConnectionDesyncStore extends Store {
initialize() {
this.waitFor(VoiceStateStore, UserStore, ChannelStore, RTCConnectionStore);
const items = [UserStore];
this.syncWith(items, retryFailedUsers);
}
getDesyncedUserIds() {
return set.keys();
}
getDesyncedVoiceStates() {
return set.values();
}
getDesyncedParticipants() {
return set2.values();
}
}
Object.defineProperty(RTCConnectionDesyncStore.prototype, "desyncedVoiceStatesCount", {
get: function desyncedVoiceStatesCount() {
return set.size();
},
set: undefined
});
RTCConnectionDesyncStore.displayName = "RTCConnectionDesyncStore";
let obj = {
CONNECTION_OPEN: function handleConnectionOpen() {
set.clear();
set2.clear();
set.clear();
},
VOICE_CHANNEL_SELECT: function handleReset() {
set.clear();
set2.clear();
set.clear();
},
RTC_CONNECTION_STATE: function handleRTCConnectionState(arg0) {
let context;
let state;
({ state, context } = arg0);
let tmp = context === BaseConnectionEvent.MediaEngineContextTypes.DEFAULT;
if (tmp) {
if (state === constants.DISCONNECTED) {
set.clear();
set2.clear();
set.clear();
}
tmp = tmp3;
}
return tmp;
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(voiceStates) {
voiceStates = voiceStates.voiceStates;
const channelId = RTCConnectionStore.getChannelId();
const reduced = null != channelId && voiceStates.reduce((acc, userId) => {
userId = userId.userId;
let tmp = userId.channelId === channelId;
if (tmp) {
let deleteResult = set.delete(userId);
const deleteResult1 = set2.delete(userId);
const deleteResult2 = set.delete(userId);
if (!deleteResult) {
deleteResult = deleteResult1;
}
if (!deleteResult) {
deleteResult = deleteResult2;
}
tmp = deleteResult;
}
if (!tmp) {
tmp = acc;
}
return tmp;
}, false);
return reduced;
},
RTC_CONNECTION_CLIENT_CONNECT: function handleRTCConnectionClientConnect(context) {
let userIds;
({ userIds, guildId: require, channelId: importDefault } = context);
let reduced = context.context === BaseConnectionEvent.MediaEngineContextTypes.DEFAULT;
if (reduced) {
let flag = false;
reduced = userIds.reduce(function(acc, item) {
let obj2;
let obj3;
if (null != VoiceStateStore.getVoiceStateForChannel(importDefault, item)) {
return acc;
} else {
let flag;
const user = UserStore.getUser(item);
if (null == user) {
set.add(item);
flag = acc;
} else {
const self = this;
const self2 = this;
const obj4 = { userId: user.id, channelId: importDefault };
const tmp19 = new VoiceStateRecord(obj4);
let tmp2 = require;
const tmp20 = makeSortedVoiceState;
if (require == null) {
tmp2 = React4;
}
const result = closure_12.set(user.id, tmp20(tmp19, tmp2, user.id));
const obj = { type: ParticipantTypes.USER, user, id: user.id, streamId: null, voiceState: tmp19, voicePlatform: null, speaking: false, lastSpoke: 0, soundsharing: false, ringing: false, userNick: obj2.getName(require, importDefault, user), userAvatarDecoration: obj3.getAvatarDecoration(user, require), localVideoDisabled: false, isPoppedOut: false };
obj2 = NicknameUtilsDefault;
obj3 = useAvatarDecoration;
const result1 = set2.set(user.id, obj);
flag = true;
}
return flag;
}
}, false);
}
return reduced;
},
RTC_CONNECTION_CLIENT_DISCONNECT: function handleRTCConnectionClientDisconnect(userId) {
userId = userId.userId;
let tmp = userId.context === BaseConnectionEvent.MediaEngineContextTypes.DEFAULT;
if (tmp) {
let deleteResult = set.delete(userId);
const deleteResult1 = set2.delete(userId);
const deleteResult2 = set.delete(userId);
if (!deleteResult) {
deleteResult = deleteResult1;
}
if (!deleteResult) {
deleteResult = deleteResult2;
}
tmp = deleteResult;
}
return tmp;
}
};
const rTCConnectionDesyncStore = new RTCConnectionDesyncStore(DispatcherDefault, obj);
let result = size.fileFinishedImporting("stores/RTCConnectionDesyncStore.tsx");
export default rTCConnectionDesyncStore;