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

+164
View File
@@ -0,0 +1,164 @@
// Metro module 12796 (f12797).
import RunningGameStore_native from "../modules/game_detection/RunningGameStore.native";
import UserSettingsProtoStore from "../modules/user_settings/UserSettingsProtoStore";
import AuthenticationStore from "./AuthenticationStore";
import DetectableGameStore from "./DetectableGameStore";
import LibraryApplicationStore from "./LibraryApplicationStore";
import RTCConnectionStore from "./RTCConnectionStore";
import SelectedChannelStore from "./SelectedChannelStore";
import { Distributors } from "../Constants";
import Durations from "../utils/Durations";
import { Storage } from "../_bundle/Module595";
import * as _LibraryApplicationUtils from "../utils/LibraryApplicationUtils";
import ActivitiesActionCreators from "../actions/ActivitiesActionCreators";
import { Interval } from "../_bundle/Timeout";
import { removeExecutablePathPrefix } from "../modules/game_detection/GameAnalyticsUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c8823_11, c8823_12, c8823_13, c8823_14, c8823_15, c8823_16, updateActivity, handleRunningGamesChange, handleLogout;
const stopActivity = function stopActivity(a0, r5 = true) {
if (r5) {
updateActivity(a0, true);
}
const r7 = c8823_15[a0.applicationId];
if (r7 != null) {
r7.stop();
delete c8823_15[a0.applicationId];
}
delete c8823_14[a0.applicationId];
Storage.set(c8823_11, c8823_14);
};
updateActivity = function updateActivity(a0) {
let closed = arguments[1];
if (closed === void 0) {
closed = false;
}
const updatedAt = Date.now();
let r21 = a0.updatedAt != null ? updatedAt - a0.updatedAt : 0;
if (r21 > c8823_12 + c8823_13) {
r21 = 0;
}
const shouldShareApplicationActivity = _LibraryApplicationUtils.shouldShareApplicationActivity(a0.applicationId, LibraryApplicationStore);
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
const sessionId = AuthenticationStore.getSessionId();
const mediaSessionId = RTCConnectionStore.getMediaSessionId();
ActivitiesActionCreators.updateActivity({
applicationId: a0.applicationId,
distributor: a0.isDiscordApplication ? Distributors.DISCORD : a0.distributor,
shareActivity: shouldShareApplicationActivity,
token: a0.token,
duration: Math.floor(r21 / 1000),
closed,
exePath: a0.exePath,
voiceChannelId,
sessionId,
mediaSessionId
});
a0.updatedAt = updatedAt;
if (c8823_15[a0.applicationId] == null) {
const applicationId = a0.applicationId;
const interval = new Interval();
c8823_15[applicationId] = interval;
interval.start(c8823_12, () => {
updateActivity(a0);
});
}
if (!closed) {
c8823_14[a0.applicationId] = a0;
Storage.set(c8823_11, c8823_14);
}
};
handleRunningGamesChange = function handleRunningGamesChange(r7 = true) {
const visibleRunningGames = RunningGameStore_native.getVisibleRunningGames();
const set = new Set();
for (const item of visibleRunningGames) {
const r41 = DetectableGameStore.findGame(item);
if (r41 != null) {
set.add(r41.id);
if (!(r41.id in c8823_14)) {
const r53 = {
applicationId: r41.id,
updatedAt: Date.now(),
distributor: item.distributor,
exePath: null
};
let exePath = item.exePath;
if (exePath == null) {
exePath = "";
}
r53.exePath = removeExecutablePathPrefix(exePath);
updateActivity(r53);
}
}
}
for (const item2 of Object.keys(c8823_14)) {
if (!set.has(item2)) {
stopActivity(c8823_14[item2], r7);
}
}
};
handleLogout = function handleLogout() {
for (const item of Object.keys(c8823_14)) {
stopActivity(c8823_14[item]);
}
c8823_16 = false;
};
c8823_11 = "ActivityTrackingStore";
c8823_12 = 30 * Durations.Millis.MINUTE;
c8823_13 = 5 * Durations.Millis.MINUTE;
let r56 = Storage.get("ActivityTrackingStore");
if (r56 == null) {
r56 = {};
}
c8823_14 = r56;
c8823_15 = {};
c8823_16 = false;
class ActivityTrackingStore extends Module589.Store {
static displayName = "ActivityTrackingStore";
initialize() {
this.waitFor(AuthenticationStore, DetectableGameStore, LibraryApplicationStore, RTCConnectionStore, RunningGameStore_native, SelectedChannelStore, UserSettingsProtoStore);
this.syncWith([UserSettingsProtoStore], handleRunningGamesChange);
}
getActivities() {
return c8823_14;
}
}
const activityTrackingStore = new ActivityTrackingStore(Dispatcher, {
RUNNING_GAMES_CHANGE: () => {
handleRunningGamesChange();
},
CONNECTION_OPEN: function handleConnectionOpen() {
if (c8823_16) {
return false;
}
for (const item of Object.keys(c8823_14)) {
updateActivity(c8823_14[item]);
}
handleRunningGamesChange(false);
c8823_16 = true;
},
CONNECTION_CLOSED: function handleConnectionClosed(a0) {
if (a0.code === 4004) {
handleLogout();
}
},
LOGOUT: handleLogout,
ACTIVITY_UPDATE_SUCCESS: function handleActivityUpdate({ applicationId, token }) {
const r6 = c8823_14[applicationId];
if (r6 == null) {
return false;
}
r6.token = token;
Storage.set(c8823_11, c8823_14);
},
ACTIVITY_UPDATE_FAIL: function handleActivityUpdateFail(a0) {
const r6 = c8823_14[a0.applicationId];
if (r6 == null) {
return false;
}
r6.token = null;
r6.updatedAt = null;
Storage.set(c8823_11, c8823_14);
}
});
export default activityTrackingStore;
+29
View File
@@ -0,0 +1,29 @@
// Metro module 5720 (f5721).
import AuthenticationStore from "./AuthenticationStore";
import { Endpoints } from "../Constants";
import { analyticsTrackingStoreMaker, AnalyticsActionHandlers } from "../_bundle/Module503";
import Dispatcher from "../Dispatcher";
import { getSession } from "../modules/analytics_sessions/SessionHeartbeatScheduler";
import { launchSignature } from "../utils/AnalyticsUtils";
import { requestSafeIdleCallback } from "../_bundle/Module696";
const r39 = analyticsTrackingStoreMaker({
dispatcher: Dispatcher,
actionHandler: {
CONNECTION_OPEN: (a0) => AnalyticsActionHandlers.handleConnectionOpen(a0),
OVERLAY_INITIALIZE: (a0) => AnalyticsActionHandlers.handleConnectionOpen(a0),
CURRENT_USER_UPDATE: (a0) => AnalyticsActionHandlers.handleConnectionOpen(a0),
CONNECTION_CLOSED: () => AnalyticsActionHandlers.handleConnectionClosed(),
FINGERPRINT: () => AnalyticsActionHandlers.handleFingerprint(),
TRACK: (a0) => AnalyticsActionHandlers.handleTrack(a0),
SET_ANALYTICS_TOKEN: (a0) => AnalyticsActionHandlers.handleSetAnalyticsToken(a0)
},
TRACKING_URL: Endpoints.TRACK,
waitFor: [AuthenticationStore],
getFingerprint: AuthenticationStore.getFingerprint,
getSessionId: () => getSession().then((result) => ({
sessionId: result?.uuid
})),
getLaunchSignature: () => launchSignature,
scheduleWhenIdle: requestSafeIdleCallback
});
export default r39;
+105
View File
@@ -0,0 +1,105 @@
// Metro module 4371 (f4372).
import { StreamTypes } from "../modules/go_live/Constants";
import Module12 from "../_bundle/Module12";
import { encodeStreamKey, decodeStreamKey } from "../modules/go_live/utils/StreamKeyUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2589_4, c2589_5, c2589_6;
const reset = function reset() {
c2589_4 = {};
c2589_5 = {};
};
c2589_4 = {};
c2589_5 = {};
c2589_6 = new Set();
class ApplicationStreamPreviewStore extends Module589.Store {
static displayName = "ApplicationStreamPreviewStore";
getPreviewURL(a0, a1, a2) {
return c2589_4[encodeStreamKey({
streamType: a0 != null ? StreamTypes.GUILD : StreamTypes.CALL,
guildId: a0,
channelId: a1,
ownerId: a2
})]?.url;
}
shouldFetchPreview(a0, a1, a2) {
const r18 = encodeStreamKey({
streamType: a0 != null ? StreamTypes.GUILD : StreamTypes.CALL,
guildId: a0,
channelId: a1,
ownerId: a2
});
const r20 = c2589_4[r18];
let r22 = c2589_5[r18];
if (r22 == null) {
r22 = 0;
}
const r2 = r20 != null && Date.now() > r20.expires;
return (r20 == null && r22 < 5 || r2) && !c2589_6.has(r18);
}
getPreviewURLForStreamKey(a0) {
const r10 = decodeStreamKey(a0);
return this.getPreviewURL(r10.guildId, r10.channelId, r10.ownerId);
}
getIsPreviewLoading(a0, a1, a2) {
return c2589_6.has(encodeStreamKey({
streamType: a0 != null ? StreamTypes.GUILD : StreamTypes.CALL,
guildId: a0,
channelId: a1,
ownerId: a2
}));
}
}
const applicationStreamPreviewStore = new ApplicationStreamPreviewStore(Dispatcher, {
CONNECTION_OPEN: reset,
LOGOUT: reset,
STREAM_PREVIEW_FETCH_START: function handleStreamPreviewFetch({ streamKey }) {
let r6 = c2589_5[streamKey];
if (r6 == null) {
r6 = 0;
}
c2589_5[streamKey] = r6 + 1;
c2589_6.add(streamKey);
},
STREAM_PREVIEW_FETCH_SUCCESS: function handleStreamPreviewFetchSuccess(a0) {
const streamKey = a0.streamKey;
c2589_4[streamKey] = {
url: a0.previewURL,
expires: Date.now() + 120000
};
c2589_5[streamKey] = 0;
c2589_6.delete(streamKey);
},
STREAM_PREVIEW_FETCH_FAIL: function handleStreamPreviewFetchFail(a0) {
const streamKey = a0.streamKey;
let retryAfter = a0.retryAfter;
const r10 = Date.now();
if (retryAfter == null) {
retryAfter = 10000 * c2589_5[streamKey];
}
c2589_4[streamKey] = {
url: null,
expires: r10 + retryAfter
};
c2589_6.delete(streamKey);
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates({ voiceStates }) {
const isEmpty = Module12.isEmpty(c2589_4);
return (isEmpty ? !Module12.isEmpty(c2589_5) : !isEmpty) && voiceStates.reduce((acc, voiceState) => {
const { userId, guildId, channelId } = voiceState;
if (voiceState.selfStream) {
return acc;
}
const r17 = encodeStreamKey({
streamType: guildId != null ? StreamTypes.GUILD : StreamTypes.CALL,
guildId,
channelId,
ownerId: userId
});
delete c2589_4[r17];
delete c2589_5[r17];
return true;
}, false);
}
});
export default applicationStreamPreviewStore;
@@ -0,0 +1,84 @@
// Metro module 4279 (f4280).
import * as _StreamSettingsConstants from "../modules/go_live/StreamSettingsConstants";
import { ApplicationStreamPresets } from "../modules/go_live/StreamSettingsConstants";
import { MediaEngineContextTypes } from "../_bundle/Module4250";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
const { ApplicationStreamResolutions, ApplicationStreamFPS } = _StreamSettingsConstants;
let PRESET_VIDEO = ApplicationStreamPresets.PRESET_VIDEO;
const RESOLUTION_720 = ApplicationStreamResolutions.RESOLUTION_720;
const FPS_30 = ApplicationStreamFPS.FPS_30;
let soundshareEnabled = true;
class ApplicationStreamingSettingsStore extends Module589.PersistedStore {
static displayName = "ApplicationStreamingSettingsStore";
static persistKey = "ApplicationStreamingSettingStore";
initialize(a0) {
if (a0 != null) {
let preset = a0.preset;
if (preset == null) {
preset = ApplicationStreamPresets.PRESET_VIDEO;
}
PRESET_VIDEO = preset;
RESOLUTION_720 = a0.resolution;
FPS_30 = a0.fps;
let soundshareEnabled2 = a0.soundshareEnabled;
if (soundshareEnabled2 == null) {
soundshareEnabled2 = true;
}
soundshareEnabled = soundshareEnabled2;
}
}
getState() {
return {
preset: PRESET_VIDEO,
resolution: RESOLUTION_720,
fps: FPS_30,
soundshareEnabled
};
}
}
const applicationStreamingSettingsStore = new ApplicationStreamingSettingsStore(Dispatcher, {
MEDIA_ENGINE_SET_GO_LIVE_SOURCE: function handleSetGoLiveSource({ settings }) {
if (settings?.context === MediaEngineContextTypes.STREAM && settings?.qualityOptions != null) {
const r10 = PRESET_VIDEO;
const preset = settings.qualityOptions.preset;
let r13 = false;
if (r10 !== preset) {
PRESET_VIDEO = settings.qualityOptions.preset;
r13 = true;
}
if (RESOLUTION_720 !== settings.qualityOptions.resolution) {
RESOLUTION_720 = settings.qualityOptions.resolution;
r13 = true;
}
if (FPS_30 !== settings.qualityOptions.frameRate) {
FPS_30 = settings.qualityOptions.frameRate;
r13 = true;
}
return r13;
}
return false;
},
STREAM_UPDATE_SETTINGS: function handleUpdateSettings({ preset, resolution, frameRate, soundshareEnabled: soundshareEnabled2 }) {
const r1 = preset != null && preset !== PRESET_VIDEO;
let r0 = false;
if (r1) {
PRESET_VIDEO = preset;
r0 = true;
}
if (resolution != null && resolution !== RESOLUTION_720) {
RESOLUTION_720 = resolution;
r0 = true;
}
if (frameRate != null && frameRate !== FPS_30) {
FPS_30 = frameRate;
r0 = true;
}
if (soundshareEnabled2 != null && soundshareEnabled2 !== soundshareEnabled) {
soundshareEnabled = soundshareEnabled2;
r0 = true;
}
return r0;
}
});
export default applicationStreamingSettingsStore;
+675
View File
@@ -0,0 +1,675 @@
// Metro module 4208 (f4209).
import GameConsoleStore from "../modules/game_console/GameConsoleStore";
import RunningGameStore_native from "../modules/game_detection/RunningGameStore.native";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import GuildStore from "./GuildStore";
import MediaEngineStore from "./MediaEngineStore";
import PermissionStore from "./PermissionStore";
import RTCConnectionStore from "./RTCConnectionStore";
import SelectedChannelStore from "./SelectedChannelStore";
import VoiceStateStore from "./VoiceStateStore";
import { ApplicationStreamDeleteReasons, ApplicationStreamStates, BasicPermissions, NULL_STRING_GUILD_ID, RTCConnectionStates } from "../Constants";
import { StreamTypes } from "../modules/go_live/Constants";
import Durations from "../utils/Durations";
import { decodeStreamKey, encodeStreamKey, isStreamKey } from "../modules/go_live/utils/StreamKeyUtils";
import windowSourceMatches from "../modules/go_live/utils/windowSourceMatches";
import getTitleFromPickedStreamContent from "../modules/go_live/utils/getTitleFromPickedStreamContent";
import { canWatchStream } from "../modules/go_live/utils/StreamPermissionUtils";
import Module589 from "../_bundle/Module589";
import canSpectate from "../modules/go_live/utils/canSpectate";
import Dispatcher from "../Dispatcher";
let c2428_3, streamsByUserAndGuild, rtcStreams, streamerActiveStreamMetadatas, c2428_7, id, selfStreamParticipantsHidden, intent, c2428_27, pid, gameForContent;
const reset = function reset() {
c2428_3 = new Map();
streamsByUserAndGuild = {};
rtcStreams = {};
streamerActiveStreamMetadatas = {};
c2428_7 = new Map();
};
const handleStreamUpdate = function handleStreamUpdate({ streamKey, region, viewerIds, paused }) {
const r15 = c2428_7.get(streamKey);
const r16 = r15 == null || Date.now() - r15 < c2428_27;
const r21 = r16 ? !r16 : c2428_7.delete(streamKey);
c2428_3.set(streamKey, {
...decodeStreamKey(streamKey),
state: paused ? ApplicationStreamStates.PAUSED : ApplicationStreamStates.ACTIVE
});
rtcStreams[streamKey] = {
streamKey,
region,
viewerIds
};
};
id = null;
selfStreamParticipantsHidden = {};
intent = null;
c2428_27 = 10 * Durations.Millis.SECOND;
c2428_3 = new Map();
streamsByUserAndGuild = {};
rtcStreams = {};
streamerActiveStreamMetadatas = {};
c2428_7 = new Map();
pid = void 0;
gameForContent = void 0;
class ApplicationStreamingStore extends Module589.PersistedStore {
static displayName = "ApplicationStreamingStore";
static persistKey = "ApplicationStreamingStore";
initialize(a0) {
this.syncWith([PermissionStore], () => true);
this.waitFor(AuthenticationStore, ChannelStore, PermissionStore, RTCConnectionStore, RunningGameStore_native, SelectedChannelStore);
if (a0?.selfStreamParticipantsHidden !== void 0) {
Object.assign(selfStreamParticipantsHidden, a0?.selfStreamParticipantsHidden);
}
}
getState() {
return {
selfStreamParticipantsHidden
};
}
isSelfStreamHidden(a0) {
let r4 = selfStreamParticipantsHidden[a0];
if (r4 == null) {
r4 = false;
}
return r4;
}
getLastActiveStream() {
const canSpectate2 = canSpectate(MediaEngineStore);
let r11 = null;
if (canSpectate2) {
let r18 = Array.from(c2428_3.values()).pop();
if (r18 == null) {
r18 = null;
}
r11 = r18;
}
return r11;
}
getAllActiveStreams() {
return canSpectate(MediaEngineStore) ? Array.from(c2428_3.values()) : [];
}
getAllActiveStreamsForChannel(c13982_0) {
return canSpectate(MediaEngineStore) ? Array.from(c2428_3.values()).filter((item) => item.channelId === c13982_0) : [];
}
getActiveStreamForStreamKey(a0) {
const canSpectate2 = canSpectate(MediaEngineStore);
let r10 = null;
if (canSpectate2) {
let r13 = c2428_3.get(a0);
if (r13 == null) {
r13 = null;
}
r10 = r13;
}
return r10;
}
getActiveStreamForApplicationStream(a0) {
if (canSpectate(MediaEngineStore) && a0 != null) {
let r17 = this.getActiveStreamForStreamKey(encodeStreamKey(a0));
if (r17 == null) {
r17 = null;
}
return r17;
}
return null;
}
getCurrentUserActiveStream() {
const channel = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId());
return channel != null ? this.getActiveStreamForUser(AuthenticationStore.getId(), channel.getGuildId()) : null;
}
isStreamMarkedFull(a0) {
return c2428_7.has(a0);
}
getActiveStreamForUser(a0, a1) {
let r11;
const streamForUser = this.getStreamForUser(a0, a1);
if (streamForUser != null) {
r11 = this.getActiveStreamForApplicationStream(streamForUser);
} else {
r11 = this.getAllActiveStreams().find((item) => item.ownerId === a0);
if (r11 == null) {
r11 = null;
}
}
return r11;
}
getStreamerActiveStreamMetadata() {
const channel = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId());
if (channel == null) {
return null;
}
const activeStreamForUser = this.getActiveStreamForUser(AuthenticationStore.getId(), channel.getGuildId());
const r1 = activeStreamForUser == null;
let r17 = null;
if (!r1) {
let r26 = streamerActiveStreamMetadatas[encodeStreamKey(activeStreamForUser)];
if (r26 == null) {
r26 = null;
}
r17 = r26;
}
return r17;
}
getStreamerActiveStreamMetadataForStream(a0) {
let r4 = streamerActiveStreamMetadatas[a0];
if (r4 == null) {
r4 = null;
}
return r4;
}
getIsActiveStreamPreviewDisabled(a0) {
let r6 = streamerActiveStreamMetadatas[a0]?.previewDisabled;
if (r6 == null) {
r6 = false;
}
return r6;
}
getAnyStreamForUser(a0) {
if (canSpectate(MediaEngineStore)) {
const r6 = streamsByUserAndGuild[a0];
const r1 = r6 == null;
let r14 = null;
if (!r1) {
let r20 = Object.values(r6).find((item) => {
const streamType = item.streamType;
const basicChannel = ChannelStore.getBasicChannel(item.channelId);
const r18 = streamType === StreamTypes.CALL || basicChannel != null && PermissionStore.canBasicChannel(BasicPermissions.VIEW_CHANNEL, basicChannel);
let r22 = true;
if (!r18) {
const basicChannel2 = ChannelStore.getBasicChannel(item.channelId);
r22 = basicChannel2 != null && canWatchStream(basicChannel2, VoiceStateStore, GuildStore, PermissionStore, GameConsoleStore)[0];
}
return r22;
});
if (r20 == null) {
r20 = null;
}
r14 = r20;
}
return r14;
}
return null;
}
getAnyDiscoverableStreamForUser(a0) {
if (canSpectate(MediaEngineStore)) {
const r6 = streamsByUserAndGuild[a0];
const r1 = r6 == null;
let r14 = null;
if (!r1) {
let r20 = Object.values(r6).find((item) => {
const streamType = item.streamType;
const basicChannel = ChannelStore.getBasicChannel(item.channelId);
const r19 = streamType === StreamTypes.CALL || basicChannel != null && PermissionStore.canBasicChannel(BasicPermissions.VIEW_CHANNEL, basicChannel);
let r23 = true;
if (!r19) {
const basicChannel2 = ChannelStore.getBasicChannel(item.channelId);
r23 = basicChannel2 != null && canWatchStream(basicChannel2, VoiceStateStore, GuildStore, PermissionStore, GameConsoleStore)[0];
}
if (r23) {
r23 = item.discoverable !== false;
}
return r23;
});
if (r20 == null) {
r20 = null;
}
r14 = r20;
}
return r14;
}
return null;
}
getStreamForUser(a0, a1) {
if (canSpectate(MediaEngineStore)) {
const r5 = streamsByUserAndGuild[a0];
const r25 = r5 == null ? void 0 : r5[a1 == null ? NULL_STRING_GUILD_ID : a1];
const r27 = r25 == null;
let r28 = null;
if (!r27) {
const streamType = r25.streamType;
const basicChannel = ChannelStore.getBasicChannel(r25.channelId);
const r32 = streamType === StreamTypes.CALL || basicChannel != null && PermissionStore.canBasicChannel(BasicPermissions.VIEW_CHANNEL, basicChannel);
let r36 = true;
if (!r32) {
const basicChannel2 = ChannelStore.getBasicChannel(r25.channelId);
r36 = basicChannel2 != null && canWatchStream(basicChannel2, VoiceStateStore, GuildStore, PermissionStore, GameConsoleStore)[0];
}
r28 = r36 ? r25 : null;
}
return r28;
}
return null;
}
getRTCStream(a0) {
const canSpectate2 = canSpectate(MediaEngineStore);
let r9 = null;
if (canSpectate2) {
let r12 = rtcStreams[a0];
if (r12 == null) {
r12 = null;
}
r9 = r12;
}
return r9;
}
getAllApplicationStreams() {
let r22;
const canSpectate2 = canSpectate(MediaEngineStore);
const r8 = [];
if (canSpectate2) {
for (const key in streamsByUserAndGuild) {
const r9 = streamsByUserAndGuild[key];
for (const key2 in r9) {
r8.push(streamsByUserAndGuild[key][key2]);
}
}
r22 = r8.filter((item) => {
let r1 = item != null;
if (r1) {
const streamType = item.streamType;
const basicChannel = ChannelStore.getBasicChannel(item.channelId);
r1 = streamType === StreamTypes.CALL || basicChannel != null && PermissionStore.canBasicChannel(BasicPermissions.VIEW_CHANNEL, basicChannel);
}
return r1;
});
} else {
r22 = r8;
}
return r22;
}
getAllApplicationStreamsForChannel(c13984_0) {
let r24;
const canSpectate2 = canSpectate(MediaEngineStore);
const r8 = [];
if (canSpectate2) {
for (const key in streamsByUserAndGuild) {
const r9 = streamsByUserAndGuild[key];
for (const key2 in r9) {
r8.push(streamsByUserAndGuild[key][key2]);
}
}
r24 = r8.filter((item) => {
let r2 = item != null && item.channelId === c13984_0;
if (r2) {
const streamType = item.streamType;
const basicChannel = ChannelStore.getBasicChannel(item.channelId);
r2 = streamType === StreamTypes.CALL || basicChannel != null && PermissionStore.canBasicChannel(BasicPermissions.VIEW_CHANNEL, basicChannel);
}
return r2;
});
} else {
r24 = r8;
}
return r24;
}
getViewerIds(a0) {
if (canSpectate(MediaEngineStore)) {
const r11 = typeof a0 !== "string" ? encodeStreamKey(a0) : a0;
const r17 = r11 != null ? rtcStreams[r11] : null;
return r17 != null ? r17.viewerIds : [];
}
return [];
}
getCurrentAppIntent() {
return intent;
}
getStreamingState() {
let r17;
const canSpectate2 = canSpectate(MediaEngineStore);
const r12 = {
activeStreams: null,
streamsByUserAndGuild: null,
rtcStreams: null,
streamerActiveStreamMetadatas: null
};
if (canSpectate2) {
r12.activeStreams = Array.from(c2428_3.entries());
r12.streamsByUserAndGuild = streamsByUserAndGuild;
r12.rtcStreams = rtcStreams;
r12.streamerActiveStreamMetadatas = streamerActiveStreamMetadatas;
r17 = r12;
} else {
r12.activeStreams = [];
r12.streamsByUserAndGuild = {};
r12.rtcStreams = {};
r12.streamerActiveStreamMetadatas = {};
r17 = r12;
}
return r17;
}
}
const applicationStreamingStore = new ApplicationStreamingStore(Dispatcher, {
MEDIA_ENGINE_SET_GO_LIVE_SOURCE: function handleSetGoLiveSource({ settings, endReason, errorCode }) {
let r3;
if (settings?.desktopSettings == null && settings?.cameraSettings == null) {
if (errorCode == null) {
return false;
}
let r2 = false;
let r23 = false;
for (const key in streamerActiveStreamMetadatas) {
r3 = r2;
r23 = r3;
const r17 = c2428_3.get(key);
r2 = r3;
if (r17 != null) {
c2428_3.set(key, {
...r17,
state: ApplicationStreamStates.FAILED,
endReason,
errorCode
});
r2 = true;
}
}
r3 = r2;
r23 = r3;
return r23;
}
return false;
},
NATIVE_SCREEN_SHARE_PICKER_UPDATE: function handleNativePickerUpdate({ existing, content }) {
let r3;
if (content == null) {
return false;
}
gameForContent = (function getGameForContent(a0) {
for (const application of a0.applications) {
const gameForPID = RunningGameStore_native.getGameForPID(application.id);
if (gameForPID == null) {
continue;
}
return gameForPID;
}
for (const window2 of a0.windows) {
const r40 = window2;
if (window2.owningApplication == null) {
continue;
}
const gameForPID2 = RunningGameStore_native.getGameForPID(r40.owningApplication.id);
if (gameForPID2 == null) {
continue;
}
return gameForPID2;
}
})(content);
pid = gameForContent?.pid;
if (existing) {
const titleFromPickedStreamContent = getTitleFromPickedStreamContent(content);
const r13 = {
pid,
id: gameForContent?.id
};
if (titleFromPickedStreamContent != null) {
r13.sourceName = titleFromPickedStreamContent;
}
let r2 = false;
let r35 = false;
for (const key in streamerActiveStreamMetadatas) {
r3 = r2;
r35 = r3;
const r16 = streamerActiveStreamMetadatas[key];
const r6 = r16 == null;
let r39 = void 0;
if (!r6) {
const sourceId2 = r16.sourceId;
r39 = sourceId2 == null ? void 0 : sourceId2.startsWith("prepicked:");
}
r2 = r3;
if (r39) {
streamerActiveStreamMetadatas[key] = {
...streamerActiveStreamMetadatas[key],
...r13
};
r2 = true;
}
}
r3 = r2;
r35 = r3;
return r35;
}
return false;
},
OVERLAY_INITIALIZE: function handleOverlayInitialize({ applicationStreamState }) {
streamsByUserAndGuild = applicationStreamState.streamsByUserAndGuild;
c2428_3 = new Map(applicationStreamState.activeStreams);
rtcStreams = applicationStreamState.rtcStreams;
streamerActiveStreamMetadatas = applicationStreamState.streamerActiveStreamMetadatas;
c2428_7 = new Map();
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((acc, { userId: userId2, guildId: guildId3, channelId: channelId2, sessionId, selfStream, discoverable }) => {
if (selfStream && channelId2 != null) {
const r39 = {
streamType: guildId3 != null ? StreamTypes.GUILD : StreamTypes.CALL,
ownerId: userId2,
guildId: guildId3,
channelId: channelId2,
discoverable
};
if (streamsByUserAndGuild[r39.ownerId] == null) {
streamsByUserAndGuild[r39.ownerId] = {};
}
const r48 = streamsByUserAndGuild[r39.ownerId];
let guildId4 = r39.guildId;
if (guildId4 == null) {
guildId4 = NULL_STRING_GUILD_ID;
}
r48[guildId4] = r39;
return true;
}
const id2 = AuthenticationStore.getId();
const sessionId2 = AuthenticationStore.getSessionId();
if (userId2 === id2 && sessionId !== sessionId2 && RTCConnectionStore.getChannelId() != null) {
return acc;
}
const userId = userId2;
const guildId2 = guildId3;
let c24974_2 = false;
c2428_7.forEach((item, index) => {
const r12 = decodeStreamKey(index);
let r0 = r12.ownerId === userId;
if (r0) {
let guildId3 = r12.guildId;
if (guildId3 == null) {
guildId3 = null;
}
let r15 = guildId2;
if (guildId2 == null) {
r15 = null;
}
r0 = guildId3 === r15;
}
if (r0) {
c24974_2 = c2428_7.delete(index) || c24974_2;
}
});
const r28 = guildId2 == null ? NULL_STRING_GUILD_ID : guildId2;
const r30 = streamsByUserAndGuild[userId];
let r32 = (r30 == null ? void 0 : r30[r28]) != null;
if (r32) {
delete streamsByUserAndGuild[userId][r28];
r32 = true;
}
if (!r32) {
r32 = c24974_2;
}
if (!r32) {
r32 = acc;
}
return r32;
}, false);
},
STREAM_WATCH: function handleStreamWatch({ streamKey }) {
const r15 = decodeStreamKey(streamKey);
c2428_3.delete(streamKey);
c2428_3.set(streamKey, {
...r15,
state: ApplicationStreamStates.CONNECTING
});
if (r15.ownerId === AuthenticationStore.getId()) {
selfStreamParticipantsHidden[r15.channelId] = false;
}
},
STREAM_START: function handleStreamStart(a0) {
const { streamType, guildId: guildId3, channelId: channelId2 } = a0;
let pid2 = a0.pid;
const { sourceName, sourceId, sourceIcon, previewDisabled } = a0;
const r23 = encodeStreamKey({
streamType,
guildId: guildId3,
channelId: channelId2,
ownerId: AuthenticationStore.getId()
});
if ((sourceId == null ? void 0 : sourceId.startsWith("prepicked:")) && pid2 == null) {
pid2 = pid;
}
let r33 = (sourceId == null ? void 0 : sourceId.startsWith("prepicked:")) && gameForContent != null ? gameForContent : pid2 != null ? RunningGameStore_native.getGameForPID(pid2) : sourceId != null ? RunningGameStore_native.getRunningGames().find((item) => windowSourceMatches(sourceId, item.windowHandle)) : null;
if (r33 == null) {
r33 = null;
}
streamerActiveStreamMetadatas[r23] = {
id: r33?.id,
pid: pid2,
sourceName,
previewDisabled,
sourceIcon,
sourceId
};
c2428_3.delete(r23);
c2428_3.set(r23, {
streamType,
guildId: guildId3,
channelId: channelId2,
ownerId: AuthenticationStore.getId(),
state: ApplicationStreamStates.CONNECTING
});
},
STREAM_STOP: function handleStreamStop(a0) {
streamerActiveStreamMetadatas[a0.streamKey] = null;
},
STREAM_CREATE: handleStreamUpdate,
STREAM_UPDATE: handleStreamUpdate,
STREAM_TIMED_OUT: function handleStreamTimedOut({ streamKey }) {
const r6 = c2428_3.get(streamKey);
if (r6 == null) {
return false;
}
c2428_3.set(streamKey, {
...r6,
state: ApplicationStreamStates.FAILED
});
},
STREAM_DELETE: function handleStreamDelete({ streamKey, unavailable, reason }) {
let guildId;
guildId = void 0;
delete rtcStreams[streamKey];
const STREAM_FULL = ApplicationStreamDeleteReasons.STREAM_FULL;
let r18 = false;
if (reason === STREAM_FULL) {
r18 = !c2428_7.has(streamKey);
c2428_7.set(streamKey, Date.now());
}
const r28 = c2428_3.get(streamKey);
if (r28 == null) {
return r18;
}
let ENDED = ApplicationStreamStates.ENDED;
if (unavailable) {
ENDED = ApplicationStreamStates.RECONNECTING;
} else if (reason === ApplicationStreamDeleteReasons.UNAUTHORIZED) {
ENDED = ApplicationStreamStates.FAILED;
} else if (reason === ApplicationStreamDeleteReasons.SAFETY_GUILD_RATE_LIMITED) {
guildId = decodeStreamKey(streamKey).guildId;
import("../modules/guild_limited_access/openGuildLimitedAccessInfoModal.native").then((result) => {
(0, result.default)(guildId);
});
ENDED = ApplicationStreamStates.ENDED;
} else if (r28.state === ApplicationStreamStates.FAILED && reason === ApplicationStreamDeleteReasons.USER_REQUESTED) {
ENDED = ApplicationStreamStates.FAILED;
}
c2428_3.set(streamKey, {
...r28,
state: ENDED
});
if (ENDED === ApplicationStreamStates.ENDED && id !== streamKey) {
c2428_3.delete(streamKey);
}
},
STREAM_CLOSE: function handleStreamClose(a0) {
c2428_3.delete(a0.streamKey);
},
STREAM_UPDATE_SELF_HIDDEN: function handleUpdateSelfStreamHidden({ channelId: channelId2, selfStreamHidden }) {
let r15 = isStreamKey(id);
if (r15) {
r15 = id == null ? void 0 : id.includes(AuthenticationStore.getId());
}
if (r15) {
r15 = selfStreamParticipantsHidden[channelId2] === false;
}
if (r15) {
r15 = selfStreamHidden === true;
}
if (r15) {
id = null;
}
selfStreamParticipantsHidden[channelId2] = selfStreamHidden;
},
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelectForFullStreams({ channelId }) {
if (channelId == null) {
return false;
}
let c13987_1 = false;
c2428_7.forEach((item, index) => {
if (decodeStreamKey(index).channelId !== channelId) {
c13987_1 = c2428_7.delete(index) || c13987_1;
}
});
return c13987_1;
},
SET_STREAM_APP_INTENT: function handleStreamSetAppIntent(a0) {
intent = a0.intent;
},
RTC_CONNECTION_STATE: function handleRTCConnectionState({ streamKey, state }) {
if (streamKey == null) {
return false;
}
const r6 = c2428_3.get(streamKey);
if (r6 != null && r6.state !== ApplicationStreamStates.ENDED) {
if (r6.state === ApplicationStreamStates.FAILED && r6.ownerId === AuthenticationStore.getId()) {
return false;
}
let state2 = r6.state;
if (RTCConnectionStates.DISCONNECTED === state) {
state2 = ApplicationStreamStates.RECONNECTING;
} else if (RTCConnectionStates.RTC_CONNECTED === state) {
state2 = ApplicationStreamStates.ACTIVE;
}
if (state2 === r6.state) {
return false;
}
c2428_3.set(streamKey, {
...r6,
state: state2
});
return void 0;
}
return false;
},
CHANNEL_RTC_SELECT_PARTICIPANT: function handleStreamCloseAll({ id: id2, channelId: channelId2 }) {
id = id2;
Array.from(c2428_3.values()).forEach((item) => {
if (encodeStreamKey(item) !== id && item.state === ApplicationStreamStates.ENDED) {
c2428_3.delete(encodeStreamKey(item));
}
});
if (id2 != null && isStreamKey(id2) && id2.includes(AuthenticationStore.getId())) {
selfStreamParticipantsHidden[channelId2] = false;
}
},
CONNECTION_OPEN: reset,
CONNECTION_CLOSED: reset,
LOGOUT: reset
});
export default applicationStreamingStore;
+83
View File
@@ -0,0 +1,83 @@
// Metro module 11653 (f11654).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c7966_0, endsAt, appliedGuildBoosts, c7966_3, c7966_4, error, error2;
const handleModifyingAppliedBoostStart = function handleModifyingAppliedBoostStart() {
c7966_4 = true;
};
c7966_0 = {};
endsAt = null;
appliedGuildBoosts = [];
c7966_3 = false;
c7966_4 = false;
error = null;
error2 = null;
class AppliedGuildBoostStore extends Module589.Store {
static displayName = "AppliedGuildBoostStore";
getAppliedGuildBoostsForGuild(a0) {
return c7966_0[a0] != null ? c7966_0[a0].subscriptions : null;
}
getLastFetchedAtForGuild(a0) {
return c7966_0[a0] != null ? c7966_0[a0].lastFetchedAt : null;
}
getCurrentUserAppliedBoosts() {
return appliedGuildBoosts;
}
getAppliedGuildBoost(c19055_0) {
return appliedGuildBoosts.find((appliedGuildBoost) => appliedGuildBoost.id === c19055_0);
}
get isModifyingAppliedBoost() {
return c7966_4;
}
get applyBoostError() {
return error;
}
get unapplyBoostError() {
return error2;
}
get cooldownEndsAt() {
return endsAt;
}
get isFetchingCurrentUserAppliedBoosts() {
return c7966_3;
}
}
const appliedGuildBoostStore = new AppliedGuildBoostStore(Dispatcher, {
GUILD_APPLIED_BOOSTS_FETCH_SUCCESS: function handleAppliedBoostsForGuildFetchSuccess(a0) {
c7966_0[a0.guildId] = {
subscriptions: a0.appliedBoosts,
lastFetchedAt: Date.now()
};
},
USER_APPLIED_BOOSTS_FETCH_SUCCESS: function handleAppliedBoostsForuserFetchSuccess({ appliedGuildBoosts: appliedGuildBoosts2 }) {
c7966_3 = false;
appliedGuildBoosts = appliedGuildBoosts2;
},
APPLIED_BOOSTS_COOLDOWN_FETCH_SUCCESS: function handleAppliedBoostCooldownFetch(a0) {
endsAt = a0.endsAt;
},
GUILD_UNAPPLY_BOOST_START: handleModifyingAppliedBoostStart,
GUILD_APPLY_BOOST_START: handleModifyingAppliedBoostStart,
GUILD_APPLY_BOOST_SUCCESS: function handleApplyBoostSuccess({ appliedGuildBoost }) {
let c19056_0 = new Set(appliedGuildBoost.map((item) => item.id));
appliedGuildBoosts = [...appliedGuildBoost, ...appliedGuildBoosts.filter((appliedGuildBoost) => !c19056_0.has(appliedGuildBoost.id))];
error = null;
c7966_4 = false;
},
GUILD_APPLY_BOOST_FAIL: function handleApplyBoostFail({ error: error3 }) {
c7966_4 = false;
error = error3;
},
GUILD_UNAPPLY_BOOST_SUCCESS: function handleUnapplyBoostSuccess({ boostId }) {
appliedGuildBoosts = appliedGuildBoosts.filter((appliedGuildBoost) => appliedGuildBoost.id !== boostId);
c7966_4 = false;
},
GUILD_UNAPPLY_BOOST_FAIL: function handleUnapplyBoostFail({ error: error3 }) {
c7966_4 = false;
error2 = error3;
},
USER_APPLIED_BOOSTS_FETCH_START: function handleUserAppliedBoostsFetchStart() {
c7966_3 = true;
}
});
export default appliedGuildBoostStore;
+679
View File
@@ -0,0 +1,679 @@
// Metro module 1218 (f1219).
import BrowserHandoffStore_native from "./BrowserHandoffStore.native";
import MobileCacheSnapshotStore from "./MobileCacheSnapshotStore";
import { AnalyticEvents, LoginStates, Platforms, Routes, TOKEN_KEY } from "../Constants";
import { EXISTING_USER_AGE_GATE_MODAL_KEY, NEW_USER_AGE_GATE_MODAL_KEY } from "../modules/age_gate/AgeGateConstants";
import Logger from "../modules/debug/Logger";
import * as _setSecondaryToken from "../_bundle/setSecondaryToken";
import { removeAnalyticsToken, removeToken, setAnalyticsToken, setToken } from "../_bundle/setSecondaryToken";
import { Storage } from "../_bundle/Module595";
import { transitionTo, isValidFingerprintRoute, getFingerprintLocation } from "../modules/routing/router_utils";
import AnalyticsUtils from "../utils/AnalyticsUtils";
import { fetchExperiments } from "../modules/experiments/fetchExperiments";
import Dispatcher, { DispatchBand } from "../Dispatcher";
import { onExperimentsLoaded } from "../modules/app_startup/awaitExperiments";
import { getAuthenticationErrorsFromV6OrEarlierAPIError, getAuthenticationErrorsFromAPIError } from "../modules/auth/getAuthenticationErrorsFromAPIError";
import APIError from "../errors/APIError";
import { extractId } from "../_bundle/Module513";
import TrackingConsentUtils from "../modules/tracking/TrackingConsentUtils";
import SentryUtils_native from "../utils/SentryUtils.native";
import isStaffFromRawUser from "../modules/user/isStaffFromRawUser";
import Module589 from "../_bundle/Module589";
import { fetchInstallationExperiments } from "../modules/experiments/apex/ApexActionCreators";
import { setClientState } from "../modules/cache/ClientStateStoreStorage.native";
import * as _AuthenticationUtils from "../utils/AuthenticationUtils";
import { AuthenticatorType } from "../flow/Server";
let credentials, loginInstanceId, c1024_13, c1024_14, c1024_15, c1024_16, id, sessionId, authSessionIdHash, staticAuthSessionId, fingerprint, fingerprint2, installation, analyticsToken, NONE, c1024_26, authenticator_types, ticket, sms, challenge, totp, backup, c1024_33, suspendedUserToken, c1024_35, c1024_36, c1024_37, handleLogout, $mk68489 = function() {
return ({ body }) => {
const { fingerprint: fingerprint3, assignments, guild_experiments, installation: installation2 } = body;
if (installation2 != null && installation2.length > 0) {
Dispatcher.dispatch({
type: "INSTALLATION_ID",
installation: installation2
});
}
if (fingerprint3) {
Dispatcher.dispatch({
type: "FINGERPRINT",
fingerprint: fingerprint3
});
}
Dispatcher.dispatch({
type: "EXPERIMENTS_FETCH_SUCCESS",
fingerprint: fingerprint3,
experiments: assignments,
guildExperiments: guild_experiments
});
c1024_33 = null;
onExperimentsLoaded();
};
}, $mk68490 = function() {
return () => {
c1024_33 = null;
Dispatcher.dispatch({
type: "EXPERIMENTS_FETCH_FAILURE"
});
};
}, $mk68491 = function() {
return () => {
transitionTo(Routes.REGISTER);
};
};
const fetchFingerprint = function fetchFingerprint(r2 = true) {
let r74;
fingerprint = Storage.get(c1024_14);
let r21 = Storage.get(c1024_15);
if (!(r21 != null && r21.length > 0)) {
const r27 = Storage.get("analytics_installation");
const r4 = r27 != null;
let r28 = null;
if (r4) {
const r31 = r27.length > 0;
r28 = null;
if (r31) {
Storage.set(c1024_15, r27);
r28 = r27;
}
}
r21 = r28;
}
installation = r21;
if (c1024_33 != null) {
return c1024_33;
}
const r42 = fingerprint != null ? fingerprint : _setSecondaryToken.getToken();
L24: {
L23: {
if (isValidFingerprintRoute()) {
if (!r2 && r42 != null) {
break L23;
}
if (!BrowserHandoffStore_native.isHandoffAvailable()) {
const headers = {};
const superPropertiesBase64 = AnalyticsUtils.getSuperPropertiesBase64();
if (superPropertiesBase64 != null) {
headers["X-Super-Properties"] = superPropertiesBase64;
}
if (fingerprint != null) {
headers["X-Fingerprint"] = fingerprint;
}
if (installation != null) {
headers["X-Installation-ID"] = installation;
}
const r70 = fetchExperiments({
withGuildExperiments: true,
headers,
context: {
location: getFingerprintLocation()
}
});
const r72 = $mk68490();
r74 = r70.then($mk68489(), r72);
c1024_33 = r74;
break L24;
}
}
}
r74 = Promise.resolve();
}
return r74;
};
handleLogout = function handleLogout(a0) {
c1024_13.verbose("handleLogout called.", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
c1024_13.verbose("removeAuthToken called.", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
removeAnalyticsToken();
const r47 = removeToken();
let r49 = a0?.isSwitchingAccount;
if (r49 == null) {
r49 = false;
}
if (!r49) {
if (r47) {
fingerprint2 = fingerprint;
fingerprint = null;
Storage.remove(c1024_14);
}
fetchFingerprint();
}
Module589.PersistedStore.clearAll({
omit: ["InstallationManagerStore", "AgeGateStore", "NativePermissionsStore", "MultiAccountStore", "DraftStore", "OverlayStoreV2", "StreamerModeStore", "LoginRequiredActionStore", "LayoutStore", "OverlaySettingsStore", "ApexExperimentStore"],
type: a0?.isSwitchingAccount ? "user-data-only" : "all"
});
Module589.Store.removeAllConditionalListeners();
MobileCacheSnapshotStore.clearAll();
SentryUtils_native.clearUser();
Storage.remove(c1024_16);
id = null;
sessionId = null;
NONE = a0?.isSwitchingAccount ? LoginStates.LOGGING_IN : LoginStates.NONE;
ticket = "";
challenge = null;
sms = false;
c1024_35 = false;
c1024_36 = false;
const r94 = [];
if (totp) {
r94.push({
type: "totp"
});
}
if (backup) {
r94.push({
type: "backup"
});
}
if (sms) {
r94.push({
type: "sms"
});
}
c1024_37 = r94;
};
EXISTING_USER_AGE_GATE_MODAL_KEY;
NEW_USER_AGE_GATE_MODAL_KEY;
c1024_13 = new Logger("AuthenticationStore");
c1024_14 = "fingerprint";
c1024_15 = "analytics_installation";
c1024_16 = "user_id_cache";
id = null;
sessionId = null;
authSessionIdHash = null;
staticAuthSessionId = null;
fingerprint = null;
fingerprint2 = null;
installation = null;
analyticsToken = null;
NONE = LoginStates.NONE;
c1024_26 = false;
authenticator_types = [];
ticket = "";
sms = false;
challenge = null;
totp = false;
backup = false;
c1024_33 = null;
suspendedUserToken = null;
c1024_35 = false;
c1024_36 = false;
c1024_37 = [];
class AuthenticationStore extends Module589.Store {
static displayName = "AuthenticationStore";
initialize() {
id = Storage.get(c1024_16);
let r19 = Storage.get(c1024_15);
if (!(r19 != null && r19.length > 0)) {
const r25 = Storage.get("analytics_installation");
const r3 = r25 != null;
let r26 = null;
if (r3) {
const r29 = r25.length > 0;
r26 = null;
if (r29) {
Storage.set(c1024_15, r25);
r26 = r25;
}
}
r19 = r26;
}
installation = r19;
if (_setSecondaryToken.getToken() == null) {
const r41 = installation == null || installation.length === 0;
const r47 = fetchFingerprint();
if (r41) {
const fireApex = function fireApex() {
fetchInstallationExperiments(null);
};
r47.then(fireApex, fireApex);
}
}
this.addChangeListener(() => setClientState(id));
}
getLoginStatus() {
return NONE;
}
getId() {
return id;
}
getSessionId() {
return sessionId;
}
getAuthSessionIdHash() {
return authSessionIdHash;
}
getStaticAuthSessionId() {
return staticAuthSessionId;
}
getToken() {
return _AuthenticationUtils.getToken();
}
isAuthenticated() {
return _AuthenticationUtils.isAuthenticated();
}
getFingerprint() {
return fingerprint;
}
getInstallationForTracking() {
return TrackingConsentUtils.canUseInstallationId() ? installation : null;
}
getAnalyticsToken() {
let r1 = analyticsToken;
if (r1 == null) {
r1 = _setSecondaryToken.getAnalyticsToken();
}
return r1;
}
getMFATicket() {
return ticket;
}
getMFAMethods() {
return c1024_37;
}
getLoginInstanceId() {
return loginInstanceId;
}
hasTOTPEnabled() {
return authenticator_types.includes(AuthenticatorType.TOTP);
}
getCredentials() {
if (credentials == null) {
throw new Error("no credentials");
}
return credentials;
}
allowLogoutRedirect() {
return !c1024_26;
}
getSuspendedUserToken() {
return suspendedUserToken;
}
getIsPasswordlessActive() {
return c1024_35;
}
attemptedPasswordLogin() {
return c1024_36;
}
}
const authenticationStore = new AuthenticationStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen({ user, sessionId: sessionId2, authSessionIdHash: authSessionIdHash2, analyticsToken: analyticsToken2, auth, staticAuthSessionId: staticAuthSessionId2, apexExperiments }) {
c1024_13.verbose("handleConnectionOpen called", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
const { id: id2, username } = user;
let email = user.email;
if (email == null) {
email = void 0;
}
SentryUtils_native.setUser(id2, username, email, isStaffFromRawUser(user));
sessionId = sessionId2;
authSessionIdHash = authSessionIdHash2;
staticAuthSessionId = staticAuthSessionId2;
analyticsToken = analyticsToken2;
setAnalyticsToken(analyticsToken2);
id = user.id;
if (auth !== void 0) {
authenticator_types = auth.authenticator_types;
}
Storage.set(c1024_16, user.id);
const installation2 = apexExperiments?.installation;
L11: {
if (installation2 != null) {
const installation3 = apexExperiments.installation;
if (installation != null && installation.length > 0) {
break L11;
}
installation = installation3;
if (TrackingConsentUtils.canUseInstallationId()) {
Storage.set(c1024_15, installation3);
}
}
}
if (Storage.get(AnalyticEvents.APP_FIRST_LOGIN, true)) {
AnalyticsUtils.track(AnalyticEvents.APP_FIRST_LOGIN, {
platform: Platforms.IOS
});
Storage.set(AnalyticEvents.APP_FIRST_LOGIN, false);
}
},
OVERLAY_INITIALIZE: function handleOverlayInitialize({ user, sessionId: sessionId2, analyticsToken: analyticsToken2, token }) {
const { id: id2, username } = user;
let email = user.email;
if (email == null) {
email = void 0;
}
SentryUtils_native.setUser(id2, username, email, isStaffFromRawUser(user));
sessionId = sessionId2;
analyticsToken = analyticsToken2;
const id3 = user.id;
c1024_13.verbose("setAuthToken called.", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
if (!(id3 != null && id3 === id)) {
removeAnalyticsToken();
}
setToken(token, id3);
if (analyticsToken2 != null) {
analyticsToken = analyticsToken2;
setAnalyticsToken(analyticsToken2);
}
fingerprint2 = fingerprint;
fingerprint = null;
Storage.remove(c1024_14);
id = user.id;
Storage.set(c1024_16, user.id);
},
CONNECTION_CLOSED: function handleConnectionClosed({ code }) {
c1024_13.verbose(`handleConnectionClosed called with code ${code}.`, {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
if (code === 4004) {
if (c1024_26) {
c1024_26 = true;
handleLogout();
Dispatcher.wait($mk68491());
return void 0;
}
AnalyticsUtils.track(AnalyticEvents.APP_USER_DEAUTHENTICATED, {
user_id: Storage.get(c1024_16)
});
handleLogout();
setImmediate(() => transitionTo(Routes.DEFAULT_LOGGED_OUT));
}
},
AUTH_SESSION_CHANGE: function handleAuthSessionChange({ authSessionIdHash: authSessionIdHash2 }) {
if (authSessionIdHash2 != null) {
authSessionIdHash = authSessionIdHash2;
}
},
LOGIN: function handleLogin({ isPasswordAttempt }) {
NONE = LoginStates.LOGGING_IN;
c1024_36 = c1024_36 || isPasswordAttempt === true;
},
LOGIN_SUCCESS: function handleLoginSuccess({ token }) {
NONE = LoginStates.NONE;
c1024_13.verbose("setAuthToken called.", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
removeAnalyticsToken();
setToken(token, void 0);
fingerprint2 = fingerprint;
fingerprint = null;
Storage.remove(c1024_14);
ticket = "";
sms = false;
challenge = null;
loginInstanceId = null;
const r44 = [];
if (totp) {
r44.push({
type: "totp"
});
}
if (backup) {
r44.push({
type: "backup"
});
}
if (sms) {
r44.push({
type: "sms"
});
}
c1024_37 = r44;
c1024_35 = false;
},
LOGIN_FAILURE: function handleLoginFailure({ error }) {
ticket = "";
sms = false;
challenge = null;
loginInstanceId = null;
const r8 = [];
if (totp) {
r8.push({
type: "totp"
});
}
if (backup) {
r8.push({
type: "backup"
});
}
if (sms) {
r8.push({
type: "sms"
});
}
c1024_37 = r8;
NONE = getAuthenticationErrorsFromV6OrEarlierAPIError(error).date_of_birth != null ? LoginStates.LOGIN_AGE_GATE : LoginStates.NONE;
},
LOGIN_MFA_STEP: function handleLoginMFAStep(a0) {
const { ticket: ticket2, sms: sms2 } = a0;
let webauthn = a0.webauthn;
const { backup: backup2, totp: totp2, loginInstanceId: loginInstanceId2 } = a0;
if (ticket2 != null) {
ticket = ticket2;
sms = sms2;
if (webauthn == null) {
webauthn = null;
}
challenge = webauthn;
backup = backup2;
totp = totp2;
loginInstanceId = loginInstanceId2;
const r9 = [];
if (webauthn != null) {
r9.push({
type: "webauthn",
challenge
});
}
if (totp) {
r9.push({
type: "totp"
});
}
if (backup) {
r9.push({
type: "backup"
});
}
if (sms) {
r9.push({
type: "sms"
});
}
c1024_37 = r9;
}
NONE = LoginStates.MFA_STEP;
},
LOGIN_MFA: function handleLoginMFA() {
NONE = LoginStates.LOGGING_IN_MFA;
},
LOGIN_ACCOUNT_SCHEDULED_FOR_DELETION: function handleLoginAccountPendingDeletion(a0) {
NONE = LoginStates.ACCOUNT_SCHEDULED_FOR_DELETION;
credentials = a0.credentials;
},
LOGIN_ACCOUNT_DISABLED: function handleLoginAccountDisabled(a0) {
NONE = LoginStates.ACCOUNT_DISABLED;
credentials = a0.credentials;
},
LOGIN_PASSWORD_RECOVERY_PHONE_VERIFICATION: function handleLoginPasswordRecoveryPhoneVerification(a0) {
NONE = LoginStates.PASSWORD_RECOVERY_PHONE_VERIFICATION;
credentials = a0.credentials;
},
LOGIN_PHONE_IP_AUTHORIZATION_REQUIRED: function handleLoginPhoneIPAuthorizationRequired(a0) {
NONE = LoginStates.PHONE_IP_AUTHORIZATION;
credentials = a0.credentials;
},
LOGIN_RESET: function handleLoginReset({ isMultiAccount }) {
NONE = LoginStates.NONE;
ticket = "";
sms = false;
challenge = null;
loginInstanceId = null;
credentials = null;
if (!isMultiAccount) {
const r15 = [];
if (totp) {
r15.push({
type: "totp"
});
}
if (backup) {
r15.push({
type: "backup"
});
}
if (sms) {
r15.push({
type: "sms"
});
}
c1024_37 = r15;
c1024_13.verbose("removeAuthToken called.", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
removeAnalyticsToken();
removeToken();
fetchFingerprint(false);
}
},
LOGIN_STATUS_RESET: function handleLoginStatusReset() {
NONE = LoginStates.NONE;
},
LOGIN_SUSPENDED_USER: function handleSuspendedUserLogin({ suspendedUserToken: suspendedUserToken2 }) {
c1024_35 = false;
suspendedUserToken = suspendedUserToken2;
setImmediate(() => transitionTo(Routes.ACCOUNT_STANDING));
},
LOGOUT: handleLogout,
FINGERPRINT: function handleFingerprint({ fingerprint: fingerprint3 }) {
if (fingerprint == null) {
if (fingerprint3 != null) {
AnalyticsUtils.track(AnalyticEvents.USER_FINGERPRINT_CHANGED, {
old_fingerprint: fingerprint2 != null ? extractId(fingerprint2) : null,
new_fingerprint: extractId(fingerprint3)
});
fingerprint = fingerprint3;
fingerprint2 = fingerprint3;
Storage.set(c1024_14, fingerprint);
} else {
fetchFingerprint();
}
} else if (fingerprint3 != null && fingerprint !== fingerprint3) {
AnalyticsUtils.track(AnalyticEvents.EXTERNAL_FINGERPRINT_DROPPED, {
fingerprint: extractId(fingerprint),
dropped_fingerprint: extractId(fingerprint3)
});
}
},
INSTALLATION_ID: function handleInstallationId({ installation: installation2 }) {
if (installation != null && installation.length > 0) {
return false;
}
installation = installation2;
if (TrackingConsentUtils.canUseInstallationId()) {
Storage.set(c1024_15, installation2);
}
},
REGISTER_SUCCESS: function handleRegisterSuccess({ token }) {
c1024_13.verbose("setAuthToken called.", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
removeAnalyticsToken();
setToken(token, void 0);
fingerprint2 = fingerprint;
fingerprint = null;
Storage.remove(c1024_14);
},
FORGOT_PASSWORD_REQUEST: function handleForgotPasswordRequest() {
NONE = LoginStates.FORGOT_PASSWORD;
},
FORGOT_PASSWORD_SENT: function handleForgotPasswordSent() {
NONE = LoginStates.NONE;
},
UPDATE_TOKEN: function handleUpdateToken({ token, userId }) {
c1024_13.verbose("handleUpdateToken called", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
c1024_13.verbose("setAuthToken called.", {
tokenManagerHasToken: _setSecondaryToken.getToken() != null,
storageHasToken: Storage.get(TOKEN_KEY) != null
});
if (!(userId != null && userId === id)) {
removeAnalyticsToken();
}
setToken(token, userId);
fingerprint2 = fingerprint;
fingerprint = null;
Storage.remove(c1024_14);
},
EXPERIMENTS_FETCH: ({ withGuildExperiments }) => {
const headers = {};
const superPropertiesBase64 = AnalyticsUtils.getSuperPropertiesBase64();
if (superPropertiesBase64 != null) {
headers["X-Super-Properties"] = superPropertiesBase64;
}
if (fingerprint != null) {
headers["X-Fingerprint"] = fingerprint;
}
if (installation != null) {
headers["X-Installation-ID"] = installation;
}
const r26 = fetchExperiments({
withGuildExperiments,
headers,
context: {
location: getFingerprintLocation()
}
});
const r28 = $mk68490();
c1024_33 = r26.then($mk68489(), r28);
},
CURRENT_USER_UPDATE: function handleUserUpdate({ user }) {
id = user.id;
if (user.authenticator_types !== void 0) {
authenticator_types = user.authenticator_types;
}
Storage.set(c1024_16, user.id);
},
AGE_GATE_LOGOUT_UNDERAGE_NEW_USER: function handleAgeGateUnderage() {
c1024_26 = true;
handleLogout();
Dispatcher.wait($mk68491());
},
CLOSE_SUSPENDED_USER: function handleSuspendedUserClosed() {
suspendedUserToken = null;
NONE = LoginStates.NONE;
handleLogout();
setImmediate(() => transitionTo(Routes.DEFAULT_LOGGED_OUT));
},
PASSWORDLESS_FAILURE: function handlePasswordlessFailure({ error }) {
ticket = "";
sms = false;
challenge = null;
c1024_35 = false;
loginInstanceId = null;
if (error instanceof APIError) {
NONE = getAuthenticationErrorsFromAPIError(error).date_of_birth != null ? LoginStates.LOGIN_AGE_GATE : LoginStates.NONE;
} else {
NONE = LoginStates.NONE;
}
},
PASSWORDLESS_START: function handlePasswordlessStart() {
c1024_35 = true;
}
}, DispatchBand.Early);
export default authenticationStore;
+16
View File
@@ -0,0 +1,16 @@
// Metro module 4259 (f4260).
import { DEFAULT_VOICE_BITRATE } from "../_bundle/Module4250";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
class BitRateStore extends Module589.Store {
static displayName = "BitRateStore";
get bitrate() {
return DEFAULT_VOICE_BITRATE;
}
}
const bitRateStore = new BitRateStore(Dispatcher, {
SET_CHANNEL_BITRATE: function handleSetChannelBitrate(a0) {
DEFAULT_VOICE_BITRATE = a0.bitrate;
}
});
export default bitRateStore;
+18
View File
@@ -0,0 +1,18 @@
// Metro module 1219 (f1220).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
class BrowserHandoffStore extends Module589.Store {
static displayName = "BrowserHandoffStore";
initialize() {}
isHandoffAvailable() {
return false;
}
get user() {
return null;
}
get key() {
return null;
}
}
const browserHandoffStore = new BrowserHandoffStore(Dispatcher, {});
export default browserHandoffStore;
+179
View File
@@ -0,0 +1,179 @@
// Metro module 4866 (f4867).
import ChannelStore from "./ChannelStore";
import SelectedChannelStore from "./SelectedChannelStore";
import SelectedGuildStore from "./SelectedGuildStore";
import { Endpoints } from "../Constants";
import Dispatcher from "../Dispatcher";
import { HTTP } from "../_bundle/sendRequest";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
let calls, enqueuedRings;
const callConnect = function callConnect() {
let r6 = arguments[1];
if (r6 === void 0) {
r6 = SelectedChannelStore.getChannelId();
}
const channel = ChannelStore.getChannel(r6);
let r0 = channel == null;
const channelId = r6;
if (!r0) {
r0 = channel.getGuildId() != null;
}
if (!r0) {
r0 = channelId == null;
}
if (!r0) {
r0 = calls[channelId] != null && !arguments[0];
}
let r19 = !r0;
if (!r0) {
let r21 = calls[channelId];
if (r21 == null) {
r21 = {
channelId,
ringing: []
};
}
calls[channelId] = r21;
Dispatcher.dispatch({
type: "CALL_CONNECT",
channelId
});
r19 = true;
}
return r19;
};
calls = {};
enqueuedRings = {};
class CallStore extends Module589.Store {
static displayName = "CallStore";
initialize() {
this.waitFor(ChannelStore, SelectedChannelStore, SelectedGuildStore);
}
getCall(a0) {
return calls[a0];
}
getCalls() {
return Object.values(calls);
}
getMessageId(a0) {
const call = this.getCall(a0);
return call != null ? call.messageId : null;
}
isCallActive(a0, a1) {
const r7 = calls[a0];
return r7 != null && !r7.unavailable && (a1 != null ? r7.messageId === a1 : r7.region != null);
}
isCallUnavailable(a0) {
const r4 = calls[a0];
return r4 != null && r4.unavailable;
}
getInternalState() {
return {
calls,
enqueuedRings
};
}
}
const callStore = new CallStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
return callConnect(true);
},
CONNECTION_CLOSED: function handleConnectionClosed() {
calls = {};
enqueuedRings = {};
},
OVERLAY_INITIALIZE: function handleOverlayInitialize({ callStoreInternalState }) {
calls = {
...callStoreInternalState.calls
};
enqueuedRings = {
...callStoreInternalState.enqueuedRings
};
},
CONNECTION_RESUMED: function handleConnectionResumed() {
return callConnect(true);
},
CHANNEL_SELECT: function handleChannelSelect(a0) {
return callConnect(false, a0.channelId);
},
CHANNEL_DELETE: function handleChannelDelete({ channel }) {
if (enqueuedRings[channel.id] != null) {
delete enqueuedRings[channel.id];
}
if (calls[channel.id] == null) {
return false;
}
delete calls[channel.id];
},
CALL_CREATE: function handleCallCreate(a0) {
const channelId = a0.channelId;
calls[channelId] = {
channelId,
messageId: a0.messageId,
region: a0.region,
ringing: Object.keys(a0.ongoingRings),
unavailable: false,
regionUpdated: false
};
if (enqueuedRings[channelId] != null) {
const r18 = enqueuedRings[channelId];
delete enqueuedRings[channelId];
const recipients = r18.indexOf("all") !== 1 ? null : r18;
HTTP.post({
url: Endpoints.CALL_RING(channelId),
body: {
recipients
},
oldFormErrors: true,
rejectWithError: true
});
}
},
CALL_UPDATE: function handleCallUpdate({ channelId, messageId, region, ongoingRings }) {
const r8 = calls[channelId];
const regionUpdated = r8 != null && (r8.regionUpdated || r8.region !== region);
calls[channelId] = {
...calls[channelId],
messageId,
region,
ringing: Object.keys(ongoingRings),
regionUpdated
};
},
CALL_DELETE: function handleCallDelete({ channelId, unavailable }) {
const r7 = calls[channelId];
calls[channelId] = unavailable === true && r7 != null ? {
...r7,
unavailable
} : {
channelId,
ringing: [],
messageId: null,
region: null,
regionUpdated: false,
unavailable
};
if (enqueuedRings[channelId] != null) {
delete enqueuedRings[channelId];
}
},
CALL_ENQUEUE_RING: function handleCallEnqueueRing(a0) {
const channelId = a0.channelId;
let recipients = a0.recipients;
let r13 = enqueuedRings[channelId];
if (r13 == null) {
r13 = [];
}
if (recipients == null) {
recipients = ["all"];
}
enqueuedRings[channelId] = Module12.union(r13, recipients);
},
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect(a0) {
if (a0.channelId == null) {
enqueuedRings = {};
}
}
});
export default callStore;
+182
View File
@@ -0,0 +1,182 @@
// Metro module 5133 (f5134).
import UserSettingsProtoStore from "../modules/user_settings/UserSettingsProtoStore";
import ChannelStore from "./ChannelStore";
import GuildAvailabilityStore from "./GuildAvailabilityStore";
import GuildChannelStore from "./GuildChannelStore";
import { ChannelTypes } from "../Constants";
import { FavoriteChannelType } from "../_bundle/Module1306";
import { isNotNullish } from "../utils/GlobalUtils";
import { isFavoritesGuildId } from "../modules/favorites/FavoritesUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c3095_7, c3095_8, syncFavoriteCategoryCollapse;
const incrementVersion = function incrementVersion() {
c3095_8 = c3095_8 + 1;
};
syncFavoriteCategoryCollapse = function syncFavoriteCategoryCollapse() {
let r2, r3;
const favoriteChannels = UserSettingsProtoStore.settings.favorites?.favoriteChannels;
if (favoriteChannels == null) {
return false;
}
let r21 = false;
let r22 = false;
for (const key in favoriteChannels) {
r3 = r21;
r22 = r3;
const r14 = favoriteChannels[key];
const type = r14.type;
const CATEGORY = FavoriteChannelType.CATEGORY;
r21 = r3;
if (type === CATEGORY) {
const collapsed = r14.collapsed;
const r30 = c3095_7[key];
if (collapsed) {
if (!r30) {
c3095_7[key] = true;
r3 = true;
}
r2 = r3;
} else {
r2 = r3;
if (r30) {
delete c3095_7[key];
r2 = true;
}
}
r21 = r2;
}
}
r3 = r21;
r22 = r3;
return r22;
};
c3095_7 = {};
c3095_8 = 0;
class CategoryCollapseStore extends Module589.PersistedStore {
static displayName = "CategoryCollapseStore";
static persistKey = "collapsedCategories";
initialize(a0) {
let r2 = a0;
this.waitFor(ChannelStore, GuildAvailabilityStore, GuildChannelStore, UserSettingsProtoStore);
this.removeChangeListener(incrementVersion);
this.addChangeListener(incrementVersion);
if (a0 == null) {
r2 = {};
}
c3095_7 = r2;
this.syncWith([UserSettingsProtoStore], syncFavoriteCategoryCollapse);
}
getState() {
return c3095_7;
}
isCollapsed(a0) {
const r5 = a0 == null || a0 === "null" || !c3095_7[a0];
return r5 ? !r5 : c3095_7[a0];
}
getCollapsedCategories() {
return c3095_7;
}
get version() {
return c3095_8;
}
}
const categoryCollapseStore = new CategoryCollapseStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
if (!a0.userGuildSettings.partial) {
c3095_7 = {};
}
for (const entry of a0.userGuildSettings.entries) {
if (entry.channel_overrides != null) {
for (const channel_override of entry.channel_overrides) {
const r40 = channel_override;
const collapsed = channel_override.collapsed;
const r41 = c3095_7;
const channel_id = r40.channel_id;
if (collapsed) {
r41[channel_id] = true;
} else {
delete r41[channel_id];
}
}
}
}
syncFavoriteCategoryCollapse();
},
USER_GUILD_SETTINGS_FULL_UPDATE: function handleUserGuildSettingsFullUpdate({ userGuildSettings }) {
const set = new Set(userGuildSettings.map((userGuildSetting) => userGuildSetting.guild_id).filter(isNotNullish));
for (const key in c3095_7) {
const channel = ChannelStore.getChannel(key);
if (channel != null && channel.guild_id != null && set.has(channel.guild_id)) {
delete c3095_7[channel.id];
}
}
for (const item of userGuildSettings) {
for (const channel_override of item.channel_overrides) {
const r62 = channel_override;
if (channel_override.collapsed) {
c3095_7[r62.channel_id] = true;
}
}
}
},
CATEGORY_COLLAPSE: function handleCategoryCollapse({ id }) {
const favoriteChannels = UserSettingsProtoStore.settings.favorites?.favoriteChannels;
const r21 = (favoriteChannels == null ? void 0 : favoriteChannels[id]?.type) === FavoriteChannelType.CATEGORY;
let r22 = !r21;
if (!r21) {
const r24 = c3095_7[id];
let r25 = !r24;
if (!r24) {
c3095_7[id] = true;
r25 = void 0;
}
r22 = r25;
}
return r22;
},
CATEGORY_EXPAND: function handleCategoryExpand({ id }) {
const favoriteChannels = UserSettingsProtoStore.settings.favorites?.favoriteChannels;
const r3 = (favoriteChannels == null ? void 0 : favoriteChannels[id]?.type) === FavoriteChannelType.CATEGORY;
let r21 = !r3;
if (!r3) {
const r24 = c3095_7[id] == null;
let r25 = false;
if (!r24) {
delete c3095_7[id];
r25 = void 0;
}
r21 = r25;
}
return r21;
},
CATEGORY_COLLAPSE_ALL: function handleCategoryCollapseAll({ guildId }) {
if (isFavoritesGuildId(guildId)) {
return false;
}
GuildChannelStore.getChannels(guildId)[ChannelTypes.GUILD_CATEGORY].forEach(({ channel }) => {
if (channel.id !== "null") {
c3095_7[channel.id] = true;
}
});
},
CATEGORY_EXPAND_ALL: function handleCategoryExpandAll({ guildId }) {
if (isFavoritesGuildId(guildId)) {
return false;
}
GuildChannelStore.getChannels(guildId)[ChannelTypes.GUILD_CATEGORY].forEach((item) => {
delete c3095_7[item.channel.id];
});
},
CHANNEL_DELETE: function handleChannelDelete(a0) {
const id = a0.channel.id;
const r1 = c3095_7[id] == null;
let r8 = false;
if (!r1) {
delete c3095_7[id];
r8 = void 0;
}
return r8;
}
});
export default categoryCollapseStore;
+105
View File
@@ -0,0 +1,105 @@
// Metro module 4260 (f4261).
import { DeviceTypes } from "../_bundle/Module4250";
import { Storage } from "../_bundle/Module595";
import Module589 from "../_bundle/Module589";
import Module12 from "../_bundle/Module12";
import Dispatcher from "../Dispatcher";
function $mk74021($env) {
return (a0) => delete c2498_6[a0.id];
}
function $mk74022($env) {
return (a0) => {
c2498_6[a0.id] = a0;
return a0;
};
}
let c2498_8;
let env2498 = {};
const c2498_4 = "CertifiedDeviceStore";
const c2498_5 = {};
const c2498_6 = {};
env2498[7] = 0;
class CertifiedDeviceStore extends Module589.Store {
static displayName = "CertifiedDeviceStore";
constructor() {
super(...arguments);
}
initialize() {
const r10 = Storage.get(c2498_4);
if (r10 != null) {
Module12.forEach(r10, (a0, a1) => {
const r2 = env2498;
a0.forEach((item) => {
if (item.type === "audioinput" && item.hardwareMute) {
item.hardwareMute = false;
}
});
const r8 = c2498_5[a1];
if (r8 != null) {
r8.forEach($mk74021(r2));
}
c2498_5[a1] = a0;
a0.forEach($mk74022(r2));
});
}
}
isCertified(a0) {
return c2498_6[a0] != null;
}
getCertifiedDevice(a0) {
return c2498_6[a0];
}
getCertifiedDeviceName(a0, r1) {
const certifiedDevice = this.getCertifiedDevice(a0);
if (certifiedDevice != null) {
r1 = `${certifiedDevice.vendor.name} ${certifiedDevice.model.name}`;
}
return r1;
}
getCertifiedDeviceByType(c14035_0) {
return Module12.find(c2498_6, (a0) => a0.type === c14035_0);
}
isHardwareMute(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.hardwareMute : false;
}
hasEchoCancellation(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.echoCancellation : false;
}
hasNoiseSuppression(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.noiseSuppression : false;
}
hasAutomaticGainControl(a0) {
const r5 = c2498_6[a0];
return r5 != null ? r5.type === DeviceTypes.AUDIO_INPUT && r5.automaticGainControl : false;
}
getVendor(a0) {
const r4 = c2498_6[a0];
return r4 != null ? r4.vendor : null;
}
getModel(a0) {
const r4 = c2498_6[a0];
return r4 != null ? r4.model : null;
}
getRevision() {
return env2498[7];
}
}
c2498_8 = CertifiedDeviceStore;
const r56 = new CertifiedDeviceStore(Dispatcher, {
CERTIFIED_DEVICES_SET: function handleSetCertifiedDevices(a0) {
const r3 = env2498;
const { applicationId, devices } = a0;
const r9 = c2498_5[applicationId];
if (r9 != null) {
r9.forEach($mk74021(r3));
}
c2498_5[applicationId] = devices;
devices.forEach($mk74022(r3));
Storage.set(c2498_4, c2498_5);
env2498[7] = env2498[7] + 1;
}
});
export default r56;
+45
View File
@@ -0,0 +1,45 @@
// Metro module 16483 (f16484).
import { FormStates } from "../Constants";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let guildId, code;
const errors = {};
let CLOSED = FormStates.CLOSED;
const error = null;
class ChangeVanityURLModalStore extends Module589.Store {
static displayName = "ChangeVanityURLModalStore";
isOpen() {
return CLOSED !== FormStates.CLOSED;
}
getProps() {
return {
submitting: CLOSED === FormStates.SUBMITTING,
errorDetails: error,
errors,
guildId,
code
};
}
}
const changeVanityURLModalStore = new ChangeVanityURLModalStore(Dispatcher, {
CHANGE_VANITY_URL_MODAL_OPEN: function handleOpen(a0) {
CLOSED = FormStates.OPEN;
guildId = a0.guildId;
code = a0.code;
error = null;
},
CHANGE_VANITY_URL_MODAL_SUBMIT: function handleSubmit() {
CLOSED = FormStates.SUBMITTING;
},
CHANGE_VANITY_URL_MODAL_SUBMIT_FAILURE: function handleSubmitFailure(a0) {
CLOSED = FormStates.OPEN;
error = a0.error;
},
CHANGE_VANITY_URL_MODAL_CLOSE: function handleClose() {
CLOSED = FormStates.CLOSED;
guildId = null;
code = null;
error = null;
}
});
export default changeVanityURLModalStore;
+49
View File
@@ -0,0 +1,49 @@
// Metro module 9879 (f9880).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c6550_0 = {
FAILED: "failed",
SUCCEEDED: "succeeded"
};
let c6550_1 = {};
class ChannelFollowerStatsStore extends Module589.Store {
static displayName = "ChannelFollowerStatsStore";
getFollowerStatsForChannel(a0) {
return c6550_1[a0];
}
}
const channelFollowerStatsStore = new ChannelFollowerStatsStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c6550_1 = {};
},
CHANNEL_FOLLOWER_STATS_FETCH_SUCCESS: function handleFollowerStatsFetchSuccess(a0) {
const channelId = a0.channelId;
let stats = a0.stats;
if (stats == null) {
stats = {};
}
c6550_1[channelId] = {
loadingStatus: c6550_0.SUCCEEDED,
lastFetched: Date.now(),
channelsFollowing: stats.channels_following,
guildMembers: stats.guild_members,
guildsFollowing: stats.guilds_following,
usersSeenEver: stats.users_seen_ever,
subscribersGainedSinceLastPost: stats.subscribers_gained_since_last_post,
subscribersLostSinceLastPost: stats.subscribers_lost_since_last_post
};
},
CHANNEL_FOLLOWER_STATS_FETCH_FAILURE: function handleFollowerStatsFetchFailure(a0) {
c6550_1[a0.channelId] = {
loadingStatus: c6550_0.FAILED,
lastFetched: Date.now(),
channelsFollowing: 0,
guildMembers: 0,
guildsFollowing: 0,
usersSeenEver: 0,
subscribersGainedSinceLastPost: 0,
subscribersLostSinceLastPost: 0
};
}
});
export default channelFollowerStatsStore;
+546
View File
@@ -0,0 +1,546 @@
// Metro module 6055 (f6056).
import ExperimentStore from "../modules/experiments/ExperimentStore";
import ApplicationStreamingStore from "./ApplicationStreamingStore";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import GuildMemberCountStore from "./GuildMemberCountStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildRoleStore from "./GuildRoleStore";
import GuildStore from "./GuildStore";
import PresenceStore from "./PresenceStore";
import SelfPresenceStore from "./SelfPresenceStore";
import UserStore from "./UserStore";
import { Permissions, StatusTypes } from "../Constants";
import { canEveryone, getGuildVisualOwnerId } from "../utils/PermissionUtils";
import MurmurHashV3 from "../_bundle/MurmurHashV3";
import Module12 from "../_bundle/Module12";
import { has } from "../_bundle/HighLow";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
function $mk77661($env) {
return function() {
const r3 = $env[0];
const r6 = $env.$parent;
const r2 = r6[15];
if (r2.ONLINE === r3) {
const r30 = r6[0];
const r31 = r6[3];
return r30(r31[12]).intl.string(r30(r31[12]).t.WbGtnH);
}
if (r2.OFFLINE === r3) {
const r18 = r6[0];
const r19 = r6[3];
return r18(r19[12]).intl.string(r18(r19[12]).t.Vv0abJ);
}
const r5 = r6[0];
const r8 = r6[3];
return r5(r8[12]).intl.string(r5(r8[12]).t["UQMV/E"]);
};
}
let handleApplicationStreamUpdate, handleLocalPresenceUpdate, c3838_17, c3838_18, c3838_21, c3838_25;
let env3838 = {};
const getMemberListId = function getMemberListId(a0) {
const channel = ChannelStore.getChannel(a0);
return channel == null ? c3838_17 : channel.memberListId == null ? canEveryone(Permissions.VIEW_CHANNEL, channel) ? c3838_17 : MurmurHashV3.v3(Module12(channel.permissionOverwrites).reduce((acc, { id: id2, allow, deny }) => {
if (has(allow, Permissions.VIEW_CHANNEL)) {
acc.push(`allow:${id2}`);
} else if (has(deny, Permissions.VIEW_CHANNEL)) {
acc.push(`deny:${id2}`);
}
return acc;
}, []).sort().join(",")).toString() : channel.memberListId;
};
const handleConnectionOpen = function handleConnectionOpen() {
c3838_21.reset();
};
handleApplicationStreamUpdate = function handleApplicationStreamUpdate() {
const allApplicationStreams = ApplicationStreamingStore.getAllApplicationStreams();
const r7 = env3838[22].concat(allApplicationStreams);
env3838[22] = allApplicationStreams;
r7.forEach((c25686_0) => {
c3838_21.forEach(null, (a0) => a0.rebuildMember(c25686_0.ownerId));
});
};
handleLocalPresenceUpdate = function handleLocalPresenceUpdate() {
const id = AuthenticationStore.getId();
c3838_21.forEach(null, (a0) => a0.rebuildMember(id));
};
c3838_17 = "everyone";
c3838_18 = {
GROUP: "GROUP",
MEMBER: "MEMBER",
CONTENT_INVENTORY: "CONTENT_INVENTORY",
CONTENT_INVENTORY_GROUP: "CONTENT_INVENTORY_GROUP",
HIDDEN_CONTENT_INVENTORY: "HIDDEN_CONTENT_INVENTORY",
CONTENT_INVENTORY_LEADERBOARD: "CONTENT_INVENTORY_LEADERBOARD"
};
class MemberList {
constructor(a0, a1) {
const r3 = {
__proto__: new.target.prototype,
rows: [],
groups: null,
members: null,
version: 0
};
r3.groups = [];
r3.members = {};
r3.guildId = a0;
r3.listId = a1;
r3.updateOwnerId();
return r3;
}
updateOwnerId() {
const guild = GuildStore.getGuild(this.guildId);
if (guild == null) {
return false;
}
const guildVisualOwnerId = getGuildVisualOwnerId(guild);
let r16 = this.ownerId !== guildVisualOwnerId;
if (r16) {
this.ownerId = guildVisualOwnerId;
r16 = true;
}
return r16;
}
setGroups(a0) {
const length = 0;
this.groups = a0.map((item) => {
let r33;
const index = length;
const r8 = Math;
let count = item.count;
if (count == null) {
count = 0;
}
let env25687;
const count2 = r8.max(0, count);
length = length + (count2 + 1);
const r9 = env3838;
const guildId = this.guildId;
const id2 = item.id;
const r20 = env25687 = {
$parent: r9
};
env25687[0] = id2;
if (StatusTypes.ONLINE !== id2 && (StatusTypes.OFFLINE !== id2 && StatusTypes.UNKNOWN !== id2)) {
const guild = GuildStore.getGuild(guildId);
const r28 = guild != null ? GuildRoleStore.getRole(guild.id, id2) : null;
r33 = {
type: c3838_18.GROUP,
key: id2,
id: id2,
title: r28 != null ? r28.name : "",
count: count2,
index
};
} else {
const r38 = {
type: c3838_18.GROUP,
key: id2,
id: id2
};
Object.defineProperty(r38, "title", {
get: $mk77661(r20),
set: void 0,
enumerable: true,
configurable: true
});
r38.count = count2;
r38.index = index;
r33 = r38;
}
return r33;
});
this.rows.length = length;
}
sync(a0, a1) {
let [c15416_0] = a0;
a1.forEach((item, index) => this.update(c15416_0 + index, item));
}
invalidate(a0) {
let [r16, r17] = a0;
while (r16 <= r17) {
const r22 = this.rows[r16];
const r23 = r16;
if (r22 == null) {
break;
}
delete this.rows[r23];
if (r22.type === c3838_18.MEMBER) {
delete this.members[r22.user.id];
}
r16 = r23 + 1;
}
this.version = this.version + 1;
}
insert(a0, { group, member }) {
let r74;
if (group != null) {
let env15417;
const rows = this.rows;
const guildId2 = this.guildId;
const { id: id3, count } = group;
const r59 = env15417 = {
$parent: env3838
};
env15417[0] = id3;
if (StatusTypes.ONLINE !== id3 && (StatusTypes.OFFLINE !== id3 && StatusTypes.UNKNOWN !== id3)) {
const guild = GuildStore.getGuild(guildId2);
const r68 = guild != null ? GuildRoleStore.getRole(guild.id, id3) : null;
r74 = {
type: c3838_18.GROUP,
key: id3,
id: id3,
title: r68 != null ? r68.name : "",
count,
index: void 0
};
} else {
const r79 = {
type: c3838_18.GROUP,
key: id3,
id: id3
};
Object.defineProperty(r79, "title", {
get: $mk77661(r59),
set: void 0,
enumerable: true,
configurable: true
});
r79.count = count;
r79.index = void 0;
r74 = r79;
}
rows.splice(a0, 0, r74);
} else if (member != null) {
const guildId = this.guildId;
const ownerId = this.ownerId;
const id2 = member.user.id;
const r2 = id2 === AuthenticationStore.getId();
const isMobileOnline = PresenceStore.isMobileOnline(id2);
const isVROnline = PresenceStore.isVROnline(id2);
const status = r2 ? SelfPresenceStore.getStatus() : PresenceStore.getStatus(id2, guildId);
const activities = r2 ? SelfPresenceStore.getActivities() : PresenceStore.getActivities(id2, guildId);
const streamForUser = ApplicationStreamingStore.getStreamForUser(id2, guildId);
const user2 = UserStore.getUser(id2);
const r41 = user2 == null ? null : {
type: c3838_18.MEMBER,
...GuildMemberStore.getMember(guildId, id2),
user: user2,
status,
activities,
applicationStream: streamForUser,
isOwner: ownerId === id2,
isMobileOnline,
isVROnline
};
if (r41 == null) {
return void 0;
}
this.rows.splice(a0, 0, r41);
this.members[member.user.id] = r41;
}
this.version = this.version + 1;
}
update(a0, { group, member }) {
let r80;
const r24 = this.rows[a0];
if (r24 != null && r24.type === c3838_18.MEMBER) {
delete this.members[r24.user.id];
}
if (group != null) {
let env15418;
const rows = this.rows;
const guildId2 = this.guildId;
const { id: id3, count } = group;
const r65 = env15418 = {
$parent: env3838
};
env15418[0] = id3;
if (StatusTypes.ONLINE !== id3 && (StatusTypes.OFFLINE !== id3 && StatusTypes.UNKNOWN !== id3)) {
const guild = GuildStore.getGuild(guildId2);
const r74 = guild != null ? GuildRoleStore.getRole(guild.id, id3) : null;
r80 = {
type: c3838_18.GROUP,
key: id3,
id: id3,
title: r74 != null ? r74.name : "",
count,
index: void 0
};
} else {
const r85 = {
type: c3838_18.GROUP,
key: id3,
id: id3
};
Object.defineProperty(r85, "title", {
get: $mk77661(r65),
set: void 0,
enumerable: true,
configurable: true
});
r85.count = count;
r85.index = void 0;
r80 = r85;
}
rows[a0] = r80;
} else if (member != null) {
const guildId = this.guildId;
const ownerId = this.ownerId;
const id2 = member.user.id;
const r34 = id2 === AuthenticationStore.getId();
const isMobileOnline = PresenceStore.isMobileOnline(id2);
const isVROnline = PresenceStore.isVROnline(id2);
const status = r34 ? SelfPresenceStore.getStatus() : PresenceStore.getStatus(id2, guildId);
const activities = r34 ? SelfPresenceStore.getActivities() : PresenceStore.getActivities(id2, guildId);
const streamForUser = ApplicationStreamingStore.getStreamForUser(id2, guildId);
const user2 = UserStore.getUser(id2);
const r50 = user2 == null ? null : {
type: c3838_18.MEMBER,
...GuildMemberStore.getMember(guildId, id2),
user: user2,
status,
activities,
applicationStream: streamForUser,
isOwner: ownerId === id2,
isMobileOnline,
isVROnline
};
if (r50 == null) {
return void 0;
}
this.rows[a0] = r50;
this.members[member.user.id] = r50;
}
this.version = this.version + 1;
}
delete(a0) {
const r7 = this.rows[a0];
if (r7 != null) {
if (r7.type === c3838_18.MEMBER) {
delete this.members[r7.user.id];
}
this.rows.splice(a0, 1);
this.version = this.version + 1;
}
}
rebuildMember(a0) {
const r5 = this.members[a0];
if (r5 != null) {
const r3 = Object;
const guildId = this.guildId;
const ownerId = this.ownerId;
const r0 = a0 === AuthenticationStore.getId();
const isMobileOnline = PresenceStore.isMobileOnline(a0);
const isVROnline = PresenceStore.isVROnline(a0);
const status = r0 ? SelfPresenceStore.getStatus() : PresenceStore.getStatus(a0, guildId);
const activities = r0 ? SelfPresenceStore.getActivities() : PresenceStore.getActivities(a0, guildId);
const streamForUser = ApplicationStreamingStore.getStreamForUser(a0, guildId);
const user2 = UserStore.getUser(a0);
r3.assign(r5, user2 == null ? null : {
type: c3838_18.MEMBER,
...GuildMemberStore.getMember(guildId, a0),
user: user2,
status,
activities,
applicationStream: streamForUser,
isOwner: ownerId === a0,
isMobileOnline,
isVROnline
});
this.version = this.version + 1;
}
}
rebuildMembers() {
const r9 = Object.keys(this.members);
const length2 = r9.length;
let r0 = 0;
if (0 < length2) {
do {
this.rebuildMember(r9[r0]);
r0 = r0 + 1;
} while (r0 < r9.length);
}
}
rebuildGroup(a0) {
let r32;
const r7 = this.groups.findIndex((group) => group.id === a0);
const r18 = this.groups[r7];
if (r18 != null) {
let env15420;
const groups = this.groups;
const guildId = this.guildId;
const { count, index } = r18;
const r11 = env15420 = {
$parent: env3838
};
env15420[0] = a0;
if (StatusTypes.ONLINE !== a0 && (StatusTypes.OFFLINE !== a0 && StatusTypes.UNKNOWN !== a0)) {
const guild = GuildStore.getGuild(guildId);
const r27 = guild != null ? GuildRoleStore.getRole(guild.id, a0) : null;
r32 = {
type: c3838_18.GROUP,
key: a0,
id: a0,
title: r27 != null ? r27.name : "",
count,
index
};
} else {
const r37 = {
type: c3838_18.GROUP,
key: a0,
id: a0
};
Object.defineProperty(r37, "title", {
get: $mk77661(r11),
set: void 0,
enumerable: true,
configurable: true
});
r37.count = count;
r37.index = index;
r32 = r37;
}
groups.splice(r7, 1, r32);
this.version = this.version + 1;
}
}
}
class MemberLists {
constructor() {
return {
__proto__: new.target.prototype,
_guildLists: {}
};
}
get(a0, a1) {
let r4 = this._guildLists[a0];
if (r4 == null) {
const _guildLists = this._guildLists;
const r10 = {};
_guildLists[a0] = r10;
r4 = r10;
}
let r11 = r4[a1];
if (r11 == null) {
const r16 = {
__proto__: MemberList.prototype,
rows: [],
groups: null,
members: null,
version: 0
};
r16.groups = [];
r16.members = {};
r16.guildId = a0;
r16.listId = a1;
r16.updateOwnerId();
r16.setGroups([{
id: StatusTypes.UNKNOWN,
count: 0
}]);
r4[a1] = r16;
r11 = r16;
}
return r11;
}
forEach(a0, a1) {
if (a0 == null) {
Module12.forEach(this._guildLists, (a0) => {
Module12.forEach(a0, a1);
});
} else {
const r6 = this._guildLists[a0];
if (r6 != null) {
Module12.forEach(r6, a1);
}
}
}
delete(a0) {
delete this._guildLists[a0];
}
reset() {
this._guildLists = {};
}
}
c3838_21 = {
__proto__: MemberLists.prototype,
_guildLists: {}
};
env3838[22] = [];
class ChannelMemberStore extends Module589.Store {
static displayName = "ChannelMemberStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(UserStore, GuildStore, GuildRoleStore, ChannelStore, GuildMemberStore, PresenceStore, SelfPresenceStore, AuthenticationStore, GuildMemberCountStore, ApplicationStreamingStore, ExperimentStore);
this.syncWith([SelfPresenceStore], handleLocalPresenceUpdate);
this.syncWith([ApplicationStreamingStore], handleApplicationStreamUpdate);
}
getProps(a0, a1) {
const r11 = c3838_21.get(a0, getMemberListId(a1));
return {
listId: `${r11.guildId}:${r11.listId}`,
groups: r11.groups,
rows: r11.rows,
version: r11.version
};
}
getRows(a0, a1) {
return c3838_21.get(a0, getMemberListId(a1)).rows;
}
}
c3838_25 = ChannelMemberStore;
const r114 = new ChannelMemberStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
GUILD_MEMBER_LIST_UPDATE: function handleGuildMemberListUpdate(a0) {
const r8 = c3838_21.get(a0.guildId, a0.id);
let c15422_0 = r8;
a0.ops.forEach((a0) => {
const op = a0.op;
if (op === "SYNC") {
c15422_0.sync(a0.range, a0.items);
} else if (op === "INVALIDATE") {
c15422_0.invalidate(a0.range);
} else if (op === "INSERT") {
c15422_0.insert(a0.index, a0.item);
} else if (op === "UPDATE") {
c15422_0.update(a0.index, a0.item);
} else if (op === "DELETE") {
c15422_0.delete(a0.index);
}
});
r8.setGroups(a0.groups);
},
GUILD_UPDATE: function handleGuildUpdate(a0) {
c3838_21.forEach(a0.guild.id, (a0) => {
if (a0.updateOwnerId()) {
a0.rebuildMembers();
}
});
},
GUILD_DELETE: function handleGuildDelete(a0) {
c3838_21.delete(a0.guild.id);
},
GUILD_ROLE_UPDATE: function handleGuildRoleUpdate({ guildId, role }) {
c3838_21.forEach(guildId, (a0) => {
a0.rebuildGroup(role.id);
a0.rebuildMembers();
});
},
GUILD_MEMBER_UPDATE: function handleMemberUpdate({ guildId, user }) {
c3838_21.forEach(guildId, (a0) => a0.rebuildMember(user.id));
},
CHANNEL_UPDATES: function handleChannelUpdates() {
return true;
}
});
export default r114;
export const EVERYONE_ID = "everyone";
export const EVERYONE_CHANNEL_ID = 0;
export { c3838_18 as MemberListRowTypes };
+176
View File
@@ -0,0 +1,176 @@
// Metro module 9883 (f9884).
import LocaleStore from "../modules/user_settings/LocaleStore";
import ChannelStore from "./ChannelStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildStore from "./GuildStore";
import MessageStore from "./MessageStore";
import RelationshipStore from "./RelationshipStore";
import UserStore from "./UserStore";
import { createMessageRecord, updateMessageRecord } from "../modules/messages/MessageRecordUtils";
import Module12 from "../_bundle/Module12";
import { handleExplicitMediaScanTimeoutForMessage } from "../modules/explicit_media_redaction/ExplicitMediaRedactionUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c6554_10, c6554_11;
const handleChannelDelete = function handleChannelDelete(a0) {
delete c6554_11[a0.channel.id];
};
const handleRelationshipUpdate = function handleRelationshipUpdate() {
Module12.forEach(c6554_11, (a0) => {
a0.items.forEach(({ message }) => {
message.set("blocked", RelationshipStore.isBlockedForMessage(message));
message.set("ignored", RelationshipStore.isIgnoredForMessage(message));
});
a0.items = a0.items.slice();
});
};
c6554_10 = {
LOADING: "LOADING",
LOADED_HAS_MORE: "LOADED_HAS_MORE",
LOADED_FINISHED: "LOADING_FINISHED",
FAILED: "FAILED"
};
c6554_11 = {};
class ChannelPinsStore extends Module589.Store {
static displayName = "ChannelPinsStore";
initialize() {
this.waitFor(ChannelStore, GuildMemberStore, GuildStore, LocaleStore, MessageStore, RelationshipStore, UserStore);
}
getPins(a0) {
return c6554_11[a0];
}
}
const channelPinsStore = new ChannelPinsStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c6554_11 = {};
},
LOAD_PINNED_MESSAGES: function handleLoadStart(a0) {
const channelId = a0.channelId;
if (!a0.reset && c6554_11[channelId] != null) {
c6554_11[channelId].state = c6554_10.LOADING;
} else {
const channel = ChannelStore.getChannel(channelId);
let guildId = channel == null ? void 0 : channel.getGuildId();
if (guildId == null) {
guildId = void 0;
}
c6554_11[channelId] = {
id: channelId,
items: [],
state: c6554_10.LOADING,
guildId
};
}
},
LOAD_PINNED_MESSAGES_SUCCESS: function handleLoadSuccess({ channelId, pins, hasMore }) {
const r12 = c6554_11[channelId];
if (r12 == null) {
return false;
}
r12.items = [...r12.items, ...pins.map(({ pinned_at, message }) => ({
pinnedAt: new Date(Date.parse(pinned_at)),
message: createMessageRecord(message)
}))];
r12.state = hasMore ? c6554_10.LOADED_HAS_MORE : c6554_10.LOADED_FINISHED;
},
LOAD_PINNED_MESSAGES_FAILURE: function handleLoadFail(a0) {
const r5 = c6554_11[a0.channelId];
if (r5 == null) {
return false;
}
r5.state = c6554_10.FAILED;
},
CHANNEL_DELETE: handleChannelDelete,
THREAD_DELETE: handleChannelDelete,
GUILD_DELETE: function handleGuildDelete({ guild }) {
c6554_11 = Module12(c6554_11).filter((item) => item.guildId !== guild.id).keyBy("id").value();
},
MESSAGE_DELETE: function handleMessageDelete({ id, channelId }) {
const r13 = c6554_11[channelId];
let r14 = r13 != null;
if (r14) {
let r21 = Module12.remove(r13.items, (a0) => a0.message.id === id).length !== 0;
if (r21) {
r13.items = r13.items.slice();
c6554_11[channelId] = r13;
r21 = void 0;
}
r14 = r21;
}
return r14;
},
MESSAGE_DELETE_BULK: function handleMessageDeleteBulk(a0) {
const ids = a0.ids;
const r8 = c6554_11[a0.channelId];
if (r8 == null) {
return false;
}
r8.items = r8.items.filter((item) => !ids.includes(item.message.id));
},
MESSAGE_UPDATE: function handleMessageUpdate(a0) {
const id2 = a0.message.id;
const channel_id = a0.message.channel_id;
if (channel_id == null) {
return false;
}
const r19 = c6554_11[channel_id];
if (r19 == null) {
return false;
}
if (a0.message.author != null) {
if (a0.message.pinned) {
r19.items = r19.items.slice();
const r72 = Module12.findIndex(r19.items, (a0) => a0.message.id === id2);
if (r72 === -1) {
r19.items.unshift({
message: createMessageRecord(a0.message),
pinnedAt: new Date()
});
} else {
r19.items[r72].message = updateMessageRecord(r19.items[r72].message, a0.message);
}
} else {
const r51 = Module12.findIndex(r19.items, (a0) => a0.message.id === id2);
if (r51 === -1) {
return false;
}
r19.items = r19.items.slice();
r19.items.splice(r51, 1);
}
} else {
const r25 = Module12.findIndex(r19.items, (a0) => a0.message.id === id2);
if (r25 === -1) {
return void 0;
}
const r27 = r19.items[r25];
const { pinnedAt, message } = r27;
const message2 = updateMessageRecord(message, a0.message);
if (message2 !== message) {
const items = r19.items.slice();
items[r25] = {
pinnedAt,
message: message2
};
c6554_11[channel_id].items = items;
}
}
},
RELATIONSHIP_ADD: handleRelationshipUpdate,
RELATIONSHIP_REMOVE: handleRelationshipUpdate,
RELATIONSHIP_UPDATE: handleRelationshipUpdate,
MESSAGE_EXPLICIT_CONTENT_SCAN_TIMEOUT: function handleScanTimeout(a0) {
const messageId = a0.messageId;
const r11 = c6554_11[a0.channelId];
if (r11 == null) {
return false;
}
const r17 = Module12.findIndex(r11.items, (a0) => a0.message.id === messageId);
if (r17 === -1) {
return false;
}
r11.items = r11.items.slice();
r11.items[r17].message = handleExplicitMediaScanTimeoutForMessage(r11.items[r17].message);
}
});
export default channelPinsStore;
export { c6554_10 as FetchState };
+21
View File
@@ -0,0 +1,21 @@
// Metro module 12797 (f12798).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c8824_0 = {};
class ChannelSKUStore extends Module589.Store {
static displayName = "ChannelSKUStore";
getSkuIdForChannel(a0) {
return c8824_0[a0];
}
}
const channelSKUStore = new ChannelSKUStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c8824_0 = {};
},
STORE_LISTING_FETCH_SUCCESS: function handleStoreListingFetchSuccess({ channelId, storeListing }) {
if (channelId != null) {
c8824_0[channelId] = storeListing.sku.id;
}
}
});
export default channelSKUStore;
+588
View File
@@ -0,0 +1,588 @@
// Metro module 5874 (f5875).
import ExperimentStore from "../modules/experiments/ExperimentStore";
import SearchMessageStore from "../modules/search/SearchMessageStore";
import ChannelStore from "./ChannelStore";
import GuildStore from "./GuildStore";
import PermissionStore from "./PermissionStore";
import SelectedChannelStore from "./SelectedChannelStore";
import SelectedGuildStore from "./SelectedGuildStore";
import UserStore from "./UserStore";
import { ChannelSections, ComponentActions } from "../Constants";
import { buildGuildStaticChannelId, isStaticChannelRoute } from "../modules/channel/ChannelConstants";
import { Permissions } from "../_bundle/Module505";
import { SidebarType } from "../modules/sidebar/SidebarActionTypes";
import { ComponentDispatch } from "../utils/ComponentDispatchUtils";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import { isMobile } from "../_bundle/Module4426";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let isMembersOpen, isSummariesOpen, c3676_18, isProfileOpen, sidebars, guildSidebars, hasSearchState, searchContextId, setIsSearchSidebarOpen;
const handlePermissionsChange = function handlePermissionsChange() {
let r3;
let r2 = false;
let r5 = false;
for (const key in sidebars) {
r3 = r2;
r5 = r3;
const r18 = sidebars[key];
if (r18.type !== SidebarType.VIEW_THREAD) {
const type = r18.type;
const VIEW_CHANNEL = SidebarType.VIEW_CHANNEL;
r2 = r3;
if (type !== VIEW_CHANNEL) {
continue;
}
}
const channel = ChannelStore.getChannel(r18.channelId);
const r31 = channel != null && PermissionStore.can(Permissions.VIEW_CHANNEL, channel);
r2 = r3;
if (!r31) {
delete sidebars[key];
r2 = true;
}
}
r3 = r2;
r5 = r3;
return r5;
};
setIsSearchSidebarOpen = function setIsSearchSidebarOpen() {
const r6 = searchContextId != null && SearchMessageStore.hasSearchState(searchContextId);
if (r6 === hasSearchState) {
return false;
}
hasSearchState = r6;
};
isMembersOpen = false;
isSummariesOpen = false;
c3676_18 = false;
isProfileOpen = true;
sidebars = {};
guildSidebars = {};
hasSearchState = false;
searchContextId = null;
class ChannelSectionStore extends Module589.PersistedStore {
static displayName = "ChannelSectionStore";
static persistKey = "ChannelSectionStore2";
initialize(a0) {
if (a0 != null) {
let isMembersOpen2 = a0.isMembersOpen;
if (isMembersOpen2 == null) {
isMembersOpen2 = false;
}
isMembersOpen = isMembersOpen2;
let isSummariesOpen2 = a0.isSummariesOpen;
if (isSummariesOpen2 == null) {
isSummariesOpen2 = false;
}
isSummariesOpen = isSummariesOpen2;
let isProfileOpen2 = a0.isProfileOpen;
if (isProfileOpen2 == null) {
isProfileOpen2 = true;
}
isProfileOpen = isProfileOpen2;
let sidebars2 = a0.sidebars;
if (sidebars2 == null) {
sidebars2 = {};
}
sidebars = sidebars2;
let guildSidebars2 = a0.guildSidebars;
if (guildSidebars2 == null) {
guildSidebars2 = {};
}
guildSidebars = guildSidebars2;
}
this.syncWith([SearchMessageStore], setIsSearchSidebarOpen);
this.syncWith([PermissionStore], handlePermissionsChange);
this.waitFor(ChannelStore, ExperimentStore, GuildStore, PermissionStore, SearchMessageStore, SelectedChannelStore, SelectedGuildStore, UserStore);
}
getState() {
return {
isMembersOpen,
isSummariesOpen,
isProfileOpen,
sidebars,
guildSidebars
};
}
getSection(a0, a1) {
if (hasSearchState) {
return ChannelSections.SEARCH;
}
const r1 = a0 == null;
let r5 = null;
if (!r1) {
const isStaticChannelRoute2 = isStaticChannelRoute(a0);
r5 = a0;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId);
}
}
return r5 != null && sidebars[r5] != null ? ChannelSections.SIDEBAR_CHAT : a1 && isProfileOpen ? ChannelSections.PROFILE : isSummariesOpen ? ChannelSections.SUMMARIES : isMembersOpen ? ChannelSections.MEMBERS : c3676_18 ? ChannelSections.CONVERSATIONS : ChannelSections.NONE;
}
getSidebarState(a0) {
const r1 = a0 == null;
let r5 = null;
if (!r1) {
const isStaticChannelRoute2 = isStaticChannelRoute(a0);
r5 = a0;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId);
}
}
return r5 == null ? void 0 : sidebars[r5];
}
getGuildSidebarState(a0) {
return a0 == null ? void 0 : guildSidebars[a0];
}
getCurrentSidebarChannelId(a0) {
const r0 = a0 == null;
let r5 = null;
if (!r0) {
const isStaticChannelRoute2 = isStaticChannelRoute(a0);
r5 = a0;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId);
}
}
if (r5 == null) {
return null;
}
if (hasSearchState) {
return null;
}
const r16 = sidebars[r5];
return r16 == null ? null : r16.type !== SidebarType.VIEW_THREAD && r16.type !== SidebarType.VIEW_CHANNEL ? r16.type === SidebarType.VIEW_MOD_REPORT ? r16.channelId : null : r16.channelId;
}
getCurrentSidebarMessageId(a0) {
let r37, details;
const r2 = a0 == null;
let r5 = null;
if (!r2) {
const isStaticChannelRoute2 = isStaticChannelRoute(a0);
r5 = a0;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r5 = guildId == null ? null : buildGuildStaticChannelId(a0, guildId);
}
}
if (r5 == null) {
return null;
}
if (hasSearchState) {
return null;
}
const r16 = sidebars[r5];
const r17 = r16 == null;
let r18 = null;
if (!r17) {
if (r16.type !== SidebarType.VIEW_THREAD && r16.type !== SidebarType.VIEW_CHANNEL) {
const type = r16.type;
const VIEW_MOD_REPORT = SidebarType.VIEW_MOD_REPORT;
r37 = null;
if (type === VIEW_MOD_REPORT) {
details = r16.details;
r37 = details?.initialMessageId;
}
} else {
details = r16.details;
r37 = details?.initialMessageId;
}
r18 = r37;
}
return r18;
}
getCurrentSearchContextId() {
return searchContextId;
}
}
const channelSectionStore = new ChannelSectionStore(Dispatcher, {
SIDEBAR_SET_SELECTED_SEARCH_CONTEXT: function handleSetSelectedSearchContext({ searchContextId: searchContextId2 }) {
searchContextId = searchContextId2;
const r8 = searchContextId2 != null && SearchMessageStore.hasSearchState(searchContextId);
const r9 = hasSearchState;
let r10 = false;
if (r8 !== r9) {
hasSearchState = r8;
r10 = void 0;
}
return r10;
},
CHANNEL_TOGGLE_MEMBERS_SECTION: function handleChannelToggleMembersSection() {
if (hasSearchState) {
ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE);
}
const r19 = isSummariesOpen;
if (r19) {
const r20 = hasSearchState;
let r21 = false;
if (r20) {
hasSearchState = false;
r21 = true;
}
const channelId = SelectedChannelStore.getChannelId();
const r2 = channelId == null;
let r25 = null;
if (!r2) {
const isStaticChannelRoute2 = isStaticChannelRoute(channelId);
r25 = channelId;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r25 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId);
}
}
if (r25 != null && r25 in sidebars) {
delete sidebars[r25];
r21 = true;
}
isSummariesOpen = r21 ? r19 || !r19 : !r19;
}
const r37 = c3676_18;
if (r37) {
const r38 = hasSearchState;
let r40 = false;
if (r38) {
hasSearchState = false;
r40 = true;
}
const channelId2 = SelectedChannelStore.getChannelId();
const r45 = channelId2 == null;
let r46 = null;
if (!r45) {
const isStaticChannelRoute3 = isStaticChannelRoute(channelId2);
r46 = channelId2;
if (isStaticChannelRoute3) {
const guildId2 = SelectedGuildStore.getGuildId();
r46 = guildId2 == null ? null : buildGuildStaticChannelId(channelId2, guildId2);
}
}
if (r46 != null && r46 in sidebars) {
delete sidebars[r46];
r40 = true;
}
c3676_18 = r40 ? r37 || !r37 : !r37;
}
const r60 = isMembersOpen;
const r61 = hasSearchState;
let r63 = false;
if (r61) {
hasSearchState = false;
r63 = true;
}
const channelId3 = SelectedChannelStore.getChannelId();
const r68 = channelId3 == null;
let r69 = null;
if (!r68) {
const isStaticChannelRoute4 = isStaticChannelRoute(channelId3);
r69 = channelId3;
if (isStaticChannelRoute4) {
const guildId3 = SelectedGuildStore.getGuildId();
r69 = guildId3 == null ? null : buildGuildStaticChannelId(channelId3, guildId3);
}
}
if (r69 != null && r69 in sidebars) {
delete sidebars[r69];
r63 = true;
}
isMembersOpen = r63 ? r60 || !r60 : !r60;
},
USER_PROFILE_SIDEBAR_TOGGLE_SECTION: function handleUserProfileSidebarToggleSection() {
if (!isProfileOpen) {
ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE);
}
const r18 = isProfileOpen;
const r19 = hasSearchState;
let r20 = false;
if (r19) {
hasSearchState = false;
r20 = true;
}
const channelId = SelectedChannelStore.getChannelId();
const r2 = channelId == null;
let r24 = null;
if (!r2) {
const isStaticChannelRoute2 = isStaticChannelRoute(channelId);
r24 = channelId;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r24 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId);
}
}
if (r24 != null && r24 in sidebars) {
delete sidebars[r24];
r20 = true;
}
isProfileOpen = r20 ? r18 || !r18 : !r18;
},
CHANNEL_TOGGLE_SUMMARIES_SECTION: function handleChannelToggleSummariesSection() {
const r7 = isMembersOpen;
if (r7) {
const r5 = hasSearchState;
let r0 = false;
if (r5) {
hasSearchState = false;
r0 = true;
}
const channelId = SelectedChannelStore.getChannelId();
const r2 = channelId == null;
let r14 = null;
if (!r2) {
const isStaticChannelRoute2 = isStaticChannelRoute(channelId);
r14 = channelId;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r14 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId);
}
}
if (r14 != null && r14 in sidebars) {
delete sidebars[r14];
r0 = true;
}
isMembersOpen = r0 ? r7 || !r7 : !r7;
}
const r26 = c3676_18;
if (r26) {
const r27 = hasSearchState;
let r29 = false;
if (r27) {
hasSearchState = false;
r29 = true;
}
const channelId2 = SelectedChannelStore.getChannelId();
const r34 = channelId2 == null;
let r35 = null;
if (!r34) {
const isStaticChannelRoute3 = isStaticChannelRoute(channelId2);
r35 = channelId2;
if (isStaticChannelRoute3) {
const guildId2 = SelectedGuildStore.getGuildId();
r35 = guildId2 == null ? null : buildGuildStaticChannelId(channelId2, guildId2);
}
}
if (r35 != null && r35 in sidebars) {
delete sidebars[r35];
r29 = true;
}
c3676_18 = r29 ? r26 || !r26 : !r26;
}
const r49 = isSummariesOpen;
const r50 = hasSearchState;
let r52 = false;
if (r50) {
hasSearchState = false;
r52 = true;
}
const channelId3 = SelectedChannelStore.getChannelId();
const r57 = channelId3 == null;
let r58 = null;
if (!r57) {
const isStaticChannelRoute4 = isStaticChannelRoute(channelId3);
r58 = channelId3;
if (isStaticChannelRoute4) {
const guildId3 = SelectedGuildStore.getGuildId();
r58 = guildId3 == null ? null : buildGuildStaticChannelId(channelId3, guildId3);
}
}
if (r58 != null && r58 in sidebars) {
delete sidebars[r58];
r52 = true;
}
isSummariesOpen = r52 ? r49 || !r49 : !r49;
},
CHANNEL_TOGGLE_CONVERSATIONS_SECTION: function handleChannelToggleConversationsSection() {
if (hasSearchState) {
ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE);
}
isMembersOpen = false;
isSummariesOpen = false;
const r3 = c3676_18;
const r18 = hasSearchState;
let r19 = false;
if (r18) {
hasSearchState = false;
r19 = true;
}
const channelId = SelectedChannelStore.getChannelId();
const r2 = channelId == null;
let r23 = null;
if (!r2) {
const isStaticChannelRoute2 = isStaticChannelRoute(channelId);
r23 = channelId;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r23 = guildId == null ? null : buildGuildStaticChannelId(channelId, guildId);
}
}
if (r23 != null && r23 in sidebars) {
delete sidebars[r23];
r19 = true;
}
c3676_18 = r19 ? r3 || !r3 : !r3;
},
CHANNEL_OPEN_CONVERSATIONS_SECTION: function handleChannelOpenConversationsSection() {
const r1 = c3676_18;
let r0 = !r1;
if (!r1) {
if (hasSearchState) {
ComponentDispatch.dispatch(ComponentActions.SEARCH_RESULTS_CLOSE);
}
isMembersOpen = false;
isSummariesOpen = false;
c3676_18 = true;
r0 = true;
}
return r0;
},
SIDEBAR_VIEW_CHANNEL: function handleSidebarViewChannel({ sidebarType, baseChannelId, channelId, details }) {
hasSearchState = false;
const r1 = baseChannelId == null;
let r6 = null;
if (!r1) {
const isStaticChannelRoute2 = isStaticChannelRoute(baseChannelId);
r6 = baseChannelId;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r6 = guildId == null ? null : buildGuildStaticChannelId(baseChannelId, guildId);
}
}
if (r6 == null) {
return false;
}
const r21 = {
type: sidebarType,
channelId,
details
};
sidebars[r6] = sidebarType === SidebarType.VIEW_MOD_REPORT ? {
...r21,
baseChannelId
} : r21;
return true;
},
SIDEBAR_VIEW_GUILD: function handleSidebarViewGuild({ sidebarType, guildId, baseChannelId, details }) {
hasSearchState = false;
const r1 = baseChannelId == null;
let baseChannelId2 = null;
if (!r1) {
const isStaticChannelRoute2 = isStaticChannelRoute(baseChannelId);
baseChannelId2 = baseChannelId;
if (isStaticChannelRoute2) {
const guildId2 = SelectedGuildStore.getGuildId();
baseChannelId2 = guildId2 == null ? null : buildGuildStaticChannelId(baseChannelId, guildId2);
}
}
let r19 = baseChannelId2 != null;
if (r19) {
guildSidebars[guildId] = {
type: sidebarType,
baseChannelId: baseChannelId2,
guildId,
details
};
r19 = true;
}
return r19;
},
SIDEBAR_CREATE_THREAD: function handleCreateThread({ parentChannelId, parentMessageId, location: location2 }) {
hasSearchState = false;
const r1 = parentChannelId == null;
let r5 = null;
if (!r1) {
const isStaticChannelRoute2 = isStaticChannelRoute(parentChannelId);
r5 = parentChannelId;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r5 = guildId == null ? null : buildGuildStaticChannelId(parentChannelId, guildId);
}
}
if (r5 != null) {
sidebars[r5] = {
type: SidebarType.CREATE_THREAD,
parentChannelId,
parentMessageId,
location: location2
};
}
},
SIDEBAR_CLOSE: function handleCloseSidebar({ baseChannelId }) {
const r1 = baseChannelId == null;
let r9 = null;
if (!r1) {
const isStaticChannelRoute2 = isStaticChannelRoute(baseChannelId);
r9 = baseChannelId;
if (isStaticChannelRoute2) {
const guildId = SelectedGuildStore.getGuildId();
r9 = guildId == null ? null : buildGuildStaticChannelId(baseChannelId, guildId);
}
}
if (r9 != null) {
delete sidebars[r9];
}
},
SIDEBAR_CLOSE_GUILD: function handleGuildCloseSidebar({ guildId }) {
let r7 = guildSidebars[guildId] != null;
if (r7) {
delete guildSidebars[guildId];
r7 = true;
}
return r7;
},
CHANNEL_DELETE: function handleChannelDelete({ channel }) {
let r4;
const r5 = channel.id in sidebars;
if (r5) {
delete sidebars[channel.id];
return true;
}
let r3 = false;
let r23 = false;
for (const key in sidebars) {
r4 = r3;
r23 = r4;
const r25 = sidebars[key];
const r2 = r25 != null && r25.type === SidebarType.VIEW_CHANNEL && r25.channelId === channel.id;
r3 = r4;
if (r2) {
delete sidebars[key];
r3 = true;
}
}
r4 = r3;
r23 = r4;
return r23;
},
CHANNEL_SELECT: function handleChannelSelect() {
if (isMobile && isMembersOpen) {
isMembersOpen = false;
isSummariesOpen = false;
c3676_18 = false;
}
},
THREAD_CREATE: function handleThreadCreate({ channel }) {
if (channel.ownerId === UserStore.getCurrentUser()?.id) {
return false;
}
const r14 = sidebars[channel.parent_id];
if (r14 != null && r14.type === SidebarType.CREATE_THREAD && r14.parentMessageId === SnowflakeUtils.castChannelIdAsMessageId(channel.id)) {
sidebars[channel.parent_id] = {
type: SidebarType.VIEW_THREAD,
channelId: channel.id
};
}
},
THREAD_DELETE: function handleThreadDelete({ channel }) {
const r9 = sidebars[channel.parent_id];
if (r9 != null && r9.type === SidebarType.VIEW_THREAD && r9.channelId === channel.id) {
delete sidebars[channel.parent_id];
return void 0;
}
return false;
}
});
export default channelSectionStore;
export const MESSAGE_REQUESTS_BASE_CHANNEL_ID = "message_requests";
export function isViewChannelSidebar(a0) {
return [SidebarType.VIEW_CHANNEL, SidebarType.VIEW_THREAD, SidebarType.VIEW_MESSAGE_REQUEST, SidebarType.VIEW_MOD_REPORT].includes(a0.type);
}
+221
View File
@@ -0,0 +1,221 @@
// Metro module 15651 (f15652).
import ChannelSettingsStore from "./ChannelSettingsStore";
import ChannelStore from "./ChannelStore";
import { ChannelSettingsSections, FormStates } from "../Constants";
import { ADVANCED_MODE_ON_KEY } from "../modules/channel_permissions/ChannelPermissionsConstants";
import { Storage } from "../_bundle/Module595";
import { makeEveryoneOverwrite, areChannelsLocked } from "../utils/PermissionUtils";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c11172_4, c11172_5, c11172_11, CLOSED, c11172_13, c11172_14, c11172_15, channel2, category2, guildId, id, advancedMode2, syncChannelUpdates;
const init = function init() {
channel2 = ChannelSettingsStore.getChannel();
category2 = ChannelSettingsStore.getCategory();
if (channel2 == null) {
return false;
}
const guildId3 = channel2.getGuildId();
const guildId2 = channel2.getGuildId();
const r19 = {
...channel2.permissionOverwrites
};
if (guildId2 != null && r19[guildId2] == null) {
r19[guildId2] = makeEveryoneOverwrite(guildId2);
}
c11172_14 = r19;
c11172_15 = r19;
if (r19[guildId] == null) {
guildId = guildId3;
}
c11172_5 = category2 != null;
c11172_4 = areChannelsLocked(channel2, category2);
id = null;
c11172_13 = false;
CLOSED = FormStates.CLOSED;
c11172_11.clear();
};
syncChannelUpdates = function syncChannelUpdates(a0) {
if (channel2 != null && channel2.id === a0) {
const channel3 = ChannelStore.getChannel(a0);
channel2 = channel3;
if (channel3 == null) {
return false;
}
category2 = ChannelSettingsStore.getCategory();
const guildId3 = channel2.getGuildId();
if (guildId3 == null) {
return false;
}
const guildId2 = channel2.getGuildId();
const r23 = {
...channel2.permissionOverwrites
};
if (guildId2 != null && r23[guildId2] == null) {
r23[guildId2] = makeEveryoneOverwrite(guildId2);
}
c11172_15 = r23;
const r33 = {};
let c22289_0 = r33;
c11172_11.forEach((item) => {
if (c11172_14 != null) {
c22289_0[item] = c11172_14[item];
}
});
if (r33[guildId3] == null && channel2.permissionOverwrites[guildId3] == null) {
r33[guildId3] = makeEveryoneOverwrite(guildId3);
}
const r50 = {
...channel2.permissionOverwrites,
...r33
};
c11172_14 = r50;
if (r50[guildId] == null) {
guildId = guildId3;
} else if (id != null && c11172_14[id] != null) {
guildId = id;
id = null;
}
c11172_4 = areChannelsLocked(channel2, category2);
return true;
}
return false;
};
c11172_11 = new Set();
CLOSED = FormStates.CLOSED;
c11172_13 = false;
c11172_14 = null;
c11172_15 = null;
channel2 = null;
category2 = null;
guildId = null;
id = null;
advancedMode2 = Storage.get(ADVANCED_MODE_ON_KEY) || false;
class ChannelSettingsPermissionsStore extends Module589.Store {
static displayName = "ChannelSettingsPermissionsStore";
initialize() {
this.waitFor(ChannelSettingsStore, ChannelStore);
}
hasChanges() {
return c11172_13;
}
showNotice() {
return this.hasChanges();
}
getPermissionOverwrite(a0) {
return c11172_14 == null ? void 0 : c11172_14[a0];
}
get editedPermissionIds() {
return Array.from(c11172_11);
}
get permissionOverwrites() {
return c11172_14;
}
get selectedOverwriteId() {
return guildId;
}
get formState() {
return CLOSED;
}
get isLockable() {
return c11172_5;
}
get locked() {
return c11172_4;
}
get channel() {
return channel2;
}
get category() {
return category2;
}
get advancedMode() {
return advancedMode2;
}
}
const channelSettingsPermissionsStore = new ChannelSettingsPermissionsStore(Dispatcher, {
CHANNEL_SETTINGS_SET_SECTION: function handleSetSection({ section }) {
if (channel2 == null && section === ChannelSettingsSections.PERMISSIONS) {
init();
return void 0;
}
return false;
},
CHANNEL_SETTINGS_PERMISSIONS_INIT: init,
CHANNEL_SETTINGS_PERMISSIONS_UPDATE_PERMISSION: function handleUpdatePermission({ id: id2, allow, deny }) {
const r5 = c11172_14;
const r8 = r5 == null ? void 0 : r5[id2];
if (r8 != null && channel2 != null) {
const r13 = {
...r8,
allow,
deny
};
const r15 = {
...c11172_14
};
r15[id2] = r13;
c11172_14 = r15;
c11172_11.add(id2);
CLOSED = FormStates.OPEN;
c11172_13 = !Module12.isEqual(c11172_14, c11172_15);
c11172_4 = areChannelsLocked(channel2, category2);
return void 0;
}
return false;
},
CHANNEL_SETTINGS_PERMISSIONS_SELECT_PERMISSION: function handleSelectPermission({ id: id2 }) {
if (c11172_14 != null && c11172_14[id2] != null) {
guildId = id2;
} else {
if (channel2 == null) {
return false;
}
id = id2;
}
},
CHANNEL_SETTINGS_INIT: function handleInit() {
if (ChannelSettingsStore.getSection() === ChannelSettingsSections.PERMISSIONS) {
init();
}
},
CHANNEL_SETTINGS_CLOSE: function handleClose() {
CLOSED = FormStates.CLOSED;
c11172_14 = null;
c11172_15 = null;
channel2 = null;
category2 = null;
c11172_13 = false;
c11172_11.clear();
guildId = null;
id = null;
},
CHANNEL_UPDATES: function handleChannelUpdates({ channels }) {
if (channel2 == null) {
return false;
}
let r22 = false;
for (const item of channels) {
if (syncChannelUpdates(item.id) !== false) {
r22 = true;
}
}
return r22;
},
CHANNEL_SETTINGS_PERMISSIONS_SUBMITTING: function handleSubmitting() {
CLOSED = FormStates.SUBMITTING;
},
CHANNEL_SETTINGS_PERMISSIONS_SAVE_SUCCESS: function handleSaveSuccess(a0) {
if (a0.silent) {
CLOSED = FormStates.OPEN;
} else {
CLOSED = FormStates.CLOSED;
init();
}
},
CHANNEL_SETTINGS_PERMISSIONS_SET_ADVANCED_MODE: function handleSetAdvancedMode({ advancedMode: advancedMode3 }) {
advancedMode2 = advancedMode3;
Storage.set(ADVANCED_MODE_ON_KEY, advancedMode3);
}
});
export default channelSettingsPermissionsStore;
+436
View File
@@ -0,0 +1,436 @@
// Metro module 7687 (f7688).
import { createChannelRecordFromInvite } from "../records/ChannelRecord";
import InviteRecord from "../records/InviteRecord";
import UserRecord from "../records/UserRecord";
import ChannelStore from "./ChannelStore";
import { ChannelSettingsSections, ChannelTypes, Endpoints, FormStates } from "../Constants";
import { DEFAULT_AUTO_ARCHIVE_DURATION } from "../modules/threads/ThreadConstants";
import { isCustomReactionEmojiId } from "../modules/reactions/ReactionUtils";
import UnicodeEmojis from "../modules/emojis/UnicodeEmojis";
import { ThreadSortOrder } from "../_bundle/Module1381";
import { ForumLayout } from "../_bundle/Module1382";
import { HTTP } from "../_bundle/sendRequest";
import Dispatcher from "../Dispatcher";
import Module12, { isArray } from "../_bundle/Module12";
import { fromInviteGuild } from "../utils/GuildRecordUtils";
import Module3771 from "../_bundle/Module3771";
import Module589 from "../_bundle/Module589";
let section, subsection, channel, channel2, channel3, guildId, CLOSED, errors, invites, loading, c4830_22, location2, _excluded, c4830_26, _createInvite, _syncChannelUpdate, c4830_29, $mk79194 = function() {
return (a0) => {
loading = false;
Dispatcher.dispatch({
type: "CHANNEL_SETTINGS_LOADED_INVITES",
invites: a0.body
});
};
}, $mk79195 = function() {
return () => {
loading = false;
return false;
};
};
const normalizeChannelPropertyForCompare = function normalizeChannelPropertyForCompare(a0, a1, type) {
let r4 = a1;
if (a0 === "topic_") {
if (a1 == null) {
r4 = "";
}
return r4;
}
if (a0 === "defaultAutoArchiveDuration") {
return a1 == null ? DEFAULT_AUTO_ARCHIVE_DURATION : a1;
}
if (a0 === "defaultSortOrder") {
return a1 == null ? ThreadSortOrder.LATEST_ACTIVITY : a1;
}
if (a0 === "defaultForumLayout") {
if (type === ChannelTypes.GUILD_MEDIA) {
return ForumLayout.GRID;
}
return a1 != null ? a1 === ForumLayout.DEFAULT ? ForumLayout.LIST : a1 : ForumLayout.LIST;
}
if (a0 !== "rateLimitPerUser_" && a0 !== "defaultThreadRateLimitPerUser") {
if (a0 === "defaultReactionEmoji") {
const r1 = a1 == null;
let r18 = null;
if (!r1) {
if (isCustomReactionEmojiId(a1.emojiId)) {
r18 = {
emojiId: a1.emojiId
};
} else {
const emojiName = a1.emojiName;
r18 = emojiName == null ? null : emojiName !== "" ? {
emojiName: UnicodeEmojis.translateInlineEmojiToSurrogates(emojiName)
} : null;
}
}
return r18;
}
return a1;
}
return a1 == null ? 0 : a1;
};
_createInvite = function _createInvite(invite) {
return new InviteRecord({
code: invite.code,
temporary: invite.temporary,
revoked: invite.revoked,
inviter: invite.inviter != null ? new UserRecord(invite.inviter) : null,
channel: createChannelRecordFromInvite(invite.channel),
guild: invite.guild != null ? fromInviteGuild(invite.guild) : null,
uses: invite.uses,
maxUses: invite.max_uses,
maxAge: invite.max_age,
createdAt: Module3771(invite.created_at),
type: invite.type,
roles: invite.roles
});
};
_syncChannelUpdate = function _syncChannelUpdate(a0) {
const r1 = channel == null;
let r0 = false;
if (!r1) {
const id = channel.id;
r0 = false;
if (id === a0) {
if (channel === channel2) {
const channel5 = ChannelStore.getChannel(a0);
const r35 = channel5 == null;
r0 = false;
if (!r35) {
channel = channel5;
channel2 = channel5;
channel3 = ChannelStore.getChannel(channel2.parent_id);
r0 = true;
}
} else {
const channel4 = ChannelStore.getChannel(a0);
const r17 = channel4 == null;
r0 = false;
if (!r17) {
channel = channel4;
const r4 = channel2 != null;
r0 = true;
if (r4) {
channel2 = channel2.set("permissionOverwrites", channel.permissionOverwrites).set("availableTags", channel.availableTags);
channel3 = ChannelStore.getChannel(channel2.parent_id);
r0 = true;
}
}
}
}
}
const r40 = r0 ? channel2 == null : !r0;
let r42 = !r40;
if (!r40) {
const r44 = guildId != null && channel2.permissionOverwrites[guildId] == null;
r42 = true;
if (r44) {
guildId = channel2.getGuildId();
r42 = true;
}
}
return r42;
};
const handleOverwriteUpdate = function handleOverwriteUpdate(a0) {
return _syncChannelUpdate(a0.channelId);
};
CLOSED = FormStates.CLOSED;
errors = {};
invites = {};
loading = false;
c4830_22 = false;
location2 = null;
_excluded = ["name", "type", "topic_", "bitrate_", "userLimit_", "nsfw_", "flags_", "rateLimitPerUser_", "defaultThreadRateLimitPerUser", "defaultAutoArchiveDuration", "template", "defaultReactionEmoji", "rtcRegion", "videoQualityMode", "threadMetadata", "banner", "availableTags", "defaultSortOrder", "defaultForumLayout", "defaultTagSetting", "iconEmoji", "themeColor"];
c4830_26 = Module12.debounce(() => {
if (channel2 != null && channel != null) {
const r8 = channel2.toJS();
let c15959_0 = r8;
let c15959_1 = channel.toJS();
const type = r8.type;
if (_excluded.every((item) => {
const r5 = c15959_0[item];
const r6 = c15959_1[item];
return Module12.isEqual(normalizeChannelPropertyForCompare(item, r5, type), normalizeChannelPropertyForCompare(item, r6, type));
}) && channel2 !== channel) {
channel2 = channel;
c4830_29.emitChange();
}
return void 0;
}
return false;
}, 500);
class ChannelSettingsStore extends Module589.Store {
static displayName = "ChannelSettingsStore";
initialize() {
this.waitFor(ChannelStore);
}
hasChanges() {
return channel2 !== channel;
}
isOpen() {
return c4830_22;
}
getSection() {
return section;
}
getInvites() {
return {
invites,
loading
};
}
showNotice() {
return this.hasChanges();
}
getChannel() {
return channel2;
}
getFormState() {
return CLOSED;
}
getCategory() {
return channel3;
}
getProps() {
return {
submitting: CLOSED === FormStates.SUBMITTING,
errors,
channel: channel2,
section,
subsection,
invites,
selectedOverwriteId: guildId,
hasChanges: this.hasChanges(),
analyticsLocation: location2
};
}
}
c4830_29 = new ChannelSettingsStore(Dispatcher, {
CHANNEL_SETTINGS_INIT: function handleSettingsInit(a0) {
const channel4 = ChannelStore.getChannel(a0.channelId);
if (channel4 == null) {
c4830_22 = false;
CLOSED = FormStates.CLOSED;
section = null;
channel = null;
channel2 = null;
channel3 = null;
invites = {};
return void 0;
}
CLOSED = FormStates.OPEN;
channel = channel4;
channel2 = channel4;
location2 = "location" in a0 ? a0.location != null ? a0.location : null : null;
subsection = "subsection" in a0 ? a0.subsection : null;
if (channel2 != null) {
channel2 = channel2.set("nsfw", channel2.isNSFW());
}
channel3 = ChannelStore.getChannel(channel2.parent_id);
guildId = channel2.getGuildId();
const r38 = channel2.isModeratorReportChannel() ? ChannelSettingsSections.PERMISSIONS : ChannelSettingsSections.OVERVIEW;
errors = {};
let r42 = section;
if (r42 == null) {
r42 = r38;
}
section = r42;
subsection = subsection;
if (channel2 != null && section === ChannelSettingsSections.INSTANT_INVITES) {
loading = true;
const r61 = HTTP.get({
url: Endpoints.INSTANT_INVITES(channel2.id),
oldFormErrors: true,
rejectWithError: true
});
const r63 = $mk79195();
r61.then($mk79194(), r63);
}
return true;
},
CHANNEL_SETTINGS_SUBMIT: function handleSettingsSubmit() {
CLOSED = FormStates.SUBMITTING;
errors = {};
},
CHANNEL_SETTINGS_SUBMIT_SUCCESS: function handleSettingsSubmitSuccess() {
channel = channel2;
CLOSED = FormStates.OPEN;
},
CHANNEL_SETTINGS_SUBMIT_FAILURE: function handleSettingsSubmitFailure(a0) {
CLOSED = FormStates.OPEN;
const r5 = Object;
let errors2 = a0.errors;
if (errors2 == null) {
errors2 = {};
}
errors = r5.keys(errors2).reduce((acc, item) => {
const r5 = a0.errors[item];
if (isArray(r5)) {
acc[item] = r5.join("\n");
} else {
acc[item] = r5;
}
return acc;
}, {});
},
CHANNEL_SETTINGS_CLOSE: function handleSettingsClose() {
c4830_22 = false;
CLOSED = FormStates.CLOSED;
section = null;
channel = null;
channel2 = null;
channel3 = null;
invites = {};
},
CHANNEL_PERMISSIONS_PUT_OVERWRITE_SUCCESS: handleOverwriteUpdate,
CHANNEL_PERMISSIONS_DELETE_OVERWRITE_SUCCESS: handleOverwriteUpdate,
CHANNEL_SETTINGS_OVERWRITE_SELECT: function handlePermissionOverwriteSelect(a0) {
guildId = a0.overwriteId;
},
CHANNEL_SETTINGS_UPDATE: function handleSettingsUpdate({ name, channelType, topic, bitrate, userLimit, nsfw, flags, rateLimitPerUser, defaultThreadRateLimitPerUser, autoArchiveDuration, locked, invitable, defaultAutoArchiveDuration, template, defaultReactionEmoji, rtcRegion, videoQualityMode, availableTags, defaultSortOrder, defaultForumLayout, defaultTagSetting, iconEmoji, themeColor }) {
if (channel2 == null) {
return false;
}
if (name != null) {
channel2 = channel2.set("name", name);
}
if (topic != null) {
channel2 = channel2.set("topic", topic);
}
if (bitrate != null) {
channel2 = channel2.set("bitrate", bitrate);
}
if (userLimit != null) {
channel2 = channel2.set("userLimit", userLimit);
}
if (nsfw != null) {
channel2 = channel2.set("nsfw", nsfw);
}
if (flags != null) {
channel2 = channel2.set("flags", flags);
}
if (rateLimitPerUser != null) {
channel2 = channel2.set("rateLimitPerUser", rateLimitPerUser);
}
if (defaultThreadRateLimitPerUser != null) {
channel2 = channel2.set("defaultThreadRateLimitPerUser", defaultThreadRateLimitPerUser);
}
if (autoArchiveDuration != null) {
channel2 = channel2.set("threadMetadata", {
...channel2.threadMetadata,
autoArchiveDuration
});
}
if (locked != null) {
channel2 = channel2.set("threadMetadata", {
...channel2.threadMetadata,
locked
});
}
if (invitable != null) {
channel2 = channel2.set("threadMetadata", {
...channel2.threadMetadata,
invitable
});
}
if (defaultAutoArchiveDuration != null) {
channel2 = channel2.set("defaultAutoArchiveDuration", defaultAutoArchiveDuration);
}
if (template != null) {
channel2 = channel2.set("template", template);
}
if (channelType != null) {
channel2 = channel2.set("type", channelType);
}
if (rtcRegion !== void 0) {
channel2 = channel2.set("rtcRegion", rtcRegion);
}
if (videoQualityMode != null) {
channel2 = channel2.set("videoQualityMode", videoQualityMode);
}
if (defaultReactionEmoji !== void 0) {
channel2 = channel2.set("defaultReactionEmoji", defaultReactionEmoji);
}
if (availableTags != null) {
channel2 = channel2.set("availableTags", availableTags);
}
if (defaultSortOrder != null) {
channel2 = channel2.set("defaultSortOrder", defaultSortOrder);
}
if (defaultTagSetting != null) {
channel2 = channel2.set("defaultTagSetting", defaultTagSetting);
}
if (defaultForumLayout != null) {
channel2 = channel2.set("defaultForumLayout", defaultForumLayout);
}
if (iconEmoji !== void 0) {
channel2 = channel2.set("iconEmoji", iconEmoji);
}
if (themeColor != null) {
channel2 = channel2.set("themeColor", themeColor);
}
c4830_26();
},
CHANNEL_SETTINGS_SET_SECTION: function handleSetSection(a0) {
section = a0.section;
subsection = a0.subsection;
if (channel2 != null && section === ChannelSettingsSections.INSTANT_INVITES) {
loading = true;
const r25 = HTTP.get({
url: Endpoints.INSTANT_INVITES(channel2.id),
oldFormErrors: true,
rejectWithError: true
});
const r27 = $mk79195();
r25.then($mk79194(), r27);
}
},
CHANNEL_SETTINGS_LOADED_INVITES: function handleLoadedInvites(a0) {
invites = {};
a0.invites.forEach((invite) => {
invites[invite.code] = _createInvite(invite);
});
},
CHANNEL_UPDATES: function handleChannelUpdates({ channels }) {
if (channel2 == null) {
return false;
}
let r20 = false;
for (const item of channels) {
r20 = _syncChannelUpdate(item.id) || r20;
}
return r20;
},
THREAD_UPDATE: function handleThreadUpdate({ channel: channel4 }) {
return channel2 != null && _syncChannelUpdate(channel4.id);
},
CHANNEL_DELETE: function handleChannelDelete(a0) {
const id = a0.channel.id;
let r8 = channel2 != null;
if (r8) {
let r1 = channel2.id === id;
if (r1) {
CLOSED = FormStates.CLOSED;
r1 = void 0;
}
r8 = r1;
}
return r8;
},
INSTANT_INVITE_REVOKE_SUCCESS: function handleInviteRevoke(a0) {
invites = {
...invites
};
delete invites[a0.code];
},
INSTANT_INVITE_CREATE_SUCCESS: function handleInviteCreateSuccess(a0) {
const r2 = {
...invites
};
r2[a0.invite.code] = _createInvite(a0.invite);
invites = r2;
}
});
export default c4830_29;
+994
View File
@@ -0,0 +1,994 @@
// Metro module 1372 (f1373).
import BasicChannelCacheStore from "../modules/app_database/stores/BasicChannelCacheStore";
import FavoriteStore from "../modules/favorites/FavoriteStore";
import { castChannelRecord, GUILD_CHANNEL_TYPES, ALL_CHANNEL_TYPES, createChannelRecordFromServer, THREAD_CHANNEL_TYPES, isPrivate } from "../records/ChannelRecord";
import AuthenticationStore from "./AuthenticationStore";
import GuildStore from "./GuildStore";
import UserStore from "./UserStore";
import { ChannelTypes } from "../Constants";
import Logger from "../modules/debug/Logger";
import { isNotNullish } from "../utils/GlobalUtils";
import DatabaseDaos from "../modules/app_database/DatabaseDaos";
import { tryLoadOrResetCacheGateway, tryLoadOrResetCacheGatewayAsync } from "../modules/app_database/app/TryLoad";
import ChannelReader from "../modules/app_database/modules/channels/ChannelReader";
import Dispatcher from "../Dispatcher";
import deserializeChannels, { deserializeChannel } from "../modules/cache/deserializeChannels";
import Module10 from "../_bundle/Module10";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import isChangelogUser from "../modules/changelog/utils/isChangelogUser";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
function $mk113775($env) {
return (a0) => !$env[29].has(a0.guildId);
}
let deleteGuildChannels, getBasicChannel2, getChannel2, setChannel, setPrivateChannel, setThread, setGuildChannel, handleOneGuildCreate, deleteChannel, addThreadIfMissing, handleFavoritesUpdate, guildChannelCount, c1139_17, c1139_18, c1139_49, c1139_35, c1139_50;
let $mk69131 = function() {
return (a0) => isChangelogUser(a0);
};
let env1139 = {};
const ensureGuildLoaded = function ensureGuildLoaded(a0, a1, a2) {
let c13000_0, c13000_1;
L17: {
c13000_0 = a0;
if (a0 != null && a0 !== "null" && !env1139[29].has(a0)) {
if (a1 === c1139_35.Basic && BasicChannelCacheStore.hasGuild(a0)) {
break L17;
}
const r7 = DatabaseDaos.database();
c13000_1 = r7;
if (r7 != null) {
c1139_17.verbose(`hydrating guild (guild: ${a0}, trace: ${a2})`);
const r57 = tryLoadOrResetCacheGateway(`ensureGuildLoaded(${a0})`, () => ChannelReader.getSync(c13000_1, c13000_0), "ensureGuildLoaded");
if (r57 == null) {
env1139[29].add(a0);
BasicChannelCacheStore.restored(a0);
c1139_17.log(`load returned null; early returning (guild: ${a0}, database: ${r7})`);
return void 0;
}
const [r61, r62] = r57;
deserializeChannels(r61);
if (a1 !== c1139_35.Basic) {
env1139[34] = env1139[34] + 1;
}
env1139[29].add(a0);
BasicChannelCacheStore.restored(a0);
Module10.mark("❗", `loaded guild channels (guild: ${a0})`, r62);
for (const item of r61) {
if (!Object.hasOwn(env1139[19], item.id)) {
setGuildChannel((0, castChannelRecord)(item));
}
}
c1139_17.verbose(`hydration complete (guild: ${a0}, channels: ${r61.length}, guilds_loaded: ${env1139[34]})`);
}
}
}
};
deleteGuildChannels = function deleteGuildChannels(a0) {
c1139_17.fileOnly(`Deleting guild channels for ${a0}`);
if (env1139[20][a0] != null) {
for (const item of SnowflakeUtils.keys(env1139[20][a0])) {
delete env1139[19][item];
}
delete env1139[20][a0];
}
if (env1139[24][a0] != null) {
delete env1139[24][a0];
}
};
getBasicChannel2 = function getBasicChannel(a0) {
const Basic = c1139_35.Basic;
if (!Object.hasOwn(env1139[19], a0) && !Object.hasOwn(env1139[21], a0) && !Object.hasOwn(env1139[23], a0) && !Object.hasOwn(env1139[28], a0) && Basic === c1139_35.Full) {
const basicChannel = BasicChannelCacheStore.getBasicChannel(a0);
if (basicChannel?.guild_id != null) {
ensureGuildLoaded(basicChannel.guild_id, Basic, "getBasicChannel");
}
}
let r34 = env1139[19][a0];
if (r34 == null) {
r34 = env1139[21][a0];
}
if (r34 == null) {
r34 = env1139[23][a0];
}
if (r34 == null) {
r34 = env1139[28][a0];
}
if (r34 == null) {
r34 = BasicChannelCacheStore.getBasicChannel(a0);
}
return r34;
};
getChannel2 = function getChannel(a0) {
const Full = c1139_35.Full;
if (!Object.hasOwn(env1139[19], a0) && !Object.hasOwn(env1139[21], a0) && !Object.hasOwn(env1139[23], a0) && !Object.hasOwn(env1139[28], a0) && Full === c1139_35.Full) {
const basicChannel = BasicChannelCacheStore.getBasicChannel(a0);
if (basicChannel?.guild_id != null) {
ensureGuildLoaded(basicChannel.guild_id, Full, "getChannel");
}
}
let r34 = env1139[19][a0];
if (r34 == null) {
r34 = env1139[21][a0];
}
if (r34 == null) {
r34 = env1139[23][a0];
}
if (r34 == null) {
r34 = env1139[28][a0];
}
if (r34 == null) {
r34 = env1139[32][a0];
}
return r34;
};
setChannel = function setChannel(a0) {
if (a0.isPrivate()) {
delete env1139[32][a0.id];
if (a0.recipients.find($mk69131()) == null) {
env1139[21][a0.id] = a0;
if (a0.type === ChannelTypes.DM) {
env1139[25][a0.getRecipientId()] = a0.id;
}
env1139[26] = env1139[26] + 1;
}
} else if (a0.isThread()) {
const r11 = env1139[19][a0.parent_id];
env1139[23][a0.id] = a0.merge.call(a0, {
nsfw: r11?.nsfw === true,
parentChannelThreadType: r11?.type
});
if (a0.isScheduledForDeletion()) {
Dispatcher.dispatch({
type: "THREAD_DELETE",
channel: a0
});
}
} else if (GUILD_CHANNEL_TYPES.has(a0.type)) {
const { id, guild_id } = a0;
env1139[19][id] = a0;
const r9 = env1139[20];
let r20 = r9[guild_id];
if (r20 == null) {
r20 = {};
}
r9[guild_id] = r20;
env1139[20][guild_id][id] = a0;
const r23 = env1139[27];
let r24 = r23[guild_id];
if (r24 == null) {
r24 = 0;
}
r23[guild_id] = r24 + 1;
if (a0.linkedLobby != null) {
const r29 = env1139[24];
let r30 = r29[guild_id];
if (r30 == null) {
r30 = {};
}
r29[guild_id] = r30;
env1139[24][guild_id][id] = a0;
} else {
const r28 = env1139[24][guild_id];
if (r28 != null) {
delete r28[id];
}
}
}
};
setPrivateChannel = function setPrivateChannel(a0) {
if (a0.recipients.find($mk69131()) != null) {
return false;
}
env1139[21][a0.id] = a0;
if (a0.type === ChannelTypes.DM) {
env1139[25][a0.getRecipientId()] = a0.id;
}
env1139[26] = env1139[26] + 1;
};
setThread = function setThread(a0) {
const r10 = env1139[19][a0.parent_id];
env1139[23][a0.id] = a0.merge.call(a0, {
nsfw: r10?.nsfw === true,
parentChannelThreadType: r10?.type
});
if (a0.isScheduledForDeletion()) {
Dispatcher.dispatch({
type: "THREAD_DELETE",
channel: a0
});
}
};
setGuildChannel = function setGuildChannel(a0) {
const { id, guild_id } = a0;
env1139[19][id] = a0;
const r8 = env1139[20];
let r9 = r8[guild_id];
if (r9 == null) {
r9 = {};
}
r8[guild_id] = r9;
env1139[20][guild_id][id] = a0;
const r12 = env1139[27];
let r13 = r12[guild_id];
if (r13 == null) {
r13 = 0;
}
r12[guild_id] = r13 + 1;
if (a0.linkedLobby != null) {
const r18 = env1139[24];
let r19 = r18[guild_id];
if (r19 == null) {
r19 = {};
}
r18[guild_id] = r19;
env1139[24][guild_id][id] = a0;
} else {
const r17 = env1139[24][guild_id];
if (r17 != null) {
delete r17[id];
}
}
};
handleOneGuildCreate = function handleOneGuildCreate({ id, channels, threads }) {
const op = channels.op;
if (op === "full_sync") {
c1139_17.fileOnly(`ConnectionOpen contained full channels for ${id} #:${channels.items.length}`);
deleteGuildChannels(id);
env1139[29].add(id);
BasicChannelCacheStore.restored(id);
for (const item of channels.items) {
setGuildChannel(item);
}
} else if (op === "update") {
if (channels.writes.length > 0 || channels.deletes.length > 0) {
BasicChannelCacheStore.invalidate(id);
}
for (const delete2 of channels.deletes) {
deleteChannel(env1139[19][delete2]);
}
for (const write of channels.writes) {
setGuildChannel(write);
}
}
if (threads != null) {
for (const item2 of threads) {
setThread(item2);
}
}
};
const handleThreadCreateOrUpdate = function handleThreadCreateOrUpdate(a0) {
let channel;
if (ALL_CHANNEL_TYPES.has(a0.channel.type)) {
const channel2 = getChannel2(a0.channel.id);
if (channel2 == null) {
channel = a0.channel;
} else {
const r20 = {
...a0.channel.toJS()
};
let bitrate = a0.channel.bitrate;
if (bitrate == null) {
bitrate = channel2.bitrate;
}
r20.bitrate = bitrate;
channel = channel2.merge(r20);
}
setChannel(channel);
return void 0;
}
return false;
};
const handleLoadArchivedThreadsSuccess = function handleLoadArchivedThreadsSuccess(a0) {
a0.threads.forEach((thread) => {
if (ALL_CHANNEL_TYPES.has(thread.type)) {
setChannel((0, createChannelRecordFromServer)(thread));
}
});
};
deleteChannel = function deleteChannel(a0) {
L23: {
if (a0 != null) {
const guild_id = a0.guild_id;
if (a0.id in env1139[21]) {
delete env1139[21][a0.id];
}
if (a0.id in env1139[19]) {
delete env1139[19][a0.id];
}
if (a0.id in env1139[23]) {
delete env1139[23][a0.id];
}
if (guild_id != null) {
if (env1139[20][guild_id] != null && a0.id in env1139[20][guild_id]) {
delete env1139[20][guild_id][a0.id];
}
if (env1139[24][guild_id] != null && a0.id in env1139[24][guild_id]) {
delete env1139[24][guild_id][a0.id];
}
}
if (a0.guild_id != null && !THREAD_CHANNEL_TYPES.has(a0.type)) {
const r50 = env1139[27];
const guild_id2 = a0.guild_id;
let r53 = env1139[27][a0.guild_id];
if (r53 == null) {
r53 = 0;
}
r50[guild_id2] = r53 + 1;
break L23;
}
if ((0, isPrivate)(a0.type)) {
env1139[26] = env1139[26] + 1;
}
}
}
};
const handleDeleteChannel = function handleDeleteChannel({ channel }) {
let r8 = env1139[19][channel.id];
if (r8 == null) {
r8 = env1139[21][channel.id];
}
if (r8 == null) {
r8 = env1139[23][channel.id];
}
if (r8 == null) {
return false;
}
deleteChannel(r8);
if (!("basicPermissions" in r8) && r8.type === ChannelTypes.DM) {
const recipientId = r8.getRecipientId();
if (env1139[25][recipientId] === r8.id) {
delete env1139[25][recipientId];
}
}
};
const handleLoadMessages = function handleLoadMessages(a0) {
for (const message of a0.messages) {
if (message.thread != null && !(message.thread.id in env1139[23]) && ALL_CHANNEL_TYPES.has(message.thread.type)) {
setThread((0, createChannelRecordFromServer)(message.thread));
}
}
};
const handleSearchMessagesSuccess = function handleSearchMessagesSuccess(a0) {
a0.data.forEach(({ messages, threads, channels }) => {
messages.forEach((message) => {
message.forEach((item) => {
addThreadIfMissing(item.thread);
});
});
threads.forEach(addThreadIfMissing);
channels.forEach((channel) => {
let r2, r9;
L6: {
L3: {
r9 = (0, createChannelRecordFromServer)(channel);
r2 = getChannel2(channel.id) != null;
const r14 = env1139[32][channel.id] != null;
if (r9.isPrivate()) {
if (r2 && !r14) {
break L3;
}
env1139[32][r9.id] = r9;
break L6;
}
}
if (!r2) {
setChannel(r9);
}
}
});
});
};
addThreadIfMissing = function addThreadIfMissing(a0) {
if (a0 != null && !(a0.id in env1139[23]) && ALL_CHANNEL_TYPES.has(a0.type)) {
const channel = (0, createChannelRecordFromServer)(a0);
const r10 = env1139[19][channel.parent_id];
env1139[23][channel.id] = channel.merge({
nsfw: r10?.nsfw === true,
parentChannelThreadType: r10?.type
});
if (channel.isScheduledForDeletion()) {
Dispatcher.dispatch({
type: "THREAD_DELETE",
channel
});
}
}
};
handleFavoritesUpdate = function handleFavoritesUpdate() {
env1139[28] = {};
const favoriteChannels = FavoriteStore.getFavoriteChannels();
for (const key in favoriteChannels) {
const categoryRecord = FavoriteStore.getCategoryRecord(key);
if (categoryRecord != null) {
env1139[28][key] = categoryRecord;
}
}
};
guildChannelCount = function guildChannelCount(a0) {
return env1139[20][a0] != null ? Object.keys(env1139[20][a0]).length : null;
};
c1139_17 = new Logger("ChannelStore");
c1139_18 = {};
env1139[19] = {};
env1139[20] = {};
env1139[21] = {};
env1139[22] = null;
env1139[23] = {};
env1139[24] = {};
env1139[25] = {};
env1139[26] = 0;
env1139[27] = {};
env1139[28] = {};
env1139[29] = new Set();
env1139[30] = {};
env1139[31] = 0;
env1139[32] = {};
env1139[33] = 0;
env1139[34] = 0;
c1139_49 = void 0;
export class ChannelLoader {
constructor() {
return {
__proto__: new.target.prototype
};
}
static loadAllMissingChannels() {
return this.loadGuildIds(GuildStore.getGuildIds().filter((item) => !env1139[29].has(item)));
}
static loadGuildFromChannelId(a0) {
return a0 == null ? null : c1139_49.loadGuildIds([getBasicChannel2(a0)?.guild_id]);
}
static loadGuildIds(a0) {
let env13001 = {
$parent: env1139
};
const r12 = a0.filter.call(a0, isNotNullish);
env13001[0] = r12;
if (r12.length === 0) {
return null;
}
const r18 = DatabaseDaos.database();
env13001[1] = r18;
if (r18 == null) {
return null;
}
if (r12.some((item) => !env1139[29].has(item))) {
env13001[2] = env1139[31];
return tryLoadOrResetCacheGatewayAsync("loadChannels", async () => {
let r34;
let c24400_0, c24400_1, c24400_2, c24400_3, c24400_4;
let c24400_5 = 0;
const r14 = env13001;
L14: {
try {
let env28883;
c24400_3 = r14;
const r44 = env28883 = {
$parent: r14
};
c24400_2 = r44;
env28883[0] = void 0;
env28883[1] = void 0;
env28883[2] = void 0;
env28883[3] = void 0;
const r51 = env13001[0].map((item) => {
const guildId = item;
if (env1139[29].has(item)) {
return null;
}
if (env1139[30][item] != null) {
c1139_17.fileOnly(`Skipping loading ${item} because a load is pending`);
return null;
}
const promise = ChannelReader.getAsync(env13001[1], item).then((result) => {
c1139_17.fileOnly(`Lazy loaded channels for ${guildId} #:${result.length}`);
return {
guildId,
channels: result
};
});
env1139[30][item] = promise;
return {
guildId: item,
promise
};
}).filter(isNotNullish);
env28883[0] = r51;
const r54 = r51.map((item) => item.promise);
c24400_5 = 1;
const r63 = await Promise.all(r54);
const r79 = c24400_3;
env28883[1] = r63;
if (r79.$parent[31] !== env13001[2]) {
c1139_17.fileOnly("lastResetTime has changed, skipping loads for " + env28883[0].map((item) => item.guildId));
c24400_5 = 0;
break L14;
}
env28883[2] = env28883[1].filter($mk113775(env13001.$parent));
await Dispatcher.dispatch({
type: "LOAD_CHANNELS",
channels: env28883[2]
});
c24400_5 = 0;
} catch ($e) {
const r42 = $e;
let r7 = r42;
c24400_4 = r42;
let r43 = c24400_5;
if (r43 !== 0) {
while (true) {
if (r43 === 1) {
try {
const r137 = c24400_4;
c24400_5 = 0;
env28883[4] = r137;
c1139_17.error("Failed to load channels from disk for " + env28883[0].map((item) => item.guildId), env28883[4]);
const r149 = env28883[0];
c24400_1 = r149;
const r151 = r149[Symbol.iterator]();
c24400_1 = r151.next;
c24400_0 = r151;
while (true) {
const r153 = c24400_1;
let r154 = c24400_0;
const r155 = r154 === void 0 ? void 0 : (r34 = r153.call(r154)).done ? r154 = void 0 : r34.value;
c24400_0 = r154;
if (r154 === void 0) {
throw env28883[4];
}
const r159 = c24400_3;
c24400_5 = 2;
env28883[3] = r155;
delete r159.$parent[30][env28883[3].guildId];
c24400_5 = 0;
}
} catch (r134) {
r7 = r134;
c24400_4 = r134;
r43 = c24400_5;
if (r43 === 0) {
break;
}
}
} else {
try {
const r129 = c24400_4;
c24400_5 = 0;
const r131 = c24400_0;
if (r131 !== void 0 && typeof r131.return === "function") {
try {
r131.return();
} catch {}
}
throw r129;
} catch (r128) {
r7 = r128;
c24400_4 = r128;
r43 = c24400_5;
if (r43 === 0) {
break;
}
}
}
}
}
throw r7;
}
return null;
}
return null;
});
}
return null;
}
}
c1139_49 = ChannelLoader;
c1139_35 = {
Basic: 0,
0: "Basic",
Full: 1,
1: "Full"
};
class ChannelStore extends Module589.Store {
static displayName = "ChannelStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(AuthenticationStore, BasicChannelCacheStore, FavoriteStore, GuildStore, UserStore);
this.syncWith([FavoriteStore], handleFavoritesUpdate);
}
hasChannel(a0) {
return getBasicChannel2(a0) != null;
}
getBasicChannel(a0) {
if (a0 != null) {
return getBasicChannel2(a0);
}
}
getChannel(a0) {
if (a0 != null) {
return getChannel2(a0);
}
}
loadAllGuildAndPrivateChannelsFromDisk() {
for (const item of GuildStore.getGuildIds()) {
ensureGuildLoaded(item, c1139_35.Full, "loadAllGuildAndPrivateChannelsFromDisk");
}
return {
...env1139[19],
...env1139[21]
};
}
getChannelIds(a0) {
let r19;
ensureGuildLoaded(a0, c1139_35.Basic, "getChannelIds");
if (a0 == null) {
r19 = SnowflakeUtils.keys(env1139[21]);
} else {
let r17 = BasicChannelCacheStore.getGuildBasicChannels(a0);
if (r17 == null) {
r17 = env1139[20][a0];
}
if (r17 == null) {
r17 = c1139_18;
}
r19 = SnowflakeUtils.keys(r17);
}
return r19;
}
getMutablePrivateChannels() {
return env1139[21];
}
getMutableBasicGuildChannelsForGuild(a0) {
ensureGuildLoaded(a0, c1139_35.Basic, "getMutableBasicGuildChannelsForGuild");
let r10 = BasicChannelCacheStore.getGuildBasicChannels(a0);
if (r10 == null) {
r10 = env1139[20][a0];
}
if (r10 == null) {
r10 = c1139_18;
}
return r10;
}
getMutableGuildChannelsForGuild(a0) {
ensureGuildLoaded(a0, c1139_35.Full, "getMutableGuildChannelsForGuild");
let r9 = env1139[20][a0];
if (r9 == null) {
r9 = c1139_18;
}
return r9;
}
getSortedLinkedChannelsForGuild(a0) {
let r9 = env1139[24][a0];
if (r9 == null) {
r9 = c1139_18;
}
return Module12.values(r9).sort((a, b) => SnowflakeUtils.compare(a.id, b.id));
}
getSortedPrivateChannels() {
return Module12(env1139[21]).values().sort((a, b) => SnowflakeUtils.compare(a.lastMessageId, b.lastMessageId)).reverse().value();
}
getDMFromUserId(a0) {
if (a0 != null) {
return env1139[25][a0];
}
}
getDMChannelFromUserId(a0) {
if (a0 != null) {
return this.getChannel(env1139[25][a0]);
}
}
getMutableDMsByUserIds() {
return env1139[25];
}
getDMUserIds() {
return SnowflakeUtils.keys(env1139[25]);
}
getPrivateChannelsVersion() {
return env1139[26];
}
getGuildChannelsVersion(a0) {
let r5 = env1139[27][a0];
if (r5 == null) {
r5 = 0;
}
return r5;
}
getAllThreadsForParent(c13002_0) {
return Module12.values(env1139[23]).filter((item) => item.parent_id === c13002_0);
}
getAllThreadsForGuild(c13003_0) {
return Module12.values(env1139[23]).filter((item) => item.guild_id === c13003_0);
}
getInitialOverlayState() {
return {
...env1139[19],
...env1139[21],
...env1139[23]
};
}
getDebugInfo() {
return {
loadedGuildIds: Array.from(env1139[29]).sort(SnowflakeUtils.compare),
pendingGuildLoads: Object.keys(env1139[30]).sort(SnowflakeUtils.compare),
guildSizes: Object.keys(env1139[20]).sort(SnowflakeUtils.compare).map((item) => `${item}: ${env1139[20][item] != null ? Object.keys(env1139[20][item]).length : null}`)
};
}
}
c1139_50 = ChannelStore;
const r163 = new ChannelStore(Dispatcher, {
BACKGROUND_SYNC: function handleBackgroundSync({ guilds }) {
let c13004_0 = env1139[20];
env1139[19] = {};
env1139[20] = {};
env1139[27] = {};
env1139[24] = {};
guilds.forEach((guild) => {
if (guild.data_mode === "unavailable") {
const { id: id3, id: id4 } = guild;
c1139_17.fileOnly(`Restoring guild channels b/c unavailable in bg sync, for ${id3} #:${env1139[20][id4] != null ? Object.keys(env1139[20][id4]).length : null}`);
Module12.forEach(c13004_0[guild.id], setGuildChannel);
} else if (guild.data_mode === "partial") {
const { id: id2, id } = guild;
c1139_17.fileOnly(`Restoring guild channels b/c partial in bg sync, for ${id2} #:${env1139[20][id] == null ? null : Object.keys(env1139[20][id]).length}`);
Module12.forEach(c13004_0[guild.id], setGuildChannel);
let deleted_channel_ids = guild.partial_updates.deleted_channel_ids;
if (deleted_channel_ids == null) {
deleted_channel_ids = [];
}
if (deleted_channel_ids.length > 0) {
ensureGuildLoaded(guild.id, c1139_35.Full, "handleBackgroundSync");
deleted_channel_ids.forEach((deleted_channel_id) => {
deleteChannel(env1139[19][deleted_channel_id]);
});
}
const channels = guild.partial_updates.channels;
if (channels != null) {
channels.forEach((channel) => {
const r12 = (0, createChannelRecordFromServer)(channel, guild.id);
const { id, guild_id } = r12;
env1139[19][id] = r12;
const r9 = env1139[20];
let r15 = r9[guild_id];
if (r15 == null) {
r15 = {};
}
r9[guild_id] = r15;
env1139[20][guild_id][id] = r12;
const r18 = env1139[27];
let r19 = r18[guild_id];
if (r19 == null) {
r19 = 0;
}
r18[guild_id] = r19 + 1;
if (r12.linkedLobby != null) {
const r24 = env1139[24];
let r25 = r24[guild_id];
if (r25 == null) {
r25 = {};
}
r24[guild_id] = r25;
env1139[24][guild_id][id] = r12;
} else {
const r23 = env1139[24][guild_id];
if (r23 != null) {
delete r23[id];
}
}
});
}
} else {
c1139_17.fileOnly(`BG sync contained full channels for ${guild.id} #:${guild.channels.length}`);
deleteGuildChannels(guild.id);
env1139[29].add(guild.id);
BasicChannelCacheStore.restored(guild.id);
guild.channels.forEach((channel) => {
const r12 = (0, createChannelRecordFromServer)(channel, guild.id);
const { id, guild_id } = r12;
env1139[19][id] = r12;
const r9 = env1139[20];
let r15 = r9[guild_id];
if (r15 == null) {
r15 = {};
}
r9[guild_id] = r15;
env1139[20][guild_id][id] = r12;
const r18 = env1139[27];
let r19 = r18[guild_id];
if (r19 == null) {
r19 = 0;
}
r18[guild_id] = r19 + 1;
if (r12.linkedLobby != null) {
const r24 = env1139[24];
let r25 = r24[guild_id];
if (r25 == null) {
r25 = {};
}
r24[guild_id] = r25;
env1139[24][guild_id][id] = r12;
} else {
const r23 = env1139[24][guild_id];
if (r23 != null) {
delete r23[id];
}
}
});
}
});
},
CACHE_LOADED_LAZY: function handleLazyCacheLoaded(a0) {
env1139[33] = Math.max(env1139[33], a0.guilds.length);
for (const guildChannel of a0.guildChannels) {
const [r12, r11] = guildChannel;
c1139_17.fileOnly(`Lazy cache contained full guild channels for ${r12} #:${r11.length}`);
env1139[29].add(r12);
for (const item of r11) {
setChannel((0, castChannelRecord)(item));
}
}
},
CACHE_LOADED: function handleCacheLoaded(a0) {
env1139[33] = Math.max(env1139[33], a0.guilds.length);
const { privateChannels, initialGuildChannels } = a0;
for (const item of [privateChannels, initialGuildChannels]) {
for (const item2 of item) {
setChannel(deserializeChannel((0, castChannelRecord)(item2)));
}
}
const guild_id = initialGuildChannels[0]?.guild_id;
if (guild_id != null) {
c1139_17.fileOnly(`Early cache contained full guild channels for ${guild_id}`);
env1139[29].add(guild_id);
}
},
CHANNEL_CREATE: function handleChannelCreate(a0) {
setChannel(a0.channel);
},
CHANNEL_DELETE: handleDeleteChannel,
CHANNEL_RECIPIENT_ADD: function handleAddRecipient(a0) {
const channel2 = getChannel2(a0.channelId);
const id = AuthenticationStore.getId();
let r15 = !!(channel2 == null ? void 0 : channel2.isPrivate());
if (r15) {
setChannel(channel2.addRecipient(a0.user.id, a0.nick, id));
r15 = true;
}
return r15;
},
CHANNEL_RECIPIENT_REMOVE: function handleRemoveRecipient(a0) {
const channel2 = getChannel2(a0.channelId);
let r12 = !!(channel2 == null ? void 0 : channel2.isPrivate());
if (r12) {
setChannel(channel2.removeRecipient(a0.user.id));
r12 = true;
}
return r12;
},
CHANNEL_UPDATES: function handleUpdateChannels(a0) {
const r19 = a0.channels.some((channel) => {
const channel2 = getChannel2(channel.id);
return channel.nsfw !== channel2?.nsfw || channel.type !== channel2?.type;
});
for (const channel of a0.channels) {
setChannel(channel);
}
if (r19) {
Object.values(env1139[23]).forEach((item) => {
setChannel(item);
});
}
},
CONNECTION_OPEN_SUPPLEMENTAL: function handleConnectionOpenSupplemental({ lazyPrivateChannels }) {
if (env1139[22] != null) {
env1139[21] = {};
env1139[22].forEach(setPrivateChannel);
}
lazyPrivateChannels.forEach(setPrivateChannel);
},
CONNECTION_OPEN: function handleConnectionOpen(a0) {
const r9 = env1139[20];
env1139[25] = {};
env1139[19] = {};
env1139[20] = {};
env1139[24] = {};
env1139[23] = {};
env1139[27] = {};
env1139[32] = {};
env1139[30] = {};
env1139[31] = Date.now();
env1139[22] = a0.initialPrivateChannels;
a0.initialPrivateChannels.forEach(setPrivateChannel);
for (const guild of a0.guilds) {
if (guild.dataMode === "partial") {
Module12.forEach(r9[guild.id], setGuildChannel);
c1139_17.fileOnly(`Restoring guild channels for ${guild.id} #:${guildChannelCount(guild.id)}`);
}
handleOneGuildCreate(guild);
}
handleFavoritesUpdate();
},
CHANNEL_PERMISSIONS_PUT_OVERWRITE_SUCCESS: function handlePutOverwriteSuccess({ channelId, overwrite }) {
const channel2 = getChannel2(channelId);
if (channel2 == null) {
return false;
}
const r12 = {
...channel2.permissionOverwrites
};
r12[overwrite.id] = overwrite;
setChannel(channel2.set("permissionOverwrites", r12));
},
CHANNEL_PERMISSIONS_DELETE_OVERWRITE_SUCCESS: function handleDeleteOverwriteSuccess({ channelId, overwriteId }) {
const channel2 = getChannel2(channelId);
if (channel2 == null) {
return false;
}
const r10 = {
...channel2.permissionOverwrites
};
delete r10[overwriteId];
setChannel(channel2.set("permissionOverwrites", r10));
},
GUILD_CREATE: function handleCreateGuild(a0) {
handleOneGuildCreate(a0.guild);
},
GUILD_DELETE: function handleGuildDelete(a0) {
c1139_17.fileOnly(`GuildDelete of ${a0.guild.id}`);
deleteGuildChannels(a0.guild.id);
env1139[29].delete(a0.guild.id);
BasicChannelCacheStore.invalidate(a0.guild.id);
},
LOAD_ARCHIVED_THREADS_SUCCESS: handleLoadArchivedThreadsSuccess,
LOAD_CHANNELS: function handleLoadChannels(a0) {
for (const channel of a0.channels) {
const { guildId: guildId2, channels } = channel;
c1139_17.fileOnly(`Lazy loaded guild channels for ${guildId2}`);
deserializeChannels(channels);
env1139[29].add(guildId2);
BasicChannelCacheStore.restored(guildId2);
for (const item of channels) {
if (!Object.hasOwn(env1139[19], item.id)) {
setGuildChannel((0, castChannelRecord)(item));
}
}
}
return false;
},
LOAD_MESSAGES_AROUND_SUCCESS: handleLoadMessages,
LOAD_MESSAGES_SUCCESS: handleLoadMessages,
LOAD_THREADS_SUCCESS: handleLoadArchivedThreadsSuccess,
LOGOUT: function handleLogout() {
c1139_17.fileOnly("initializeClear()");
env1139[25] = {};
env1139[19] = {};
env1139[20] = {};
env1139[27] = {};
env1139[24] = {};
env1139[21] = {};
env1139[32] = {};
env1139[23] = {};
env1139[29] = new Set();
env1139[30] = {};
env1139[31] = Date.now();
},
OVERLAY_INITIALIZE: function handleInitialize(a0) {
for (const channel of a0.channels) {
setChannel(deserializeChannel((0, castChannelRecord)(channel)));
}
},
SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
MOD_VIEW_SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
THREAD_CREATE: handleThreadCreateOrUpdate,
THREAD_DELETE: handleDeleteChannel,
THREAD_LIST_SYNC: function handleThreadListSync(a0) {
a0.threads.forEach((thread) => {
if (ALL_CHANNEL_TYPES.has(thread.type)) {
setChannel(thread);
}
});
},
THREAD_UPDATE: handleThreadCreateOrUpdate
});
export default r163;
+53
View File
@@ -0,0 +1,53 @@
// Metro module 5780 (f5781).
import ChannelStore from "./ChannelStore";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c3596_3, c3596_4;
const handleConnectionOpen = function handleConnectionOpen() {
SnowflakeUtils.keys(c3596_4).forEach((item) => {
if (ChannelStore.getChannel(item) == null) {
delete c3596_4[item];
}
});
};
c3596_3 = {};
c3596_4 = c3596_3;
class CollapsedVoiceChannelStore extends Module589.PersistedStore {
static displayName = "CollapsedVoiceChannelStore";
static persistKey = "collapsedChannels";
initialize(a0) {
let r1 = a0;
this.waitFor(ChannelStore);
if (a0 == null) {
r1 = c3596_3;
}
c3596_4 = r1;
}
getState() {
return c3596_4;
}
getCollapsed() {
return c3596_4;
}
isCollapsed(a0) {
return c3596_4[a0] || false;
}
}
const collapsedVoiceChannelStore = new CollapsedVoiceChannelStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
CHANNEL_COLLAPSE: function handleChannelCollapse({ channelId }) {
const r4 = c3596_4[channelId];
const r8 = c3596_4;
if (r4) {
delete r8[channelId];
} else {
r8[channelId] = true;
}
c3596_4 = {
...c3596_4
};
}
});
export default collapsedVoiceChannelStore;
+113
View File
@@ -0,0 +1,113 @@
// Metro module 4869 (f4870).
import ConnectedAccountRecord from "../records/ConnectedAccountRecord";
import { PlatformTypes } from "../Constants";
import Platforms from "../lib/Platforms";
import { fromGuildBasic } from "../utils/GuildRecordUtils";
import ConnectedAccountsActionCreators from "../actions/ConnectedAccountsActionCreators";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let $mk75138 = function() {
return (a0) => {
const r6 = c3000_4.has(a0.type);
return r6 ? !r6 : Platforms.isSupported(a0.type);
};
}, $mk75139 = function() {
return (a0) => c3000_4.has(a0.type);
};
let c3000_4 = new Set([PlatformTypes.CONTACTS]);
let c3000_5 = true;
let c3000_6 = [];
let c3000_7 = [];
let c3000_8 = {};
let c3000_9 = new Set();
let c3000_10 = {};
let c3000_11 = {};
class ConnectedAccountsStore extends Module589.Store {
static displayName = "ConnectedAccountsStore";
isJoining(a0) {
return c3000_8[a0] || false;
}
joinErrorMessage(a0) {
return c3000_11[a0];
}
isFetching() {
return c3000_5;
}
getAccounts() {
return c3000_6;
}
getLocalAccounts() {
return c3000_7;
}
getAccount(c14487_0, c14487_1) {
return c3000_6.find((item) => (c14487_0 == null || item.id === c14487_0) && item.type === c14487_1);
}
getLocalAccount(c14488_0) {
return c3000_7.find((item) => item.type === c14488_0);
}
isSuggestedAccountType(a0) {
return c3000_10[a0] || false;
}
addPendingAuthorizedState(a0) {
c3000_9.add(a0);
}
deletePendingAuthorizedState(a0) {
c3000_9.delete(a0);
}
hasPendingAuthorizedState(a0) {
return c3000_9.has(a0);
}
}
const connectedAccountsStore = new ConnectedAccountsStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
const r6 = a0.connectedAccounts.map((connectedAccount) => new ConnectedAccountRecord(connectedAccount));
c3000_6 = r6.filter($mk75138());
c3000_7 = r6.filter($mk75139());
c3000_5 = false;
},
USER_CONNECTIONS_UPDATE: function handleConnectionsUpdate(a0) {
if (a0.local && a0.accounts != null) {
const r15 = a0.accounts.map((account) => new ConnectedAccountRecord({
...account,
integrations: account.integrations.map((integration) => ({
...integration,
guild: fromGuildBasic({
...integration.guild,
features: []
})
}))
}));
c3000_6 = r15.filter($mk75138());
c3000_7 = r15.filter($mk75139());
c3000_5 = false;
} else {
ConnectedAccountsActionCreators.fetch();
}
},
USER_CONNECTIONS_INTEGRATION_JOINING: function handleJoining(a0) {
c3000_8[a0.integrationId] = a0.joining;
},
USER_CONNECTION_UPDATE: function handleUserConnectionUpdate({ platformType, id, revoked, accessToken }) {
const r11 = c3000_6.find((item) => item.id === id && item.type === platformType);
if (r11 == null) {
return false;
}
if (revoked != null) {
r11.revoked = revoked;
}
if (accessToken != null) {
r11.accessToken = accessToken;
}
},
USER_CONNECTIONS_INTEGRATION_JOINING_ERROR: function handleJoiningError(a0) {
c3000_11[a0.integrationId] = a0.error !== void 0 ? a0.error : "";
},
USER_CONNECTIONS_CALLBACK: function handleUserConnectionsCallback(a0) {
ConnectedAccountsActionCreators.callback(a0.provider, {
code: a0.code,
state: a0.state,
openid_params: a0.openid_params
});
}
});
export default connectedAccountsStore;
+64
View File
@@ -0,0 +1,64 @@
// Metro module 5124 (f5125).
import Module589 from "../_bundle/Module589";
import Module12 from "../_bundle/Module12";
import Dispatcher from "../Dispatcher";
let c3086_2 = {};
class ConnectedAppsStore extends Module589.Store {
static displayName = "ConnectedAppsStore";
isConnected(a0) {
return c3086_2[a0] != null;
}
isChildConnected(a0) {
return a0 != null && Object.values(c3086_2).some((item) => item.parentId === a0);
}
get connections() {
return Module12.values(c3086_2);
}
getApplication(a0) {
return c3086_2[a0];
}
getAllConnections() {
return c3086_2;
}
}
const connectedAppsStore = new ConnectedAppsStore(Dispatcher, {
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
c3086_2 = {
...a0.connectedApps
};
},
RPC_APP_CONNECTED: function handleAppConnection({ application }) {
if (application.id == null) {
return false;
}
const id = application.id;
if (c3086_2[id] == null) {
c3086_2[id] = {
count: 0,
id: application.id,
parentId: application.parentId,
name: application.name,
icon: application.icon,
coverImage: application.coverImage,
authenticated: false
};
}
const r16 = c3086_2[id];
r16.count = r16.count + 1;
},
RPC_APP_AUTHENTICATED: function handleAppAuthenticated({ application }) {
if (application.id != null && c3086_2[application.id] != null) {
c3086_2[application.id].authenticated = true;
}
},
RPC_APP_DISCONNECTED: function handleAppDisconnection({ application }) {
if (application.id != null && c3086_2[application.id] != null) {
const r12 = c3086_2[application.id];
r12.count = r12.count - 1;
if (c3086_2[application.id].count === 0) {
delete c3086_2[application.id];
}
}
}
});
export default connectedAppsStore;
+55
View File
@@ -0,0 +1,55 @@
// Metro module 5643 (f5644).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c3483_0 = false;
let c3483_1 = false;
let c3483_2 = {};
let consentRequired = null;
class ConsentStore extends Module589.Store {
static displayName = "ConsentStore";
hasConsented(a0) {
return c3483_2[a0] != null && c3483_2[a0].consented;
}
get consents() {
return c3483_2;
}
get fetchedConsents() {
return c3483_0;
}
get receivedConsentsInConnectionOpen() {
return c3483_1;
}
getAuthenticationConsentRequired() {
return consentRequired;
}
}
const consentStore = new ConsentStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen({ consents: consents2 }) {
if (consents2 != null) {
c3483_2 = {
...c3483_2,
...consents2
};
c3483_1 = true;
}
},
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
c3483_2 = {
...a0.consents
};
c3483_0 = true;
},
UPDATE_CONSENTS: function handleUpdateConsents(a0) {
c3483_2 = {
...a0.consents
};
c3483_0 = true;
},
SET_CONSENT_REQUIRED: function handleConsentRequired(a0) {
consentRequired = a0.consentRequired;
},
LOGOUT: function handleLogout() {
consentRequired = null;
}
});
export default consentStore;
+174
View File
@@ -0,0 +1,174 @@
// Metro module 8349 (f8350).
import ChannelStore from "./ChannelStore";
import GuildStore from "./GuildStore";
import InstantInviteStore from "./InstantInviteStore";
import { FormStates } from "../Constants";
import InstantInviteUtils from "../utils/InstantInviteUtils";
import { getDefaultInviteExpiration } from "../modules/instant_invite/DefaultInviteExpirationExperiments";
import Module38 from "../_bundle/Module38";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let guildId, message, invite, c5331_6, c5331_7, c5331_8, value, CLOSED, c5331_15;
const updateWithLatestInvite = function updateWithLatestInvite(a0, { targetType, targetUserId, targetApplicationId }) {
let maxAge = getDefaultInviteExpiration({
guild: GuildStore.getGuild(ChannelStore.getChannel(a0)?.guild_id)
});
const invite2 = InstantInviteStore.getInvite(a0, {
targetType,
targetUserId,
targetApplicationId
});
invite = invite2;
if (invite2 != null) {
maxAge = invite.maxAge;
}
const maxUses = invite != null ? invite.maxUses : value;
const temporary = invite != null && invite.temporary;
const flags = invite != null ? invite.flags : 0;
const r40 = invite == null;
let roleIds = void 0;
if (!r40) {
const roles = invite.roles;
roleIds = roles == null ? void 0 : roles.map((role) => role.id);
}
if (roleIds == null) {
roleIds = [];
}
const r27 = {
channelId: a0,
maxAge,
maxUses,
temporary,
flags,
targetType,
targetUserId,
targetApplicationId,
roleIds
};
c5331_6 = r27;
c5331_7 = r27;
};
value = InstantInviteUtils.INVITE_OPTIONS_UNLIMITED.value;
CLOSED = FormStates.CLOSED;
c5331_15 = false;
class CreateInviteModalStore extends Module589.Store {
static displayName = "CreateInviteModalStore";
initialize() {
this.waitFor(ChannelStore, GuildStore, InstantInviteStore);
}
init() {
this.waitFor(InstantInviteStore);
}
isOpen() {
return CLOSED !== FormStates.CLOSED;
}
isSubmitting() {
return c5331_15;
}
getGuildId() {
return guildId;
}
getError() {
return message;
}
getInvite() {
return invite;
}
getInviteSettings() {
return c5331_6;
}
getPendingSettings() {
return c5331_7;
}
getProps() {
return {};
}
get onClose() {
return c5331_8;
}
}
const createInviteModalStore = new CreateInviteModalStore(Dispatcher, {
CREATE_INVITE_MODAL_INIT: function handleInit(a0) {
guildId = a0.guildId;
message = null;
let targetType = a0.targetType;
if (targetType == null) {
targetType = null;
}
let targetUserId = a0.targetUserId;
if (targetUserId == null) {
targetUserId = null;
}
let targetApplicationId = a0.targetApplicationId;
if (targetApplicationId == null) {
targetApplicationId = null;
}
updateWithLatestInvite(a0.channelId, {
targetType,
targetUserId,
targetApplicationId
});
},
CREATE_INVITE_MODAL_OPEN: function handleModalOpen(a0) {
CLOSED = FormStates.OPEN;
let onClose2 = a0.onClose;
if (onClose2 == null) {
onClose2 = void 0;
}
c5331_8 = onClose2;
guildId = a0.guildId;
message = null;
let targetType = a0.targetType;
if (targetType == null) {
targetType = null;
}
let targetUserId = a0.targetUserId;
if (targetUserId == null) {
targetUserId = null;
}
let targetApplicationId = a0.targetApplicationId;
if (targetApplicationId == null) {
targetApplicationId = null;
}
updateWithLatestInvite(a0.channelId, {
targetType,
targetUserId,
targetApplicationId
});
},
CREATE_INVITE_MODAL_UPDATE_SETTINGS: function handleUpdateSettings({ settings }) {
if (c5331_7 != null) {
c5331_7 = {
...c5331_7,
...settings
};
}
},
CREATE_INVITE_MODAL_RESET_SETTINGS: function handleResetSettings() {
c5331_7 = c5331_6;
},
CREATE_INVITE_MODAL_GENERATE_INVITE: function handleGenerateInvite() {
c5331_6 = c5331_7;
c5331_15 = true;
},
CREATE_INVITE_MODAL_GENERATE_INVITE_SUCCESS: function handleGenerateInviteSuccess({ channelId }) {
message = null;
c5331_15 = false;
Module38(c5331_6 != null, "No invite settings for generated invite");
updateWithLatestInvite(channelId, {
targetType: c5331_6.targetType,
targetUserId: c5331_6.targetUserId,
targetApplicationId: c5331_6.targetApplicationId
});
},
CREATE_INVITE_MODAL_GENERATE_INVITE_FAILURE: function handleGenerateInviteFailure(a0) {
invite = null;
c5331_15 = false;
message = a0.message;
},
CREATE_INVITE_MODAL_CLOSE: function handleModalClose() {
CLOSED = FormStates.CLOSED;
c5331_8 = void 0;
}
});
export default createInviteModalStore;
+65
View File
@@ -0,0 +1,65 @@
// Metro module 4010 (f4011).
import { Routes } from "../Constants";
import Module589 from "../_bundle/Module589";
import { Storage } from "../_bundle/Module595";
import Dispatcher from "../Dispatcher";
let c2287_3 = {
lastViewedPath: null,
lastViewedNonVoicePath: null
};
let c2287_4 = c2287_3;
let c2287_5 = "LAST_VIEWED_PATH";
class DefaultRouteStore extends Module589.PersistedStore {
static displayName = "DefaultRouteStore";
static persistKey = "DefaultRouteStore";
static migrations = [() => {
const lastViewedPath = Storage.get(c2287_5, null);
Storage.remove(c2287_5);
return {
lastViewedPath
};
}];
initialize(r2 = c2287_3) {
if (r2 == null) {
r2 = c2287_3;
}
c2287_4 = r2;
}
get defaultRoute() {
let lastViewedPath = c2287_4.lastViewedPath;
if (lastViewedPath == null) {
lastViewedPath = Routes.ME;
}
return lastViewedPath;
}
get lastNonVoiceRoute() {
let lastViewedNonVoicePath = c2287_4.lastViewedNonVoicePath;
if (lastViewedNonVoicePath == null) {
lastViewedNonVoicePath = Routes.ME;
}
return lastViewedNonVoicePath;
}
get fallbackRoute() {
return Routes.ME;
}
getState() {
return c2287_4;
}
}
const defaultRouteStore = new DefaultRouteStore(Dispatcher, {
SAVE_LAST_ROUTE: function handleSaveRoute(a0) {
c2287_4.lastViewedPath = a0.path;
return true;
},
SAVE_LAST_NON_VOICE_ROUTE: function handleSaveLastNonVoiceRoute(a0) {
c2287_4.lastViewedNonVoicePath = a0.path;
return true;
},
LOGOUT: function handleLogout() {
c2287_4 = {
lastViewedPath: null,
lastViewedNonVoicePath: null
};
}
});
export default defaultRouteStore;
+612
View File
@@ -0,0 +1,612 @@
// Metro module 4221 (f4222).
import ApplicationRecord, { createExecutable } from "../records/ApplicationRecord";
import { AnalyticEvents } from "../Constants";
import { ApplicationTypes } from "../modules/applications/ApplicationConstants";
import Durations from "../utils/Durations";
import CachedEntriesMap from "../lib/CachedEntriesMap";
import { Storage } from "../_bundle/Module595";
import { isDesktop, isWindows, isMac, isLinux } from "../utils/PlatformUtils";
import { DetectableGameRecord } from "../modules/game_detection/GameDetectionTypes";
import Module589 from "../_bundle/Module589";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import { isNotNullish } from "../utils/GlobalUtils";
import { GameLinkTypes } from "../flow/Server";
import AnalyticsUtils from "../utils/AnalyticsUtils";
import { ShowCurrentGame } from "../modules/user_settings/UserSettings";
import Dispatcher from "../Dispatcher";
let c2438_7, DAY, c2438_9, c2438_10, c2438_11, c2438_12, detectableGamesEtag2, c2438_14, c2438_15, c2438_16, c2438_17, c2438_18, blocklistEtag2, blocklistExecutables, c2438_21, c2438_22, HOUR, c2438_24, c2438_25, c2438_26, convertGameRecordToGame, addGameIdToNameCache, addDetectableGame;
const gameFromServer = function gameFromServer(item) {
let executables = item.executables;
if (executables == null) {
executables = [];
}
const r2 = {
id: item.id,
name: item.name,
executables: executables.map(createExecutable),
overlay: null,
overlayWarn: null,
overlayCompatibilityHook: null,
hook: null,
aliases: null,
supportsOutOfProcessOverlay: null,
themes: null,
icon: null,
thirdPartySkus: null,
cover_image_hash: null,
content_classification: null
};
let overlay = item.overlay;
if (overlay == null) {
overlay = false;
}
r2.overlay = overlay;
let overlay_warn = item.overlay_warn;
if (overlay_warn == null) {
overlay_warn = false;
}
r2.overlayWarn = overlay_warn;
let overlay_compatibility_hook = item.overlay_compatibility_hook;
if (overlay_compatibility_hook == null) {
overlay_compatibility_hook = false;
}
r2.overlayCompatibilityHook = overlay_compatibility_hook;
let hook = item.hook;
if (hook == null) {
hook = true;
}
r2.hook = hook;
let aliases = item.aliases;
if (aliases == null) {
aliases = [];
}
r2.aliases = aliases;
r2.supportsOutOfProcessOverlay = ApplicationRecord.supportsOutOfProcessOverlay(item.overlay_methods);
let themes = item.themes;
if (themes == null) {
themes = [];
}
r2.themes = themes;
let icon_hash = item.icon_hash;
if (icon_hash == null) {
icon_hash = void 0;
}
r2.icon = icon_hash;
let third_party_skus = item.third_party_skus;
if (third_party_skus == null) {
third_party_skus = [];
}
r2.thirdPartySkus = third_party_skus;
let cover_image_hash = item.cover_image_hash;
if (cover_image_hash == null) {
cover_image_hash = void 0;
}
r2.cover_image_hash = cover_image_hash;
let content_classification = item.content_classification;
if (content_classification == null) {
content_classification = void 0;
}
r2.content_classification = content_classification;
return r2;
};
convertGameRecordToGame = function convertGameRecordToGame(a0) {
let themes = a0.themes;
if (themes == null) {
themes = [];
}
let thirdPartySkus = a0.thirdPartySkus;
if (thirdPartySkus == null) {
thirdPartySkus = [];
}
let cover_image_hash = a0.cover_image_hash;
if (cover_image_hash == null) {
cover_image_hash = void 0;
}
let content_classification = a0.content_classification;
if (content_classification == null) {
content_classification = void 0;
}
return {
id: a0.id,
name: a0.name,
executables: a0.executables,
overlayWarn: a0.overlayWarn,
overlayCompatibilityHook: a0.overlayCompatibilityHook,
overlay: a0.overlay,
hook: a0.hook,
aliases: a0.aliases,
supportsOutOfProcessOverlay: a0.supportsOutOfProcessOverlay,
themes,
icon: a0.icon,
thirdPartySkus,
cover_image_hash,
content_classification
};
};
addGameIdToNameCache = function addGameIdToNameCache(id, a1) {
if (c2438_10[a1] == null) {
c2438_10[a1] = [];
}
c2438_10[a1].push(id);
};
addDetectableGame = function addDetectableGame(item) {
const r28 = item instanceof DetectableGameRecord ? convertGameRecordToGame(item) : item;
c2438_9.set(item.id, r28);
addGameIdToNameCache(r28.id, r28.name.toLowerCase());
for (const aliase of item.aliases) {
addGameIdToNameCache(r28.id, aliase.toLowerCase());
}
if (isDesktop()) {
for (const executable of item.executables) {
c2438_11[executable.name] = r28.id;
}
}
};
c2438_7 = "GameStoreReportedGames";
DAY = Durations.Millis.DAY;
c2438_9 = new CachedEntriesMap();
c2438_10 = Object.create(null);
c2438_11 = Object.create(null);
let r53 = Storage.get("GameStoreReportedGames");
if (r53 == null) {
r53 = Object.create(null);
}
c2438_12 = r53;
detectableGamesEtag2 = "";
c2438_14 = void 0;
c2438_15 = null;
c2438_16 = false;
c2438_17 = null;
c2438_18 = false;
blocklistEtag2 = "";
blocklistExecutables = [];
c2438_21 = [];
c2438_22 = new Map();
HOUR = Durations.Millis.HOUR;
c2438_24 = new Set();
c2438_25 = new Set();
c2438_26 = isWindows() ? "win32" : isMac() ? "darwin" : isLinux() ? "linux" : null;
class DetectableGameStore extends Module589.PersistedStore {
static displayName = "GameStore";
static persistKey = "GameStore";
static migrations = [(a0) => {
let r2;
if (a0 != null) {
const detectableGames = a0.detectableGames;
let detectableGames2 = detectableGames == null ? void 0 : detectableGames.map((detectableGame) => {
const detectableGameRecord = new DetectableGameRecord(detectableGame);
let themes = detectableGameRecord.themes;
if (themes == null) {
themes = [];
}
let thirdPartySkus = detectableGameRecord.thirdPartySkus;
if (thirdPartySkus == null) {
thirdPartySkus = [];
}
let cover_image_hash = detectableGameRecord.cover_image_hash;
if (cover_image_hash == null) {
cover_image_hash = void 0;
}
let content_classification = detectableGameRecord.content_classification;
if (content_classification == null) {
content_classification = void 0;
}
return {
id: detectableGameRecord.id,
name: detectableGameRecord.name,
executables: detectableGameRecord.executables,
overlayWarn: detectableGameRecord.overlayWarn,
overlayCompatibilityHook: detectableGameRecord.overlayCompatibilityHook,
overlay: detectableGameRecord.overlay,
hook: detectableGameRecord.hook,
aliases: detectableGameRecord.aliases,
supportsOutOfProcessOverlay: detectableGameRecord.supportsOutOfProcessOverlay,
themes,
icon: detectableGameRecord.icon,
thirdPartySkus,
cover_image_hash,
content_classification
};
});
if (detectableGames2 == null) {
detectableGames2 = [];
}
r2 = {
detectableGamesEtag: a0.detectableGamesEtag,
detectableGames: detectableGames2
};
} else {
r2 = {
detectableGamesEtag: "",
detectableGames: []
};
}
return r2;
}, (a0) => isDesktop() ? a0 : {
detectableGamesEtag: "",
detectableGames: []
}, () => ({
detectableGamesEtag: "",
detectableGames: []
}), (a0) => {
let blocklistEtag3 = a0.blocklistEtag;
if (blocklistEtag3 == null) {
blocklistEtag3 = "";
}
let blocklistExecutables2 = a0.blocklistExecutables;
if (blocklistExecutables2 == null) {
blocklistExecutables2 = [];
}
let blocklistPatterns = a0.blocklistPatterns;
if (blocklistPatterns == null) {
blocklistPatterns = [];
}
return {
...a0,
blocklistEtag: blocklistEtag3,
blocklistExecutables: blocklistExecutables2,
blocklistPatterns
};
}];
initialize(a0) {
if (a0 != null) {
if (a0.detectableGamesEtag != null) {
detectableGamesEtag2 = a0.detectableGamesEtag;
}
if (a0.blocklistEtag != null) {
blocklistEtag2 = a0.blocklistEtag;
}
if (a0.blocklistExecutables != null) {
blocklistExecutables = a0.blocklistExecutables;
}
if (a0.blocklistPatterns != null) {
c2438_21 = a0.blocklistPatterns.map((blocklistPattern) => new RegExp(blocklistPattern, "i"));
}
const detectableGames = a0.detectableGames;
if (detectableGames != null) {
detectableGames.forEach((detectableGame) => {
addDetectableGame(detectableGame);
});
}
}
}
getState() {
return isDesktop() ? {
detectableGamesEtag: detectableGamesEtag2,
detectableGames: c2438_9.values(),
blocklistEtag: blocklistEtag2,
blocklistExecutables,
blocklistPatterns: c2438_21.map((item) => item.source)
} : {
detectableGamesEtag: "",
detectableGames: [],
blocklistEtag: "",
blocklistExecutables: [],
blocklistPatterns: []
};
}
get games() {
return c2438_9.values();
}
getDetectableGame(a0) {
return c2438_9.get(SnowflakeUtils.cast(a0));
}
searchGamesByName(a0) {
if (a0 == null) {
return [];
}
const r6 = a0.toLowerCase();
return Object.prototype.hasOwnProperty.call(c2438_10, r6) ? c2438_10[r6] : [];
}
findGame(a0, c13993_1) {
let detectableGame, c13993_4;
const _this = this;
const detectableGame2 = this.getDetectableGame(a0.id);
if (detectableGame2 != null) {
return detectableGame2;
}
if (a0.name != null) {
const r30 = this.searchGamesByName(a0.name);
const _loop = function _loop() {
const detectableGame2 = _this.getDetectableGame(c13993_4);
if (detectableGame2 == null) {
return 0;
}
if (c13993_1 != null) {
c13993_1(detectableGame2);
return 0;
}
if (a0.exePath != null && detectableGame2.executables != null) {
let c24976_0 = a0.exePath.split("/").filter(isNotNullish).pop();
if (detectableGame2.executables.some((executable) => executable.name === c24976_0)) {
return {
v: detectableGame2
};
}
}
detectableGame = detectableGame2;
};
for (const item of r30) {
c13993_4 = item;
const r35 = _loop();
if (r35 === 0) {
continue;
}
if (!r35) {
continue;
}
return r35.v;
}
}
if (a0.exePath != null) {
const gameByExecutable = this.getGameByExecutable(a0.exePath.split("/").filter(isNotNullish).pop());
if (gameByExecutable != null) {
return gameByExecutable;
}
const gameByExecutable2 = this.getGameByExecutable(a0.exePath.split("/").filter(isNotNullish).slice(-2).join("/"));
if (gameByExecutable2 != null) {
return gameByExecutable2;
}
}
if (detectableGame != null && a0.name != null) {
this.trackNameMatchFallback(a0.name, detectableGame, a0.exePath);
}
return detectableGame;
}
getOfficialGame(a0) {
let id;
const r1 = a0 == null;
let r3 = null;
if (!r1) {
if (a0.type === ApplicationTypes.GAME) {
id = a0.id;
} else {
const linkedGames = a0.linkedGames;
id = linkedGames == null ? void 0 : linkedGames.find((linkedGame) => linkedGame.type === GameLinkTypes.OFFICIAL)?.id;
}
r3 = id == null ? null : this.getDetectableGame(id);
}
return r3;
}
getGameByApplication(a0) {
let r1 = void 0;
const detectableGame2 = this.getDetectableGame(a0.id);
if (detectableGame2 != null) {
return detectableGame2;
}
let r28 = "none";
if (a0.linkedGames != null) {
for (const linkedGame of a0.linkedGames) {
const detectableGame3 = this.getDetectableGame(linkedGame.id);
if (detectableGame3 == null) {
continue;
}
r28 = "linked_game";
r1 = detectableGame3;
break;
}
}
if (r1 == null) {
const r48 = this.searchGamesByName(a0.name).map((item) => this.getDetectableGame(item)).reverse()[0];
if (r48 != null) {
r28 = "name";
r1 = r48;
}
}
this.maybeTrackApplicationLookupFallthrough(a0, r28, r1);
return r1;
}
isGameInDatabase(a0) {
return this.findGame(a0) != null || a0.nativeProcessObserverId !== void 0 && !(2147483648 & a0.nativeProcessObserverId);
}
get fetching() {
return c2438_14 === true;
}
get detectableGamesEtag() {
return detectableGamesEtag2;
}
get blocklistEtag() {
return blocklistEtag2;
}
get lastFetched() {
return c2438_15;
}
get hasAttemptedFetch() {
return c2438_16;
}
get detectableGamesTtl() {
return DAY;
}
canFetchDetectableGames() {
return c2438_14 !== true && (c2438_15 == null || Date.now() >= c2438_15 + DAY);
}
canFetchExecutableBlocklist() {
return c2438_18 ? !c2438_18 : c2438_17 == null || Date.now() >= c2438_17 + DAY;
}
getGameByExecutable(a0) {
if (a0 != null) {
return this.getDetectableGame(c2438_11[a0]);
}
}
shouldBlock(a0) {
let c13995_1;
if (a0.exePath != null && a0.exePath !== "") {
c13995_1 = a0.exePath.toLowerCase();
if (a0.id != null && c2438_26 != null) {
const detectableGame2 = this.getDetectableGame(a0.id);
if (detectableGame2 != null && detectableGame2.executables.some((executable) => executable.os === c2438_26 && c13995_1.endsWith(executable.name.toLowerCase()))) {
return false;
}
}
const r24 = blocklistExecutables.find((blocklistExecutable) => c13995_1.includes(blocklistExecutable));
if (r24 != null) {
this.maybeTrackBlock(a0, "explicit_list", r24);
return true;
}
const r28 = c2438_21.find((item) => item.test(a0.exePath));
let r29 = r28 != null;
if (r29) {
this.maybeTrackBlock(a0, "pattern_match", r28.source);
r29 = true;
}
return r29;
}
return false;
}
getBlockReason(a0) {
let c13996_1;
if (a0.exePath != null && a0.exePath !== "") {
c13996_1 = a0.exePath.toLowerCase();
const matchedExe = blocklistExecutables.find((blocklistExecutable) => c13996_1.includes(blocklistExecutable));
if (matchedExe != null) {
return {
matchedExe,
matchedPattern: null
};
}
const r18 = c2438_21.find((item) => item.test(a0.exePath));
return r18 != null ? {
matchedExe: null,
matchedPattern: r18.source
} : null;
}
return null;
}
maybeTrackApplicationLookupFallthrough(a0, a1, a2) {
const id = a0.id;
if (!c2438_24.has(id)) {
c2438_24.add(id);
const GAME_APPLICATION_LOOKUP_FALLTHROUGH = AnalyticEvents.GAME_APPLICATION_LOOKUP_FALLTHROUGH;
let name = a0.name;
if (name == null) {
name = null;
}
let matched_game_id = a2?.id;
if (matched_game_id == null) {
matched_game_id = null;
}
let matched_game_name = a2?.name;
if (matched_game_name == null) {
matched_game_name = null;
}
AnalyticsUtils.track(GAME_APPLICATION_LOOKUP_FALLTHROUGH, {
application_id: id,
application_name: name,
match_type: a1,
matched_game_id,
matched_game_name
});
}
}
trackNameMatchFallback(a0, a1, a2) {
const r6 = a0.toLowerCase();
if (!c2438_25.has(r6)) {
c2438_25.add(r6);
const had_exe_path = a2 != null && a2 !== "";
const GAME_NAME_MATCH_FALLBACK = AnalyticEvents.GAME_NAME_MATCH_FALLBACK;
let exe_name = null;
if (had_exe_path) {
let r29 = a2.split(/[/\\]/).pop();
if (r29 == null) {
r29 = null;
}
exe_name = r29;
}
AnalyticsUtils.track(GAME_NAME_MATCH_FALLBACK, {
matched_name: a0,
matched_game_id: a1.id,
exe_name,
had_exe_path
});
}
}
maybeTrackBlock(a0, a1, a2) {
let executable_name = a0.exePath.split(/[/\\]/).pop();
if (executable_name == null) {
executable_name = "unknown";
}
const r15 = c2438_22.get(executable_name);
const r18 = Date.now();
if (r15 == null || r18 - r15 >= HOUR) {
c2438_22.set(executable_name, r18);
const GAME_BLOCKLIST_TRIGGERED = AnalyticEvents.GAME_BLOCKLIST_TRIGGERED;
let gameName = a0.gameName;
if (gameName == null) {
gameName = a0.origGameName;
}
AnalyticsUtils.track(GAME_BLOCKLIST_TRIGGERED, {
block_type: a1,
matched_entry: a2,
game_name: gameName,
executable_name
});
}
}
shouldReport(a0) {
if (this.shouldBlock(a0)) {
return false;
}
let r1 = this.findGame(a0) != null;
const r0 = a0.name != null && c2438_12[a0.name] != null;
let r21 = ShowCurrentGame.getSetting() && !c2438_14;
if (r21) {
if (!r1) {
r1 = r0;
}
r21 = !r1;
}
return r21;
}
markGameReported(a0) {
c2438_12[a0] = true;
Storage.set(c2438_7, c2438_12);
}
}
const detectableGameStore = new DetectableGameStore(Dispatcher, {
OVERLAY_INITIALIZE: function handleOverlayInitialize({ detectableApplications }) {
c2438_9.clear();
c2438_10 = Object.create(null);
c2438_11 = Object.create(null);
for (const item of detectableApplications) {
addDetectableGame(item);
}
},
GAMES_DATABASE_FETCH: function handleApplicationsFetch() {
c2438_14 = true;
},
GAMES_DATABASE_FETCH_FAIL: function handleApplicationsFetchFail() {
c2438_14 = false;
c2438_16 = true;
},
GAMES_DATABASE_UPDATE: function handleDetectableGamesUpdated({ games: games2, etag }) {
if (etag != null && detectableGamesEtag2 !== etag) {
c2438_9.clear();
c2438_10 = Object.create(null);
c2438_11 = Object.create(null);
detectableGamesEtag2 = etag;
}
for (const item of games2) {
addDetectableGame(gameFromServer(item));
}
c2438_14 = void 0;
c2438_15 = Date.now();
c2438_16 = true;
},
GAMES_BLOCKLIST_FETCH: function handleGamesBlocklistFetch() {
c2438_18 = true;
},
GAMES_BLOCKLIST_FETCH_FAIL: function handleGamesBlocklistFetchFail() {
c2438_18 = false;
},
GAMES_BLOCKLIST_UPDATE: function handleGamesBlocklistUpdated({ executables, patterns, etag }) {
if (etag != null && blocklistEtag2 !== etag) {
blocklistEtag2 = etag;
blocklistExecutables = executables.map((executable) => executable.toLowerCase());
c2438_21 = patterns.map((pattern) => new RegExp(pattern, "i"));
}
c2438_18 = false;
c2438_17 = Date.now();
}
});
export default detectableGameStore;
export { gameFromServer };
+44
View File
@@ -0,0 +1,44 @@
// Metro module 6004 (f6005).
import GuildStore from "./GuildStore";
import UserStore from "./UserStore";
import { ExperimentBuckets } from "../modules/experiments/ExperimentConstants";
import { Environments } from "../modules/user/UserStoreConstants";
import * as _UserStoreUtils from "../modules/user/UserStoreUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let isStaffEnv;
const r1 = Environments.DEVELOPMENT === "production" || window.GLOBAL_ENV.RELEASE_CHANNEL === Environments.STAGING;
const init = function init() {
isStaffEnv = _UserStoreUtils.isStaffEnv(UserStore.getCurrentUser());
};
isStaffEnv = r1;
class DeveloperExperimentStore extends Module589.Store {
static displayName = "DeveloperExperimentStore";
initialize() {
this.waitFor(UserStore, GuildStore);
Object.defineProperties(this, {
isDeveloper: {
configurable: false,
get: () => isStaffEnv,
set: () => {}
}
});
isStaffEnv = _UserStoreUtils.isStaffEnv(UserStore.getCurrentUser());
setTimeout(() => Object.freeze(this));
}
getExperimentDescriptor() {
return isStaffEnv ? {
type: "developer",
name: "discord_dev_testing",
revision: 1,
override: true,
bucket: ExperimentBuckets.TREATMENT_1
} : null;
}
}
const developerExperimentStore = new DeveloperExperimentStore(Dispatcher, {
CONNECTION_OPEN: init,
OVERLAY_INITIALIZE: init,
CURRENT_USER_UPDATE: init
});
export default developerExperimentStore;
+219
View File
@@ -0,0 +1,219 @@
// Metro module 706 (f707).
import { UserFlags } from "../Constants";
import Backoff from "../_bundle/Backoff";
import Durations from "../utils/Durations";
import { HTTP } from "../_bundle/sendRequest";
import { getToken } from "../_bundle/setSecondaryToken";
import { setDeveloperOptionSettings } from "../actions/DeveloperOptionsActionCreators";
import { Storage } from "../_bundle/Module595";
import SentryUtils_native from "../utils/SentryUtils.native";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c596_5, c596_6, c596_7, c596_9, c596_11;
let url, c597_1, c597_2;
let env596 = {};
url = void 0;
c597_1 = void 0;
c597_2 = void 0;
const refreshSourceMapCookie = function refreshSourceMapCookie() {
HTTP.put({
url,
headers: {
Authorization: getToken()
},
oldFormErrors: true,
rejectWithError: true
}).then((result) => {
L6: {
if (result.status !== 401 && result.status !== 403) {
if (result.status !== 200) {
c597_1 = setTimeout(refreshSourceMapCookie, c597_2.fail());
break L6;
}
c597_2.succeed();
c597_1 = setTimeout(refreshSourceMapCookie, result.body.sourceMapCookieTTLSeconds * Durations.Millis.SECOND * 0.75);
} else {
c597_1 = null;
setDeveloperOptionSettings({
sourceMapsEnabled: false
});
}
}
}, () => {
c597_1 = setTimeout(refreshSourceMapCookie, c597_2.fail());
});
};
url = `${location.protocol}//${location.host}/__development/source_maps`;
c597_1 = null;
c597_2 = new Backoff(5 * Durations.Millis.SECOND, 1 * Durations.Millis.MINUTE, true);
c596_5 = {
set: function set(a0) {
if (a0 !== (c597_1 != null)) {
if (a0) {
c597_1 = setTimeout(refreshSourceMapCookie, 0);
} else {
clearTimeout(c597_1);
c597_1 = null;
HTTP.del({
url,
headers: {
Authorization: getToken()
},
oldFormErrors: true,
rejectWithError: true
});
}
}
}
};
c596_6 = "DeveloperOptionsStore";
c596_7 = {
trace: false,
canary: false,
logGatewayEvents: false,
logOverlayEvents: false,
logAnalyticsEvents: false,
sourceMapsEnabled: false,
axeEnabled: false,
cssDebuggingEnabled: false,
layoutDebuggingEnabled: false,
bugReporterEnabled: true,
idleStatusIndicatorEnabled: false,
onlyShowPreviewAppCollections: false,
disableAppCollectionsCache: false,
isStreamInfoOverlayEnabled: false,
preventPopoutClose: false,
logKeyboardMismatches: false,
alertStartupMetrics: false,
logQuestEvents: false
};
env596[8] = {
...c596_7
};
c596_9 = "DeveloperOptionsRoutingKey";
env596[10] = [];
class DeveloperOptionsStore extends Module589.Store {
static displayName = "DeveloperOptionsStore";
constructor() {
super(...arguments);
}
initialize() {
const r12 = Storage.get(c596_6);
if (r12 != null) {
env596[8] = {
...c596_7,
...r12
};
}
const r23 = Storage.get(c596_9);
if (r23 != null) {
env596[10] = r23;
}
}
get isTracingRequests() {
return env596[8].trace;
}
get isForcedCanary() {
return env596[8].canary;
}
get isLoggingGatewayEvents() {
return env596[8].logGatewayEvents;
}
get isLoggingOverlayEvents() {
return env596[8].logOverlayEvents;
}
get isLoggingAnalyticsEvents() {
return env596[8].logAnalyticsEvents;
}
get isAxeEnabled() {
return env596[8].axeEnabled;
}
get cssDebuggingEnabled() {
return env596[8].cssDebuggingEnabled;
}
get layoutDebuggingEnabled() {
return env596[8].layoutDebuggingEnabled;
}
get sourceMapsEnabled() {
return env596[8].sourceMapsEnabled;
}
get isBugReporterEnabled() {
return env596[8].bugReporterEnabled;
}
get isIdleStatusIndicatorEnabled() {
return env596[8].idleStatusIndicatorEnabled;
}
get onlyShowPreviewAppCollections() {
return env596[8].onlyShowPreviewAppCollections;
}
get disableAppCollectionsCache() {
return env596[8].disableAppCollectionsCache;
}
get isStreamInfoOverlayEnabled() {
return env596[8].isStreamInfoOverlayEnabled;
}
get preventPopoutClose() {
return env596[8].preventPopoutClose;
}
get logKeyboardMismatches() {
return env596[8].logKeyboardMismatches;
}
get alertStartupMetrics() {
return env596[8].alertStartupMetrics;
}
get isLoggingQuestEvents() {
return env596[8].logQuestEvents;
}
getDebugOptionsHeaderValue() {
Object.keys(env596[8]).map((item) => env596[8][item]);
return Object.keys(env596[8]).filter((item) => env596[8][item]).join(",");
}
get routingKeyTags() {
return env596[10];
}
getRoutingKeyHeaderValue() {
return env596[10].length !== 0 ? env596[10].join(",") : null;
}
}
c596_11 = DeveloperOptionsStore;
const r120 = new DeveloperOptionsStore(Dispatcher, {
LOGOUT: function handleLogout(a0) {
env596[8] = {
...c596_7,
...env596[8],
...c596_7
};
c596_5.set(env596[8].sourceMapsEnabled);
Storage.set(c596_6, env596[8]);
env596[10] = [];
Storage.set(c596_9, env596[10]);
},
CONNECTION_OPEN: function handleConnectionOpen(a0) {
let flags = a0.user.flags;
if (flags == null) {
flags = 0;
}
const r2 = (flags & UserFlags.STAFF) === UserFlags.STAFF;
const r1 = r2 || a0.user.personal_connection_id != null;
if (r2) {
c596_5.set(env596[8].sourceMapsEnabled);
}
SentryUtils_native.setTags({
isStaff: r1.toString()
});
},
DEVELOPER_OPTIONS_UPDATE_SETTINGS: function handleUpdateSettings(a0) {
env596[8] = {
...c596_7,
...env596[8],
...a0.settings
};
c596_5.set(env596[8].sourceMapsEnabled);
Storage.set(c596_6, env596[8]);
},
DEVELOPER_OPTIONS_SET_ROUTING_KEY: function handleSetRoutingKey(a0) {
env596[10] = a0.tags;
Storage.set(c596_9, env596[10]);
}
});
export default r120;
+100
View File
@@ -0,0 +1,100 @@
// Metro module 4859 (f4860).
import shallowEqual from "../_bundle/shallowEqual";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2992_2 = {};
let c2992_3 = {};
let c2992_4 = {
scrollTop: 0
};
class DimensionStore extends Module589.Store {
static displayName = "DimensionStore";
percentageScrolled(a0) {
if (c2992_2[a0] != null) {
const r6 = c2992_2[a0];
return r6.scrollTop / r6.scrollHeight;
}
return 1;
}
getChannelDimensions(a0) {
return c2992_2[a0];
}
getGuildDimensions(a0) {
let r5 = c2992_3[a0];
if (r5 == null) {
r5 = {
guildId: a0,
scrollTop: null,
scrollTo: null
};
}
return r5;
}
getGuildListDimensions() {
return c2992_4;
}
isAtBottom(a0) {
const r1 = c2992_2[a0] != null;
let r6 = void 0;
if (r1) {
const r7 = c2992_2[a0];
r6 = r7.scrollTop === r7.scrollHeight - r7.offsetHeight;
}
return r6;
}
}
const dimensionStore = new DimensionStore(Dispatcher, {
UPDATE_CHANNEL_DIMENSIONS: function handleChannelScroll({ channelId, scrollTop, scrollHeight, offsetHeight }) {
const r4 = c2992_2[channelId];
if (scrollTop != null && (scrollHeight != null && offsetHeight != null)) {
const r5 = {
channelId,
scrollTop,
scrollHeight,
offsetHeight
};
if (r4 != null && shallowEqual(r4, r5)) {
return false;
}
c2992_2[channelId] = r5;
} else {
if (r4 == null) {
return false;
}
delete c2992_2[channelId];
}
},
UPDATE_CHANNEL_LIST_DIMENSIONS: function handleGuildUpdate({ guildId, scrollTop, scrollTo }) {
if (c2992_3[guildId] == null) {
c2992_3[guildId] = {
guildId,
scrollTop: null,
scrollTo: null
};
}
if (scrollTop !== void 0) {
c2992_3[guildId].scrollTop = scrollTop;
}
let r1 = false;
if (scrollTo !== void 0) {
r1 = c2992_3[guildId].scrollTo !== scrollTo;
c2992_3[guildId].scrollTo = scrollTo;
}
return scrollTo != null || r1;
},
UPDATE_GUILD_LIST_DIMENSIONS: function handleGuildListUpdate(a0) {
c2992_4.scrollTop = a0.scrollTop;
},
CALL_CREATE: function handleCallCreate({ channelId }) {
const r2 = c2992_2[channelId] != null;
let r0 = void 0;
if (r2) {
const r11 = c2992_2[channelId];
r0 = r11.scrollTop === r11.scrollHeight - r11.offsetHeight;
}
if (r0) {
delete c2992_2[channelId];
}
}
});
export default dimensionStore;
+414
View File
@@ -0,0 +1,414 @@
// Metro module 4526 (f4527).
import _slicedToArray from "../_bundle/_slicedToArray";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import GuildAvailabilityStore from "./GuildAvailabilityStore";
import { MAX_MESSAGE_LENGTH_PREMIUM } from "../Constants";
import Module12 from "../_bundle/Module12";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import Module589 from "../_bundle/Module589";
import { isNotNullish } from "../utils/GlobalUtils";
import Dispatcher from "../Dispatcher";
let c2733_7, c2733_8, c2733_9, deleteDraft;
const handleChanged = function handleChanged(a0) {
const { type, channelId } = a0;
let draft = a0.draft;
const draftType = a0.draftType;
if (draft === ChannelStore.getChannel(channelId)?.template) {
draft = "";
}
L23: {
const id = AuthenticationStore.getId();
if (id != null && (draft != null && draft !== "")) {
let r34 = c2733_9[id];
if (r34 == null) {
const r36 = {};
c2733_9[id] = r36;
r34 = r36;
}
let r37 = r34[channelId];
if (r37 == null) {
const r38 = {};
r34[channelId] = r38;
r37 = r38;
}
const draft2 = draft.length > c2733_7 ? draft.substr(0, c2733_7) : draft;
if (draft2 === r37[draftType]?.draft) {
break L23;
}
r37[draftType] = {
timestamp: Date.now(),
draft: draft2
};
} else {
const id2 = AuthenticationStore.getId();
if (id2 != null) {
let r22 = c2733_9[id2];
if (r22 == null) {
const r23 = {};
c2733_9[id2] = r23;
r22 = r23;
}
const r24 = r22[channelId];
if (r24 != null) {
delete r24[draftType];
if (Module12.isEmpty(r24)) {
delete r22[channelId];
}
}
}
}
}
return type === "DRAFT_SAVE";
};
deleteDraft = function deleteDraft(a0, a1, r6 = AuthenticationStore.getId()) {
if (r6 == null) {
return false;
}
let r8 = c2733_9[r6];
if (r8 == null) {
const r9 = {};
c2733_9[r6] = r9;
r8 = r9;
}
const r11 = r8[a0];
if (r11 == null) {
return false;
}
delete r11[a1];
if (Module12.isEmpty(r11)) {
delete r8[a0];
}
};
const handleChannelDelete = function handleChannelDelete(a0) {
const id = a0.channel.id;
const id2 = AuthenticationStore.getId();
if (id2 != null) {
let r9 = c2733_9[id2];
if (r9 == null) {
const r11 = {};
c2733_9[id2] = r11;
r9 = r11;
}
delete r9[id];
}
return false;
};
c2733_7 = MAX_MESSAGE_LENGTH_PREMIUM + 500;
c2733_8 = {
ChannelMessage: 0,
0: "ChannelMessage",
ThreadSettings: 1,
1: "ThreadSettings",
FirstThreadMessage: 2,
2: "FirstThreadMessage",
ApplicationLauncherCommand: 3,
3: "ApplicationLauncherCommand",
Poll: 4,
4: "Poll",
SlashCommand: 5,
5: "SlashCommand",
ForwardContextMessage: 6,
6: "ForwardContextMessage",
InteractionModal: 7,
7: "InteractionModal"
};
c2733_9 = {};
class DraftStore extends Module589.PersistedStore {
static displayName = "DraftStore";
static persistKey = "DraftStore";
static migrations = [(a0) => {
if (a0 == null) {
return {};
}
for (const key in a0) {
if ("timestamp" in a0[key]) {
const r14 = {};
r14[c2733_8.ChannelMessage] = a0[key];
a0[key] = r14;
}
}
return a0;
}, (a0) => {
const id = AuthenticationStore.getId();
if (a0 != null && id != null) {
const r13 = {};
const r7 = {};
r13[id] = r7;
for (const key in a0) {
r7[key] = a0[key];
}
return r13;
}
return {};
}];
initialize(a0) {
c2733_9 = a0 == null ? {} : a0;
(function pruneEmptyDrafts() {
for (const item of SnowflakeUtils.entries(c2733_9)) {
const [r42, r13] = item;
for (const item2 of SnowflakeUtils.entries(r13)) {
const r55 = _slicedToArray(item2, 2);
const r56 = r55[0];
const r59 = r55[1][c2733_8.ChannelMessage];
if (r59 != null && !(r59.draft !== "" && r59.draft.trim() !== "")) {
deleteDraft(r56, c2733_8.ChannelMessage, r42);
}
}
}
})();
this.waitFor(AuthenticationStore, ChannelStore, GuildAvailabilityStore);
}
getState() {
return c2733_9;
}
getThreadDraftWithParentMessageId(c14301_0) {
const id = AuthenticationStore.getId();
if (id != null) {
let r11 = c2733_9[id];
if (r11 == null) {
const r12 = {};
c2733_9[id] = r12;
r11 = r12;
}
const r22 = SnowflakeUtils.keys(r11).find((item) => this.getThreadSettings(item)?.parentMessageId === c14301_0);
return r22 != null ? this.getThreadSettings(r22) : void 0;
}
}
getRecentlyEditedDrafts(c14302_0) {
const id = AuthenticationStore.getId();
if (id == null) {
return [];
}
let r5 = c2733_9[id];
if (r5 == null) {
const r10 = {};
c2733_9[id] = r10;
r5 = r10;
}
return Module12(r5).mapValues((a0) => a0 == null ? void 0 : a0[c14302_0]).pickBy(isNotNullish).toPairs().map((item) => {
const [channelId, r15] = item;
return {
channelId,
timestamp: r15.timestamp,
draft: r15.draft
};
}).sortBy((item) => -item.timestamp).value();
}
getDraft(a0, a1) {
const id = AuthenticationStore.getId();
if (id == null) {
return "";
}
let r6 = c2733_9[id];
if (r6 == null) {
const r8 = {};
c2733_9[id] = r8;
r6 = r8;
}
const r10 = r6[a0];
if (r10 != null) {
const r12 = r10[a1];
if (r12 != null) {
return r12.draft;
}
}
return "";
}
getThreadSettings(a0) {
const id = AuthenticationStore.getId();
if (id == null) {
return null;
}
let r8 = c2733_9[id];
if (r8 == null) {
const r9 = {};
c2733_9[id] = r9;
r8 = r9;
}
const r11 = r8[a0];
return r11 == null ? null : r11[c2733_8.ThreadSettings];
}
}
const draftStore = new DraftStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
const id = AuthenticationStore.getId();
if (!(id in c2733_9)) {
c2733_9[id] = {};
}
const id2 = AuthenticationStore.getId();
if (id2 != null && !(GuildAvailabilityStore.totalUnavailableGuilds > 0)) {
let r20 = c2733_9[id2];
if (r20 == null) {
const r22 = {};
c2733_9[id2] = r22;
r20 = r22;
}
for (const key in r20) {
if (ChannelStore.getChannel(key) == null) {
delete r20[key];
}
}
}
return false;
},
LOGOUT: function handleLogout(a0) {
if (!a0.isSwitchingAccount) {
c2733_9 = {};
}
},
MULTI_ACCOUNT_REMOVE_ACCOUNT: function handleMultiAccountRemove(a0) {
if (a0.userId in c2733_9) {
delete c2733_9[a0.userId];
}
},
GUILD_DELETE: function handleGuildDelete() {
const id = AuthenticationStore.getId();
if (id != null && !(GuildAvailabilityStore.totalUnavailableGuilds > 0)) {
let r7 = c2733_9[id];
if (r7 == null) {
const r16 = {};
c2733_9[id] = r16;
r7 = r16;
}
for (const key in r7) {
if (ChannelStore.getChannel(key) == null) {
delete r7[key];
}
}
}
return false;
},
CHANNEL_DELETE: handleChannelDelete,
THREAD_DELETE: handleChannelDelete,
THREAD_CREATE: function handleThreadCreate({ channel }) {
const id = AuthenticationStore.getId();
if (id != null && channel.ownerId !== id) {
let r11 = c2733_9[id];
if (r11 == null) {
const r20 = {};
c2733_9[id] = r20;
r11 = r20;
}
const r22 = r11[channel.parent_id];
if (r22 == null) {
return false;
}
const r25 = r22[c2733_8.ThreadSettings];
if (r25 == null) {
return false;
}
if (r25.parentMessageId !== SnowflakeUtils.castChannelIdAsMessageId(channel.id)) {
return false;
}
const r31 = r11[channel.parent_id];
if (r31 == null) {
return false;
}
let draft = r31[c2733_8.FirstThreadMessage]?.draft;
if (draft == null) {
draft = "";
}
if (draft !== "") {
const id2 = channel.id;
const r36 = {};
r36[c2733_8.ChannelMessage] = {
timestamp: Date.now(),
draft
};
r11[id2] = r36;
}
const parent_id = channel.parent_id;
const ThreadSettings = c2733_8.ThreadSettings;
const id3 = AuthenticationStore.getId();
if (id3 != null) {
let r46 = c2733_9[id3];
if (r46 == null) {
const r48 = {};
c2733_9[id3] = r48;
r46 = r48;
}
const r49 = r46[parent_id];
if (r49 != null) {
delete r49[ThreadSettings];
if (Module12.isEmpty(r49)) {
delete r46[parent_id];
}
}
}
const parent_id2 = channel.parent_id;
const FirstThreadMessage = c2733_8.FirstThreadMessage;
const id4 = AuthenticationStore.getId();
if (id4 != null) {
let r61 = c2733_9[id4];
if (r61 == null) {
const r63 = {};
c2733_9[id4] = r63;
r61 = r63;
}
const r64 = r61[parent_id2];
if (r64 != null) {
delete r64[FirstThreadMessage];
if (Module12.isEmpty(r64)) {
delete r61[parent_id2];
}
}
}
return void 0;
}
return false;
},
DRAFT_SAVE: handleChanged,
DRAFT_CHANGE: handleChanged,
DRAFT_CLEAR: function handleDraftClear({ channelId, draftType }) {
const id = AuthenticationStore.getId();
const r3 = id == null;
let r0 = false;
if (!r3) {
let r13 = c2733_9[id];
if (r13 == null) {
const r14 = {};
c2733_9[id] = r14;
r13 = r14;
}
const r15 = r13[channelId];
const r16 = r15 == null;
r0 = false;
if (!r16) {
delete r15[draftType];
const isEmpty = Module12.isEmpty(r15);
r0 = void 0;
if (isEmpty) {
delete r13[channelId];
r0 = void 0;
}
}
}
return r0;
},
THREAD_SETTINGS_DRAFT_CHANGE: function handleThreadSettingsDraftChanged({ channelId, draft }) {
const id = AuthenticationStore.getId();
if (id != null) {
let r6 = c2733_9[id];
if (r6 == null) {
const r14 = {};
c2733_9[id] = r14;
r6 = r14;
}
let r15 = r6[channelId];
if (r15 == null) {
const r16 = {};
r6[channelId] = r16;
r15 = r16;
}
r15[c2733_8.ThreadSettings] = {
timestamp: Date.now(),
...r15[c2733_8.ThreadSettings],
...draft,
parentChannelId: channelId
};
}
}
});
export default draftStore;
export { c2733_8 as DraftType };
+87
View File
@@ -0,0 +1,87 @@
// Metro module 5966 (f5967).
import MessageStore from "./MessageStore";
import { UseLegacyChatInput } from "../modules/user_settings/UserSettings";
import MessageParser from "../modules/messages/MessageParser";
import { toRichValue } from "../modules/channel_text_area/slate/SlateUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c3756_4 = {};
let c3756_5 = {};
class EditMessageStore extends Module589.Store {
static displayName = "EditMessageStore";
initialize() {
this.waitFor(MessageStore);
}
isEditing(a0, a1) {
return c3756_4[a0]?.messageId === a1;
}
isEditingAny(a0) {
return c3756_4[a0] != null;
}
getEditingTextValue(a0) {
return c3756_4[a0]?.textValue;
}
getEditingRichValue(a0) {
return c3756_4[a0]?.richValue;
}
getEditingMessageId(a0) {
return c3756_4[a0]?.messageId;
}
getEditingMessage(a0) {
const r3 = c3756_4[a0];
return r3 != null ? r3.messageId != null ? MessageStore.getMessage(a0, r3.messageId) : null : null;
}
getEditActionSource(a0) {
return c3756_5[a0];
}
}
const editMessageStore = new EditMessageStore(Dispatcher, {
MESSAGE_START_EDIT: function handleMessageStartEdit(a0) {
const { channelId, messageId } = a0;
let content = a0.content;
const source = a0.source;
const setting = UseLegacyChatInput.getSetting();
const textValue = MessageParser.unparse(content, channelId);
if (setting) {
content = textValue;
}
c3756_4[channelId] = {
channelId,
messageId,
textValue,
richValue: toRichValue(content)
};
c3756_5[channelId] = source;
},
MESSAGE_UPDATE_EDIT: function handleMessageUpdateEdit({ channelId, textValue, richValue }) {
const r6 = c3756_4[channelId];
if (r6 == null) {
return false;
}
c3756_4[channelId] = {
...r6,
textValue,
richValue
};
},
MESSAGE_END_EDIT: function handleMessageEndEdit({ channelId }) {
if (channelId != null && c3756_4[channelId] != null) {
delete c3756_4[channelId];
delete c3756_5[channelId];
return void 0;
}
return false;
},
MESSAGE_DELETE: function handleMessageDelete(a0) {
const channelId = a0.channelId;
if (c3756_4[channelId]?.messageId === a0.id) {
delete c3756_4[channelId];
delete c3756_5[channelId];
}
},
LOGOUT: function handleLogout() {
c3756_4 = {};
c3756_5 = {};
}
});
export default editMessageStore;
+74
View File
@@ -0,0 +1,74 @@
// Metro module 5028 (f5029).
import UserSettingsProtoStore from "../modules/user_settings/UserSettingsProtoStore";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c3034_1 = new Set();
class ExpandedGuildFolderStore extends Module589.PersistedStore {
static displayName = "ExpandedGuildFolderStore";
static persistKey = "ExpandedGuildFolderStore";
initialize(a0) {
if (a0 != null) {
c3034_1 = new Set(a0.expandedFolders);
}
this.waitFor(UserSettingsProtoStore);
}
getState() {
return {
expandedFolders: Array.from(c3034_1)
};
}
getExpandedFolders() {
return c3034_1;
}
isFolderExpanded(a0) {
return c3034_1.has(a0);
}
}
const expandedGuildFolderStore = new ExpandedGuildFolderStore(Dispatcher, {
TOGGLE_GUILD_FOLDER_EXPAND: function toggleFolderExpand({ folderId }) {
const set = new Set(c3034_1);
c3034_1 = set;
const r12 = set.has(folderId);
const r13 = c3034_1;
if (r12) {
r13.delete(folderId);
} else {
r13.add(folderId);
}
},
SET_GUILD_FOLDER_EXPANDED: function setFolderExpanded({ folderId, expanded }) {
const set = new Set(c3034_1);
c3034_1 = set;
if (expanded) {
set.add(folderId);
} else if (set.has(folderId)) {
c3034_1.delete(folderId);
}
},
USER_SETTINGS_PROTO_UPDATE: function handleSettingsUpdate() {
const guildFolders = UserSettingsProtoStore.getGuildFolders();
if (guildFolders == null) {
return false;
}
let c14562_1 = false;
const _loop = function _loop(a0) {
if (!guildFolders.some((guildFolder) => guildFolder.folderId === a0)) {
const set = new Set(c3034_1);
c3034_1 = set;
set.delete(a0);
c14562_1 = true;
}
};
for (const item of c3034_1) {
_loop(item);
}
return c14562_1;
},
GUILD_FOLDER_COLLAPSE: function handleCollapseAll() {
if (c3034_1.size === 0) {
return false;
}
c3034_1 = new Set();
}
});
export default expandedGuildFolderStore;
+429
View File
@@ -0,0 +1,429 @@
// Metro module 10475 (f10476).
import ConnectedAccountsStore from "./ConnectedAccountsStore";
import StreamerModeStore from "./StreamerModeStore";
import { PlatformTypes } from "../Constants";
import Durations from "../utils/Durations";
import { HTTP } from "../_bundle/sendRequest";
import ConnectedAccountsActionCreators from "../actions/ConnectedAccountsActionCreators";
import Dispatcher from "../Dispatcher";
import { getAssetFromImageURL } from "../utils/ApplicationAssetUtils";
import Platforms from "../lib/Platforms";
import isUndefinedOrNull from "../_bundle/isUndefinedOrNull";
import Module589 from "../_bundle/Module589";
function $mk115679($env) {
return function getTwitchGame() {
return $env[16].apply(this, arguments);
};
}
function $mk115680($env) {
return function parseUsernameFromThumbnail(a0) {
const r5 = c7022_9.exec(a0);
return r5 == null ? void 0 : r5[1];
};
}
function $mk115681($env) {
return (a0) => {
const r0 = $env;
return r0[2]._checkTwitch(r0[0], a0);
};
}
function $mk115683($env) {
return (a0) => {
const r0 = $env;
return r0[2]._checkYouTube(r0[0], a0);
};
}
let streamerModeUpdate, c7022_7, c7022_8, c7022_9, c7022_13, c7022_14, c7022_17, c7022_19;
let env7022 = {};
const makeTwitchRequest = function makeTwitchRequest(a0, a1, a2) {
return HTTP.get({
url: `https://api.twitch.tv/helix${a0}`,
query: a1,
headers: {
"Client-ID": "33kozedd0zs6fbauka98psnc7zwom2s",
Authorization: `Bearer ${a2}`
},
rejectWithError: false
});
};
env7022[16] = function _getTwitchGame() {
const r8 = async (id, c26677_1) => {
let r26;
let c30224_0, c30224_1, c30224_2;
L14: {
c30224_0 = id;
c30224_1 = void 0;
c30224_2 = void 0;
r26 = c7022_14[id];
if (r26 != null) {
break L14;
}
c30224_1 = (await makeTwitchRequest("/games", {
id
}, c26677_1)).body.data;
c30224_2 = c30224_1[0]?.name;
c7022_14[c30224_0] = c30224_2;
return c30224_2;
}
return r26;
};
env7022[16] = r8;
return r8.apply(this, arguments);
};
streamerModeUpdate = function streamerModeUpdate() {
if (StreamerModeStore.enabled) {
c7022_17.start();
} else {
c7022_17.stop();
}
};
c7022_7 = 1 * Durations.Millis.MINUTE;
c7022_8 = 5 * Durations.Millis.MINUTE;
c7022_9 = /live_user_(.*)-\{width\}/;
env7022[10] = null;
env7022[11] = 0;
env7022[12] = null;
c7022_13 = new Set();
c7022_14 = {};
class StreamingPoller {
_started = false;
start() {
if (!this._started) {
this._started = true;
if (ConnectedAccountsStore.isFetching()) {
ConnectedAccountsActionCreators.fetch();
} else {
this._check();
}
}
}
stop() {
this._started = false;
env7022[12] = null;
env7022[11] = 0;
if (this._nextCheck != null) {
clearTimeout(this._nextCheck);
}
Dispatcher.dispatch({
type: "STREAMING_UPDATE",
stream: null
});
}
async _checkTwitch(a0) {
let r186, r206;
let env17989 = {
$parent: env7022
};
env17989[0] = a0;
let r5 = arguments[1];
if (r5 === void 0) {
r5 = null;
}
env17989[1] = r5;
env17989[2] = this;
let accessToken, assetFromImageURL, name, c26678_3, c26678_4, c26678_5;
let c26678_6 = 0;
const r22 = env17989;
L36: {
L35: {
L34: {
try {
let env30225;
c26678_4 = r22;
const r45 = env30225 = {
$parent: r22
};
c26678_3 = r45;
env30225[0] = void 0;
env30225[1] = void 0;
env30225[2] = void 0;
env30225[3] = void 0;
env30225[4] = void 0;
env30225[5] = void 0;
env30225[6] = void 0;
env30225[7] = void 0;
env30225[8] = void 0;
env30225[9] = void 0;
if (env17989[0].revoked) {
break L36;
}
accessToken = env17989[1];
if (accessToken == null) {
accessToken = env17989[0].accessToken;
}
env17989[1] = accessToken;
if (accessToken == null) {
break L35;
}
c26678_6 = 1;
env30225[0] = (await makeTwitchRequest("/streams", {
user_id: env17989[0].id,
first: 1
}, env17989[1])).body.data[0];
if (env30225[0] != null && env30225[0].type === "live") {
env30225[1] = env30225[0].thumbnail_url;
env30225[2] = env30225[0].game_id;
env30225[3] = env30225[0].title;
const r102 = env30225[1] != null;
let large_image = void 0;
if (r102) {
assetFromImageURL = getAssetFromImageURL(PlatformTypes.TWITCH, env30225[1]);
if (assetFromImageURL == null) {
assetFromImageURL = void 0;
}
large_image = assetFromImageURL;
}
env30225[4] = {
large_image
};
const r106 = env30225[2];
const r107 = env17989[1];
env30225[5] = await $mk115679(env7022)(r106, r107);
env30225[6] = Platforms.get(PlatformTypes.TWITCH);
const r156 = env30225[1];
name = $mk115680(env7022)(r156);
if (name == null) {
name = env17989[0].name;
}
env30225[7] = name;
env30225[8] = env30225[3] != null ? env30225[3] !== "" ? env30225[3].slice(0, 128) : void 0 : void 0;
env30225[9] = env30225[5] != null ? env30225[5] !== "" ? env30225[5].slice(0, 128) : void 0 : void 0;
const r177 = env30225[6];
const getPlatformUserUrl = r177.getPlatformUserUrl;
r186 = {
url: getPlatformUserUrl == null ? void 0 : getPlatformUserUrl.call(r177, {
id: env17989[0].id,
name: env30225[7]
}),
name: env30225[6].name,
assets: env30225[4],
details: env30225[8],
state: env30225[9]
};
c26678_6 = 0;
break L34;
}
throw new Error("no stream");
} catch ($e) {
const r43 = $e;
let r13 = r43;
c26678_5 = r43;
if (c26678_6 !== 0) {
while (true) {
try {
const r203 = c26678_5;
c26678_6 = 0;
r206 = r203.status === 401 ? env17989[1] == null ? ConnectedAccountsActionCreators.refreshAccessToken(env17989[0].type, env17989[0].id).then($mk115681(env17989)).catch(() => null) : null : null;
} catch (r201) {
r13 = r201;
c26678_5 = r201;
if (c26678_6 === 0) {
break;
}
continue;
}
return r206;
}
}
throw r13;
}
}
return r186;
}
return null;
}
return null;
}
async _checkYouTube(a0) {
let r135, r166;
let env17990 = {
$parent: env7022
};
env17990[0] = a0;
let r5 = arguments[1];
if (r5 === void 0) {
r5 = null;
}
env17990[1] = r5;
env17990[2] = this;
let assetFromImageURL2, c26679_1, c26679_2, c26679_3;
let c26679_4 = 0;
const r22 = env17990;
L23: {
try {
let env30226;
c26679_2 = r22;
const r44 = env30226 = {
$parent: r22
};
c26679_1 = r44;
env30226[0] = void 0;
env30226[1] = void 0;
env30226[2] = void 0;
env30226[3] = void 0;
env30226[4] = void 0;
env30226[5] = void 0;
env30226[6] = void 0;
env30226[7] = void 0;
env30226[8] = void 0;
env7022[12] = null;
if (env17990[0].revoked) {
break L23;
}
if (c7022_13.has(env17990[0].id)) {
break L23;
}
c26679_4 = 1;
env30226[0] = (await HTTP.get({
url: "https://www.googleapis.com/youtube/v3/liveBroadcasts",
query: {
part: "id,snippet",
broadcastStatus: "active",
broadcastType: "all"
},
headers: {
Authorization: `Bearer ${env17990[1] != null ? env17990[1] : env17990[0].accessToken}`
},
oldFormErrors: true,
rejectWithError: false
})).body.items;
if (env30226[0].length < 1) {
throw new Error("no stream");
}
env30226[1] = env30226[0][0];
env30226[2] = env30226[1].id;
env30226[3] = env30226[1].snippet;
env30226[4] = env30226[3].title;
env30226[5] = env30226[3].thumbnails;
assetFromImageURL2 = getAssetFromImageURL(PlatformTypes.YOUTUBE, env30226[5].high.url);
if (assetFromImageURL2 == null) {
assetFromImageURL2 = void 0;
}
env30226[6] = {
large_image: assetFromImageURL2
};
env30226[7] = env30226[4] != null ? env30226[4] !== "" ? env30226[4].slice(0, 128) : void 0 : void 0;
env30226[8] = env30226[2];
r135 = {
url: `https://youtube.com/watch?v=${env30226[8]}`,
name: Platforms.get(PlatformTypes.YOUTUBE).name,
details: env30226[7],
assets: env30226[6]
};
env7022[12] = r135;
c26679_4 = 0;
} catch ($e) {
const r42 = $e;
let r13 = r42;
c26679_3 = r42;
if (c26679_4 !== 0) {
while (true) {
L34: {
try {
const r159 = c26679_3;
c26679_4 = 0;
env30226[9] = r159;
if (env30226[9].status === 401 && env17990[1] == null) {
r166 = ConnectedAccountsActionCreators.refreshAccessToken(env17990[0].type, env17990[0].id).then($mk115683(env17990)).catch(() => null);
break L34;
}
const status = env30226[9].status;
r166 = null;
if (status === 403) {
c7022_13.add(env17990[0].id);
r166 = null;
}
} catch (r156) {
r13 = r156;
c26679_3 = r156;
if (c26679_4 === 0) {
break;
}
continue;
}
}
return r166;
}
}
throw r13;
}
return r135;
}
return null;
}
_check() {
let c17991_0;
if (this._started) {
const accounts = ConnectedAccountsStore.getAccounts();
if (accounts != null) {
if (this._nextCheck != null) {
clearTimeout(this._nextCheck);
}
const r8 = [PlatformTypes.TWITCH];
c17991_0 = r8;
const r20 = Date.now();
if (env7022[11] <= r20) {
r8.push(PlatformTypes.YOUTUBE);
env7022[11] = r20 + c7022_8;
}
Promise.allSettled(accounts.filter((account) => c17991_0.includes(account.type)).map((item) => item.type === PlatformTypes.TWITCH ? this._checkTwitch(item) : this._checkYouTube(item))).then((result) => {
if (this._started) {
let stream = result.find((item) => item.status === "fulfilled" && item.value != null)?.value;
if (stream == null && env7022[12] != null) {
stream = env7022[12];
}
Dispatcher.dispatch({
type: "STREAMING_UPDATE",
stream
});
}
this._scheduleCheck();
});
}
}
}
_scheduleCheck() {
if (this._started) {
this._nextCheck = setTimeout(() => this._check(), c7022_7);
}
}
}
const r64 = {
__proto__: StreamingPoller.prototype
};
r64._started = false;
c7022_17 = r64;
class ExternalStreamingStore extends Module589.Store {
static displayName = "ExternalStreamingStore";
constructor() {
super(...arguments);
}
initialize() {
const enabled = StreamerModeStore.enabled;
if (enabled) {
c7022_17.start();
} else {
c7022_17.stop();
}
this.waitFor(ConnectedAccountsStore, StreamerModeStore);
this.syncWith([StreamerModeStore], streamerModeUpdate);
}
getStream() {
return env7022[10];
}
}
c7022_19 = ExternalStreamingStore;
const r82 = new ExternalStreamingStore(Dispatcher, {
STREAMING_UPDATE: function streamUpdate(a0) {
if (isUndefinedOrNull(a0.stream, env7022[10])) {
return false;
}
let stream = a0.stream;
if (stream == null) {
stream = null;
}
env7022[10] = stream;
},
USER_CONNECTIONS_UPDATE: () => c7022_17._check()
});
export default r82;
+177
View File
@@ -0,0 +1,177 @@
// Metro module 5099 (f5100).
import UserSettingsProtoStore from "../modules/user_settings/UserSettingsProtoStore";
import ChannelStore from "./ChannelStore";
import GuildStore from "./GuildStore";
import SelectedChannelStore from "./SelectedChannelStore";
import SelectedGuildStore from "./SelectedGuildStore";
import { ID_REGEX } from "../Constants";
import { UserSettingsTypes } from "../modules/user_settings/UserSettingsConstants";
import Frecency from "../lib/Frecency";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c3067_9, c3067_10, c3067_11, initFrecency, c3067_13;
const handleChannelSelect = function handleChannelSelect({ guildId, channelId }) {
const r10 = c3067_10;
let r1 = false;
if (channelId !== r10) {
let r11 = channelId;
if (r11 == null) {
r11 = null;
}
c3067_10 = r11;
const r12 = channelId != null && ID_REGEX.test(channelId);
let r0 = false;
if (r12) {
c3067_9.track(channelId);
c3067_13.pendingUsages.push({
key: channelId,
timestamp: Date.now()
});
r0 = true;
}
r1 = r0;
}
const r24 = c3067_11;
let r25 = r1;
if (guildId !== r24) {
let r27 = guildId;
if (r27 == null) {
r27 = null;
}
c3067_11 = r27;
if (guildId != null && ID_REGEX.test(guildId)) {
c3067_9.track(guildId);
c3067_13.pendingUsages.push({
key: guildId,
timestamp: Date.now()
});
r1 = true;
}
r25 = r1;
}
return r25;
};
initFrecency = function initFrecency() {
const guildAndChannels = UserSettingsProtoStore.frecencyWithoutFetchingLatest.guildAndChannelFrecency?.guildAndChannels;
if (guildAndChannels == null) {
return false;
}
c3067_9.overwriteHistory(Module12.mapValues(guildAndChannels, (a0) => ({
...a0,
recentUses: a0.recentUses.map(Number).filter((item) => item > 0)
})), c3067_13.pendingUsages);
};
c3067_9 = new Frecency({
computeBonus: () => 100,
computeWeight: (a0) => {
let r0;
L9: {
r0 = 100;
if (a0 !== 0) {
if (a0 >= 1) {
const r3 = a0 < 2;
r0 = 70;
if (r3) {
break L9;
}
}
if (a0 >= 2) {
const r8 = a0 < 4;
r0 = 50;
if (r8) {
break L9;
}
}
if (a0 >= 4) {
const r11 = a0 < 7;
r0 = 30;
if (r11) {
break L9;
}
}
r0 = a0 >= 7 ? 10 : 1;
}
}
return r0;
},
lookupKey: (a0) => {
let r6 = GuildStore.getGuild(a0);
if (r6 == null) {
r6 = ChannelStore.getChannel(a0);
}
if (r6 == null) {
r6 = ChannelStore.getChannel(ChannelStore.getDMFromUserId(a0));
}
return r6;
},
afterCompute: () => {},
numFrequentlyItems: 100,
maxSamples: 10
});
c3067_10 = null;
c3067_11 = null;
c3067_13 = {
pendingUsages: []
};
class FrecencyStore extends Module589.PersistedStore {
static displayName = "FrecencyStore";
static persistKey = "FrecencyStore";
initialize(a0) {
this.waitFor(ChannelStore, GuildStore, SelectedChannelStore, SelectedGuildStore, UserSettingsProtoStore);
if (a0 != null) {
a0.pendingUsages = a0.pendingUsages.filter((pendingUsage) => pendingUsage != null && ID_REGEX.test(pendingUsage.key));
c3067_13 = a0;
}
this.syncWith([UserSettingsProtoStore], initFrecency);
}
getState() {
return c3067_13;
}
hasPendingUsage() {
return c3067_13.pendingUsages.length > 0;
}
get frecencyWithoutFetchingLatest() {
return c3067_9;
}
getFrequentlyWithoutFetchingLatest() {
return c3067_9.frequently;
}
getScoreWithoutFetchingLatest(a0) {
let r6 = c3067_9.getFrecency(a0);
if (r6 == null) {
r6 = 0;
}
return r6;
}
getScoreForDMWithoutFetchingLatest(a0) {
const dMFromUserId = ChannelStore.getDMFromUserId(a0);
return dMFromUserId != null ? this.getScoreWithoutFetchingLatest(dMFromUserId) : 0;
}
getMaxScore() {
return 1000;
}
getBonusScore() {
return 100;
}
getVersion() {
return c3067_9.version;
}
}
const frecencyStore = new FrecencyStore(Dispatcher, {
CHANNEL_SELECT: handleChannelSelect,
VOICE_CHANNEL_SELECT: handleChannelSelect,
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate(a0) {
const type = a0.settings.type;
const wasSaved = a0.wasSaved;
const r0 = type !== UserSettingsTypes.FRECENCY_AND_FAVORITES_SETTINGS || !wasSaved;
let r1 = !r0;
if (!r0) {
c3067_13.pendingUsages = [];
r1 = true;
}
return r1;
}
});
export default frecencyStore;
export const MAX_NUM_SELECTED_ITEMS = 100;
+238
View File
@@ -0,0 +1,238 @@
// Metro module 12373 (f12374).
import AuthenticationStore from "./AuthenticationStore";
import RelationshipStore from "./RelationshipStore";
import SelfPresenceStore from "./SelfPresenceStore";
import { StatusTypes, ME } from "../Constants";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
function $mk89737($env) {
return (a0) => {
const r3 = $env;
if (a0 != null && (0, $env.$parent[9])(r3[0], a0.user.id, a0.activities, a0.status)) {
r3[1] = true;
}
};
}
let handleGuildCreate, handleLocalPresenceUpdate, c8544_12;
let env8544 = {};
const updateParty = function updateParty(a0, a1, a2, a3) {
const r18 = a2.find((item) => item.party != null && Boolean(item.party.id));
const r13 = r18 != null ? r18.party != null ? r18.party.id : null : null;
let r24 = env8544[7][a1];
if (r24 == null) {
r24 = {};
}
const r26 = r24[a0];
if (r13 != null && a3 !== StatusTypes.OFFLINE) {
if (r26 != null) {
if (r26 === r13) {
return false;
}
let r29 = env8544[7][a1];
if (r29 == null) {
r29 = {};
}
const r12 = r29[a0];
if (r12 != null) {
const r14 = env8544[7][a1];
delete r14[a0];
if (Module12.isEmpty(r14)) {
delete env8544[7][a1];
}
const r42 = env8544[8].get(r12);
if (r42 != null) {
r42.delete(a1);
if (r42.size === 0) {
env8544[8].delete(r12);
}
}
}
}
let r50 = env8544[7][a1];
if (r50 == null) {
const r51 = env8544[7];
const r52 = {};
r51[a1] = r52;
r50 = r52;
}
r50[a0] = r13;
if (!RelationshipStore.isBlocked(a1) && !RelationshipStore.isIgnored(a1)) {
let r60 = env8544[8].get(r13);
if (r60 == null) {
r60 = new Set();
}
env8544[8].set(r13, r60);
r60.add(a1);
}
return true;
}
let r72 = r26 != null;
if (r72) {
let r74 = env8544[7][a1];
if (r74 == null) {
r74 = {};
}
const r75 = r74[a0];
const r5 = r75 != null;
r72 = true;
if (r5) {
const r77 = env8544[7][a1];
delete r77[a0];
if (Module12.isEmpty(r77)) {
delete env8544[7][a1];
}
const r89 = env8544[8].get(r75);
const r90 = r89 != null;
r72 = true;
if (r90) {
r89.delete(a1);
const size = r89.size;
r72 = true;
if (size === 0) {
env8544[8].delete(r75);
r72 = true;
}
}
}
}
return r72;
};
handleGuildCreate = function handleGuildCreate({ guild }) {
let r0 = false;
for (const presence of guild.presences) {
if (updateParty(guild.id, presence.user.id, presence.activities, presence.status) !== false) {
r0 = true;
}
}
return r0;
};
handleLocalPresenceUpdate = function handleLocalPresenceUpdate() {
return updateParty(ME, AuthenticationStore.getId(), SelfPresenceStore.getActivities());
};
const handleRelationshipAddOrUpdate = function handleRelationshipAddOrUpdate({ relationship }) {
if (!RelationshipStore.isBlocked(relationship.id) && !RelationshipStore.isIgnored(relationship.id)) {
return false;
}
const r7 = env8544[7][relationship.id];
if (r7 == null) {
return false;
}
for (const item of Module12.values(r7)) {
const r42 = env8544[8].get(item);
if (r42 != null) {
r42.delete(relationship.id);
}
}
};
env8544[7] = {};
env8544[8] = new Map();
class GamePartyStore extends Module589.Store {
static displayName = "GamePartyStore";
constructor() {
super(...arguments);
}
initialize() {
this.syncWith([SelfPresenceStore], handleLocalPresenceUpdate);
this.waitFor(AuthenticationStore, RelationshipStore, SelfPresenceStore);
}
getParty(a0) {
return a0 != null ? env8544[8].has(a0) ? env8544[8].get(a0) : null : null;
}
getUserParties() {
return env8544[7];
}
getParties() {
return env8544[8];
}
}
c8544_12 = GamePartyStore;
const r60 = new GamePartyStore(Dispatcher, {
CONNECTION_OPEN_SUPPLEMENTAL: function handleConnectionOpenSupplemental({ guilds, presences }) {
let r0 = false;
for (const item of presences) {
const { user, status, activities } = item;
if (user != null && updateParty(ME, user.id, activities, status) !== false) {
r0 = true;
}
}
for (const item2 of guilds) {
if (handleGuildCreate({
guild: item2
}) !== false) {
r0 = true;
}
}
return r0;
},
OVERLAY_INITIALIZE: function handleOverlayInitialize({ parties, userParties }) {
env8544[8] = new Map();
env8544[7] = {
...userParties
};
Object.keys(parties).forEach((item) => env8544[8].set(item, new Set(parties[item])));
},
GUILD_CREATE: handleGuildCreate,
PRESENCES_REPLACE: function handlePresenceReplace({ presences }) {
let r0 = false;
for (const item of presences) {
const { user, activities } = item;
if (user != null && updateParty(ME, user.id, activities) !== false) {
r0 = true;
}
}
return r0;
},
PRESENCE_UPDATES: function handlePresenceUpdates(a0) {
return a0.updates.map((update) => {
let guildId = update.guildId;
const { user, status, activities } = update;
if (guildId == null) {
guildId = ME;
}
return updateParty(guildId, user.id, activities, status);
}).some((item) => item);
},
THREAD_MEMBER_LIST_UPDATE: function handleThreadMemberListUpdate(a0) {
let env19812;
const guildId = a0.guildId;
const r6 = a0.members.map((member) => member.presence);
const r7 = env19812 = {
$parent: env8544
};
env19812[0] = guildId;
env19812[1] = false;
r6.forEach($mk89737(r7));
return env19812[1];
},
THREAD_MEMBERS_UPDATE: function handleThreadMembersUpdate({ guildId, addedMembers }) {
let r6 = addedMembers != null;
if (r6) {
let env19813;
const r8 = addedMembers.map((addedMember) => addedMember.presence);
const r9 = env19813 = {
$parent: env8544
};
env19813[0] = guildId;
env19813[1] = false;
r8.forEach($mk89737(r9));
r6 = env19813[1];
}
return r6;
},
RELATIONSHIP_ADD: handleRelationshipAddOrUpdate,
RELATIONSHIP_UPDATE: handleRelationshipAddOrUpdate,
RELATIONSHIP_REMOVE: function handleRelationshipRemove({ relationship }) {
const r7 = env8544[7][relationship.id];
if (r7 == null) {
return false;
}
for (const item of Module12.values(r7)) {
const r34 = env8544[8].get(item);
if (r34 != null) {
r34.add(relationship.id);
}
}
}
});
export default r60;
+33
View File
@@ -0,0 +1,33 @@
// Metro module 12798 (f12799).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
const geoRestrictedGuilds = [];
class GeoRestrictedGuildStore extends Module589.Store {
static displayName = "GeoRestrictedGuildStore";
getGeoRestrictedGuilds() {
return geoRestrictedGuilds;
}
}
const geoRestrictedGuildStore = new GeoRestrictedGuildStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
geoRestrictedGuilds = a0.geoRestrictedGuilds;
},
GUILD_DELETE: function handleDeleteGuild({ guild }) {
if (geoRestrictedGuilds.findIndex((geoRestrictedGuild) => geoRestrictedGuild.id === guild.id) === -1) {
return false;
}
geoRestrictedGuilds = geoRestrictedGuilds.filter((geoRestrictedGuild) => geoRestrictedGuild.id !== guild.id);
},
GUILD_GEO_RESTRICTED: function handleGeoRestrictGuild(a0) {
const r8 = geoRestrictedGuilds.filter((geoRestrictedGuild) => geoRestrictedGuild.id !== a0.guildId);
r8.push({
id: a0.guildId,
name: a0.name,
icon: a0.icon,
unavailable: true,
geo_restricted: true
});
geoRestrictedGuilds = r8;
}
});
export default geoRestrictedGuildStore;
+300
View File
@@ -0,0 +1,300 @@
// Metro module 8032 (f8033).
import GiftCodeRecord from "../records/GiftCodeRecord";
import { MAX_TIMEOUT_MS, NOOP_NULL, AbortCodes } from "../Constants";
import { Timeout } from "../_bundle/Timeout";
import Module3771 from "../_bundle/Module3771";
import { isGiftCodeEmbed, findGiftCodes, makeComboId } from "../utils/GiftCodeUtils";
import Dispatcher from "../Dispatcher";
import GiftCodeActionCreators from "../actions/GiftCodeActionCreators";
import Module589 from "../_bundle/Module589";
function $mk79690($env) {
return () => {
let env26084;
const r3 = $env.$parent;
const r5 = $env[0];
const r13 = env26084 = {
$parent: r3
};
env26084[0] = r5;
const r6 = r3[8];
const r14 = r6.get(r5);
if (r14 != null && r14.expiresAt != null) {
const r12 = r14.expiresAt.valueOf() - (0, r3[1])(r3[2][3])().valueOf();
if (r12 <= 0) {
r6.delete(r5);
delete r3[7][r5];
r3[18].emitChange();
} else {
const r25 = r3[7][r5];
if (r25 != null) {
r25.start(Math.min(r3[5], r12), $mk79690(r13));
}
}
}
};
}
let resolveMessageGiftCodes, c5086_7, c5086_8, c5086_12, c5086_13, c5086_14, c5086_15, c5086_19, c5086_18;
let env5086 = {};
const updateGiftCode = function updateGiftCode(a0) {
const fromServer = GiftCodeRecord.createFromServer(a0);
const code4 = fromServer.code;
if (c5086_8.has(code4)) {
c5086_8.set(code4, c5086_8.get(code4).merge(fromServer));
} else {
c5086_8.set(code4, fromServer);
if (fromServer.expiresAt != null) {
let env16196;
const timeout = new Timeout();
c5086_7[code4] = timeout;
const r31 = env16196 = {
$parent: env5086
};
env16196[0] = code4;
const r33 = c5086_8.get(code4);
if (r33 != null && r33.expiresAt != null) {
const r15 = r33.expiresAt.valueOf() - Module3771().valueOf();
if (r15 <= 0) {
c5086_8.delete(code4);
delete c5086_7[code4];
c5086_18.emitChange();
} else {
const r43 = c5086_7[code4];
if (r43 != null) {
r43.start(Math.min(MAX_TIMEOUT_MS, r15), $mk79690(r31));
}
}
}
}
}
};
resolveMessageGiftCodes = function resolveMessageGiftCodes(a0, r1 = false) {
if (r1 && !c5086_15.has(a0.channel_id)) {
return false;
}
const r22 = isGiftCodeEmbed(a0) ? findGiftCodes(a0?.embeds != null ? a0 == null ? void 0 : a0.embeds[0].url : void 0) : findGiftCodes(a0.content);
if (r22.length !== 0) {
r22.forEach((item) => {
if (!(env5086[9].includes(item) || env5086[11].includes(item))) {
if (!env5086[9].includes(item)) {
env5086[9] = [...env5086[9], item];
}
Dispatcher.wait(() => GiftCodeActionCreators.resolveGiftCode(item, false, true).catch(NOOP_NULL));
}
});
}
return false;
};
const handleMessage = function handleMessage(a0) {
resolveMessageGiftCodes(a0.message, true);
return false;
};
const handleLoadMessages = function handleLoadMessages({ channelId, messages }) {
c5086_15.add(channelId);
messages.forEach((message) => {
resolveMessageGiftCodes(message, true);
return false;
});
};
const handleLoadThreadsSuccess = function handleLoadThreadsSuccess({ firstMessages }) {
if (firstMessages == null) {
return false;
}
if (firstMessages != null) {
firstMessages.forEach((firstMessage) => {
resolveMessageGiftCodes(firstMessage);
return false;
});
}
};
c5086_7 = {};
c5086_8 = new Map();
env5086[9] = [];
env5086[10] = [];
env5086[11] = [];
c5086_12 = new Set();
c5086_13 = {};
c5086_14 = {};
c5086_15 = new Set();
class GiftCodeStore extends Module589.Store {
static displayName = "GiftCodeStore";
constructor() {
super(...arguments);
}
get(a0) {
const r6 = c5086_8.get(a0);
return r6 == null ? null : r6.isExpired() ? null : r6;
}
getError(a0) {
return a0 != null ? c5086_14[a0] : null;
}
getForGifterSKUAndPlan(c16197_0, c16197_1, c16197_2) {
return Array.from(c5086_8.values()).filter((item) => {
let r0 = item.userId === c16197_0 && item.skuId === c16197_1;
if (r0) {
r0 = c16197_2 == null || item.subscriptionPlanId === c16197_2;
}
if (r0) {
r0 = !item.isExpired();
}
return r0;
});
}
getIsResolving(a0) {
return env5086[9].includes(a0);
}
getIsResolved(a0) {
return env5086[11].includes(a0);
}
getIsAccepting(a0) {
return env5086[10].includes(a0);
}
getUserGiftCodesFetchingForSKUAndPlan(a0, a1) {
return c5086_12.has(makeComboId(a0, a1));
}
getUserGiftCodesLoadedAtForSKUAndPlan(a0, a1) {
return c5086_13[makeComboId(a0, a1)];
}
getResolvingCodes() {
return env5086[9];
}
getResolvedCodes() {
return env5086[11];
}
getAcceptingCodes() {
return env5086[10];
}
}
c5086_19 = GiftCodeStore;
c5086_18 = new GiftCodeStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c5086_15.clear();
return false;
},
CHANNEL_SELECT: function handleChannelSelect({ channelId }) {
if (channelId != null) {
c5086_15.add(channelId);
}
return false;
},
GIFT_CODE_RESOLVE: function handleGiftCodeResolve({ code: code4 }) {
if (!env5086[9].includes(code4)) {
env5086[9] = [...env5086[9], code4];
}
},
GIFT_CODE_RESOLVE_SUCCESS: function handleGiftCodeResolveSuccess({ giftCode }) {
env5086[9] = env5086[9].filter((item) => item !== giftCode.code);
if (!env5086[11].includes(giftCode.code)) {
env5086[11] = [...env5086[11], giftCode.code];
}
updateGiftCode(giftCode);
},
GIFT_CODE_RESOLVE_FAILURE: function handleGiftCodeResolveFailure({ code, error }) {
env5086[9] = env5086[9].filter((item) => item !== code);
if (!env5086[11].includes(code)) {
env5086[11] = [...env5086[11], code];
}
if (error != null) {
c5086_14[code] = error;
}
},
GIFT_CODE_REDEEM: function handleGiftCodeAccept({ code: code4 }) {
if (!env5086[10].includes(code4)) {
env5086[10] = [...env5086[10], code4];
}
},
GIFT_CODE_REDEEM_SUCCESS: function handleGiftCodeAcceptSuccess({ code: code2 }) {
env5086[10] = env5086[10].filter((item) => item !== code2);
const r7 = c5086_8.get(code2);
if (r7 != null) {
c5086_8.set(code2, r7.merge({
redeemed: true,
uses: r7.uses + 1
}));
}
},
GIFT_CODE_REDEEM_FAILURE: function handleGiftCodeAcceptFailure({ code: code3, error }) {
env5086[10] = env5086[10].filter((item) => item !== code3);
const r13 = c5086_8.get(code3);
c5086_14[code3] = error;
if (r13 != null) {
const code4 = error.code;
if (AbortCodes.UNKNOWN_GIFT_CODE === code4) {
c5086_8.set(code3, r13.set("revoked", true));
} else if (AbortCodes.INVALID_GIFT_REDEMPTION_EXHAUSTED === code4) {
c5086_8.set(code3, r13.set("uses", r13.maxUses));
}
}
},
GIFT_CODE_REVOKE_SUCCESS: function handleGiftCodeRevoke({ code: code4 }) {
c5086_8.delete(code4);
const r6 = c5086_7[code4];
if (r6 != null) {
r6.stop();
delete c5086_7[code4];
}
if (!env5086[11].includes(code4)) {
env5086[11] = [...env5086[11], code4];
}
},
GIFT_CODE_CREATE_SUCCESS: function handleGiftCodeCreate(a0) {
updateGiftCode(a0.giftCode);
},
GIFT_CODES_FETCH: function handleGiftCodesFetch(a0) {
c5086_12.add(makeComboId(a0.skuId, a0.subscriptionPlanId));
},
GIFT_CODES_FETCH_SUCCESS: function handleGiftCodesFetchSuccess({ giftCodes, skuId, subscriptionPlanId }) {
giftCodes.forEach(updateGiftCode);
const r14 = makeComboId(skuId, subscriptionPlanId);
c5086_13[r14] = Date.now();
c5086_12.delete(r14);
},
GIFT_CODES_FETCH_FAILURE: function handleGiftCodesFetchFail(a0) {
c5086_12.delete(makeComboId(a0.skuId, a0.subscriptionPlanId));
},
MESSAGE_CREATE: handleMessage,
MESSAGE_UPDATE: handleMessage,
LOCAL_MESSAGES_LOADED: handleLoadMessages,
LOAD_MESSAGES_SUCCESS: handleLoadMessages,
LOAD_MESSAGES_AROUND_SUCCESS: handleLoadMessages,
LOAD_RECENT_MENTIONS_SUCCESS: function handleLoadRecentMentions(a0) {
a0.messages.forEach((message) => {
resolveMessageGiftCodes(message);
return false;
});
},
LOAD_PINNED_MESSAGES_SUCCESS: function handleLoadPinnedMessages(a0) {
a0.pins.forEach((pin) => {
resolveMessageGiftCodes(pin.message);
return false;
});
},
SEARCH_MESSAGES_SUCCESS: function handleSearchMessagesSuccess(a0) {
a0.data.forEach((a0) => {
a0.messages.forEach((message) => {
message.forEach((item) => {
resolveMessageGiftCodes(item);
return false;
});
});
});
},
GIFT_CODE_UPDATE: function handleGiftCodeUpdate({ uses, code: code4 }) {
const r7 = c5086_8.get(code4);
if (r7 != null) {
c5086_8.set(code4, r7.set("uses", Math.max(r7.uses, uses)));
}
},
LOAD_THREADS_SUCCESS: handleLoadThreadsSuccess,
LOAD_ARCHIVED_THREADS_SUCCESS: handleLoadThreadsSuccess,
LOAD_FORUM_POSTS: function handleLoadForumPosts(a0) {
Object.values(a0.threads).map(({ first_message }) => {
let r5 = first_message != null;
if (r5) {
resolveMessageGiftCodes(first_message);
r5 = false;
}
return r5;
});
}
});
export default c5086_18;
+62
View File
@@ -0,0 +1,62 @@
// Metro module 8180 (f8181).
import GuildStore from "./GuildStore";
import { fetchGuildAffinities } from "../actions/GuildAffinitiesActionCreators";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c5194_3 = {
guildAffinitiesByGuildId: {},
guildAffinities: [],
lastFetched: 0
};
class GuildAffinitiesStore extends Module589.PersistedStore {
static displayName = "GuildAffinitiesStore";
static persistKey = "GuildAffinitiesStore";
initialize(a0) {
if (a0 != null) {
c5194_3 = a0;
}
this.waitFor(GuildStore);
}
getState() {
return c5194_3;
}
getGuildAffinity(a0) {
return c5194_3.guildAffinitiesByGuildId[a0];
}
get affinities() {
return c5194_3.guildAffinities;
}
get hasRequestResolved() {
return c5194_3.lastFetched !== 0;
}
}
const guildAffinitiesStore = new GuildAffinitiesStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
if (Date.now() - c5194_3.lastFetched > 86400000) {
fetchGuildAffinities();
}
return false;
},
LOAD_GUILD_AFFINITIES_SUCCESS: function handleLoadGuildAffinitiesSuccess({ guildAffinities }) {
c5194_3.guildAffinities = [];
c5194_3.guildAffinitiesByGuildId = {};
c5194_3.lastFetched = Date.now();
guildAffinities.forEach(({ affinity, guild_id }, a1) => {
const r5 = {
score: affinity,
guildId: guild_id,
index: a1
};
c5194_3.guildAffinitiesByGuildId[guild_id] = r5;
c5194_3.guildAffinities.push(r5);
});
},
LOGOUT: function handleLogout() {
c5194_3 = {
guildAffinitiesByGuildId: {},
guildAffinities: [],
lastFetched: 0
};
}
});
export default guildAffinitiesStore;
+67
View File
@@ -0,0 +1,67 @@
// Metro module 4527 (f4528).
import GuildStore from "./GuildStore";
import Logger from "../modules/debug/Logger";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2734_1, c2734_2;
const handleConnectionOpen = function handleConnectionOpen(a0) {
c2734_2 = new Set(a0.unavailableGuilds);
if (a0.unavailableGuilds.length > 0) {
c2734_1.warn(`${a0.unavailableGuilds.length} guilds are unavailable on connection open: ${a0.unavailableGuilds}`);
}
};
const handleGuild = function handleGuild(a0) {
if (c2734_2.has(a0.guild.id)) {
c2734_2.delete(a0.guild.id);
c2734_1.info(`Guild has become available: ${a0.guild.id}`);
return void 0;
}
return false;
};
c2734_1 = new Logger("GuildAvailabilityStore");
c2734_2 = new Set();
class GuildAvailabilityStore extends Module589.Store {
static displayName = "GuildAvailabilityStore";
initialize() {
this.waitFor(GuildStore);
}
isUnavailable(a0) {
return a0 != null && c2734_2.has(a0);
}
get totalGuilds() {
return GuildStore.getGuildCount() + c2734_2.size;
}
get totalUnavailableGuilds() {
return c2734_2.size;
}
get unavailableGuilds() {
return Array.from(c2734_2);
}
}
const guildAvailabilityStore = new GuildAvailabilityStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
GUILD_UNAVAILABLE: function handleGuildUnavailable(a0) {
if (c2734_2.has(a0.guildId)) {
return false;
}
const guild = GuildStore.getGuild(a0.guildId);
c2734_1.warn(`Guild has gone unavailable: ${a0.guildId} (${guild != null && guild.name != null ? guild.name : "???"})`);
c2734_2.add(a0.guildId);
},
GUILD_DELETE: function handleGuildDelete(a0) {
if (a0.guild.unavailable !== true) {
c2734_2.delete(a0.guild.id);
}
},
GUILD_CREATE: handleGuild,
GUILD_UPDATE: handleGuild,
GUILD_GEO_RESTRICTED: function handleGuildGeoRestrict(a0) {
if (c2734_2.has(a0.guildId)) {
c2734_2.delete(a0.guildId);
return void 0;
}
return false;
}
});
export default guildAvailabilityStore;
+331
View File
@@ -0,0 +1,331 @@
// Metro module 5127 (f5128).
import FavoriteStore from "../modules/favorites/FavoriteStore";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import GuildChannelStore, { GUILD_SELECTABLE_CHANNELS_KEY, GUILD_VOCAL_CHANNELS_KEY } from "./GuildChannelStore";
import GuildStore from "./GuildStore";
import { ChannelTypes, FAVORITES } from "../Constants";
import getFlattedChannelList from "../modules/channel/getFlattedChannelList";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
function $mk75511($env) {
return function updateChannel({ channel }) {
const r7 = $env[0];
let r4 = r7[channel.parent_id != null ? channel.parent_id : "null"];
if (r4 == null) {
r4 = r7.null;
}
r4.push({
channel,
index: -1
});
};
}
function $mk75512($env) {
return ({ channel }) => {
const r3 = $env[0];
r3._categories.push({
channel,
index: -1
});
r3[channel.id] = [];
};
}
let c3089_11, c3089_12, c3089_13, c3089_14, rebuildGuild, updateSelectedVoiceChannel, handleFavoritesUpdate;
const setIndex = function setIndex(a0, a1) {
a0.index = a1;
};
rebuildGuild = function rebuildGuild(guild_id) {
let env14675;
const r4 = env14675 = {};
const r6 = $mk75511(r4);
const channels = GuildChannelStore.getChannels(guild_id);
const r10 = {
_categories: [],
null: []
};
env14675[0] = r10;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r4));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r10._categories, r10).forEach(setIndex);
c3089_12[guild_id] = r10;
return r10;
};
const handleConnectionOpen = function handleConnectionOpen() {
c3089_12 = {};
if (c3089_11 != null) {
let env14676;
const r4 = env14676 = {};
const r6 = $mk75511(r4);
const channels = GuildChannelStore.getChannels(c3089_11);
const r12 = {
_categories: [],
null: []
};
env14676[0] = r12;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r4));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r12._categories, r12).forEach(setIndex);
c3089_12[c3089_11] = r12;
}
};
const handleGuildUpdates = function handleGuildUpdates(a0) {
const id = a0.guild.id;
c3089_12[id] = void 0;
if (c3089_11 === id) {
let env14677;
const r4 = env14677 = {};
const r6 = $mk75511(r4);
const channels = GuildChannelStore.getChannels(id);
const r14 = {
_categories: [],
null: []
};
env14677[0] = r14;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r4));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r14._categories, r14).forEach(setIndex);
c3089_12[id] = r14;
}
};
const handleChannelUpdate = function handleChannelUpdate(a0) {
const guild_id = a0.channel.guild_id;
if (guild_id == null) {
return false;
}
c3089_12[guild_id] = void 0;
if (c3089_11 === guild_id) {
let env14678;
const r4 = env14678 = {};
const r6 = $mk75511(r4);
const channels = GuildChannelStore.getChannels(guild_id);
const r15 = {
_categories: [],
null: []
};
env14678[0] = r15;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r4));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r15._categories, r15).forEach(setIndex);
c3089_12[guild_id] = r15;
}
};
const handleGuildRoleUpdate = function handleGuildRoleUpdate({ guildId }) {
c3089_12[guildId] = void 0;
if (guildId === c3089_11) {
let env14679;
const r4 = env14679 = {};
const r6 = $mk75511(r4);
const channels = GuildChannelStore.getChannels(guildId);
const r13 = {
_categories: [],
null: []
};
env14679[0] = r13;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r4));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r13._categories, r13).forEach(setIndex);
c3089_12[guildId] = r13;
}
};
updateSelectedVoiceChannel = function updateSelectedVoiceChannel(a0, channelId) {
c3089_13 = channelId;
if (a0 != null && a0.getGuildId() != null) {
const guildId = a0.getGuildId();
let r15 = guildId != null;
if (r15) {
c3089_12[guildId] = void 0;
r15 = true;
if (guildId === c3089_11) {
let env14680;
const r6 = env14680 = {};
const r8 = $mk75511(r6);
const channels = GuildChannelStore.getChannels(guildId);
const r20 = {
_categories: [],
null: []
};
env14680[0] = r20;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r6));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r8);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r8);
getFlattedChannelList(r20._categories, r20).forEach(setIndex);
c3089_12[guildId] = r20;
r15 = true;
}
}
return r15;
}
return false;
};
handleFavoritesUpdate = function handleFavoritesUpdate() {
let env14681;
const r4 = env14681 = {};
const r6 = $mk75511(r4);
const channels = GuildChannelStore.getChannels(FAVORITES);
const r10 = {
_categories: [],
null: []
};
env14681[0] = r10;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r4));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r10._categories, r10).forEach(setIndex);
c3089_12[FAVORITES] = r10;
};
c3089_11 = null;
c3089_12 = {};
c3089_13 = null;
c3089_14 = {
_categories: [],
null: []
};
class GuildCategoryStore extends Module589.Store {
static displayName = "GuildCategoryStore";
initialize() {
this.waitFor(GuildChannelStore, GuildStore, AuthenticationStore, ChannelStore, FavoriteStore);
this.syncWith([FavoriteStore], handleFavoritesUpdate);
}
getCategories(a0) {
let r1;
if (a0 != null) {
let r11 = c3089_12[a0];
if (r11 == null) {
let env14682;
const r6 = env14682 = {};
const r8 = $mk75511(r6);
const channels = GuildChannelStore.getChannels(a0);
const r13 = {
_categories: [],
null: []
};
env14682[0] = r13;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r6));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r8);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r8);
getFlattedChannelList(r13._categories, r13).forEach(setIndex);
c3089_12[a0] = r13;
r11 = r13;
}
r1 = r11;
} else {
r1 = c3089_14;
}
return r1;
}
}
const guildCategoryStore = new GuildCategoryStore(Dispatcher, {
CHANNEL_SELECT: function handleChannelSelect({ guildId }) {
let r11 = guildId;
if (r11 == null) {
r11 = null;
}
c3089_11 = r11;
let r1 = guildId != null;
if (r1) {
let r14 = c3089_12[guildId] == null;
if (r14) {
let env14683;
const r6 = env14683 = {};
const r8 = $mk75511(r6);
const channels = GuildChannelStore.getChannels(guildId);
const r17 = {
_categories: [],
null: []
};
env14683[0] = r17;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r6));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r8);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r8);
getFlattedChannelList(r17._categories, r17).forEach(setIndex);
c3089_12[guildId] = r17;
r14 = void 0;
}
r1 = r14;
}
return r1;
},
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
CACHE_LOADED_LAZY: handleConnectionOpen,
GUILD_CREATE: handleGuildUpdates,
GUILD_UPDATE: handleGuildUpdates,
GUILD_DELETE: function handleGuildDelete(a0) {
delete c3089_12[a0.guild.id];
},
CHANNEL_CREATE: handleChannelUpdate,
CHANNEL_DELETE: handleChannelUpdate,
CHANNEL_UPDATES: function handleChannelUpdates({ channels }) {
let r0 = false;
for (const item of channels) {
const guild_id = item.guild_id;
if (guild_id != null) {
c3089_12[guild_id] = void 0;
r0 = true;
if (c3089_11 === guild_id) {
rebuildGuild(guild_id);
}
}
}
return r0;
},
GUILD_MEMBER_UPDATE: function handleGuildMemberUpdate({ guildId, user }) {
if (AuthenticationStore.getId() !== user.id) {
return false;
}
c3089_12[guildId] = void 0;
if (guildId === c3089_11) {
let env14684;
const r14 = env14684 = {};
const r6 = $mk75511(r14);
const channels = GuildChannelStore.getChannels(guildId);
const r18 = {
_categories: [],
null: []
};
env14684[0] = r18;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r14));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r18._categories, r18).forEach(setIndex);
c3089_12[guildId] = r18;
}
},
CURRENT_USER_UPDATE: function handleCurrentUserUpdate() {
if (c3089_11 == null) {
return false;
}
let env14685;
const r4 = env14685 = {};
const r6 = $mk75511(r4);
const channels = GuildChannelStore.getChannels(c3089_11);
const r11 = {
_categories: [],
null: []
};
env14685[0] = r11;
channels[ChannelTypes.GUILD_CATEGORY].forEach($mk75512(r4));
channels[GUILD_SELECTABLE_CHANNELS_KEY].forEach(r6);
channels[GUILD_VOCAL_CHANNELS_KEY].forEach(r6);
getFlattedChannelList(r11._categories, r11).forEach(setIndex);
c3089_12[c3089_11] = r11;
},
GUILD_ROLE_CREATE: handleGuildRoleUpdate,
GUILD_ROLE_UPDATE: handleGuildRoleUpdate,
GUILD_ROLE_DELETE: handleGuildRoleUpdate,
IMPERSONATE_UPDATE: handleGuildRoleUpdate,
IMPERSONATE_STOP: handleGuildRoleUpdate,
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect({ channelId }) {
return channelId == null && c3089_13 != null ? updateSelectedVoiceChannel(ChannelStore.getChannel(c3089_13), null) : updateSelectedVoiceChannel(ChannelStore.getChannel(channelId), channelId);
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((acc, { channelId, sessionId }) => AuthenticationStore.getSessionId() === sessionId ? updateSelectedVoiceChannel(ChannelStore.getChannel(channelId), channelId) || acc : acc, false);
}
});
export default guildCategoryStore;
+442
View File
@@ -0,0 +1,442 @@
// Metro module 1932 (f1933).
import GatedChannelStore from "../modules/channel/GatedChannelStore";
import FavoriteStore from "../modules/favorites/FavoriteStore";
import { createFavoritesGuildChannelRecord } from "../modules/favorites/utils/createFavoritesGuildChannelRecord";
import { GUILD_NON_CATEGORY_CHANNEL_TYPES, isGuildSelectableChannelType, isGuildVocalChannelType, createChannelRecord } from "../records/ChannelRecord";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildStore from "./GuildStore";
import PermissionStore from "./PermissionStore";
import RelationshipStore from "./RelationshipStore";
import UserStore from "./UserStore";
import * as _Constants from "../Constants";
import { ChannelTypes, ElevatedPermissions, FAVORITES, Permissions } from "../Constants";
import * as _FavoritesUtils from "../modules/favorites/FavoritesUtils";
import Module12 from "../_bundle/Module12";
import { computeChannelName } from "../modules/channel/useChannelName";
import { hasAny } from "../_bundle/HighLow";
import { computePermissions } from "../utils/PermissionUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c1618_21, c1618_22, c1618_23, c1618_24, c1618_25, c1618_26, channelId, c1618_28, c1618_29, c1618_30, c1618_31, c1618_32, rebuildGuildChannels, hasElevatedPermissions2, handleFavoritesUpdate;
const comparator = function comparator(a0, a1) {
return a0.comparator - a1.comparator;
};
const resetAllGuildChannels = function resetAllGuildChannels() {
c1618_24 = {};
c1618_28 = {};
c1618_25 = {};
c1618_26 = {};
if (c1618_23 != null) {
rebuildGuildChannels(c1618_23);
}
};
rebuildGuildChannels = function rebuildGuildChannels(a0) {
let r37;
const r5 = {
id: a0
};
r5[c1618_21] = [];
r5[c1618_22] = [];
r5[ChannelTypes.GUILD_CATEGORY] = [c1618_29];
r5.count = 0;
c1618_24[a0] = r5;
c1618_28[a0] = [];
let c13350_0 = r5;
const id = r5.id;
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(id);
const r14 = {};
if (isFavoritesGuildId) {
const favoriteChannels = FavoriteStore.getFavoriteChannels();
r37 = r14;
for (const key2 in favoriteChannels) {
r37 = r14;
const channel = ChannelStore.getChannel(key2);
if (channel != null) {
const favoritesGuildChannelRecord = createFavoritesGuildChannelRecord(favoriteChannels, favoriteChannels[key2], channel);
r14[key2] = {
channel: favoritesGuildChannelRecord,
comparator: favoritesGuildChannelRecord.position
};
}
}
r37 = r14;
} else {
const mutableGuildChannelsForGuild = ChannelStore.getMutableGuildChannelsForGuild(id);
r37 = r14;
for (const key in mutableGuildChannelsForGuild) {
r37 = r14;
r14[key] = {
channel: mutableGuildChannelsForGuild[key],
comparator: mutableGuildChannelsForGuild[key].position
};
}
r37 = r14;
}
let c13351_0, c13351_1;
Module12.forEach(r37, (a0) => {
const channel = a0.channel;
c13350_0.count = c13350_0.count + 1;
if (!(GUILD_NON_CATEGORY_CHANNEL_TYPES.has(channel.type) && (!PermissionStore.can(Permissions.VIEW_CHANNEL, channel) && (!GatedChannelStore.isChannelGated(channel.guild_id, channel.id) && channel.id !== channelId)))) {
let type = channel.type;
if (isGuildSelectableChannelType(type)) {
type = c1618_21;
} else if (isGuildVocalChannelType(type)) {
type = c1618_22;
}
if (channel.type === ChannelTypes.GUILD_DIRECTORY) {
if (c1618_28[id] == null) {
c1618_28[id] = [];
}
c1618_28[id].push(a0);
}
if (c13350_0[type] != null) {
c13350_0[type].push(a0);
}
}
});
r5[c1618_21].sort(comparator);
r5[c1618_22].sort(comparator);
r5[ChannelTypes.GUILD_CATEGORY].sort(comparator);
c13351_0 = void 0;
c13351_1 = void 0;
const id2 = r5.id;
const r81 = {};
c1618_25[id2] = r81;
c13351_0 = r81;
c13351_1 = {};
r5[c1618_21].forEach(({ channel }) => {
let name;
const r15 = computeChannelName(channel, UserStore, RelationshipStore);
const hasOwnProperty = Object.prototype.hasOwnProperty;
const r22 = hasOwnProperty.call(c13351_1, r15) ? c13351_1[r15] : null;
if (r22 == null) {
c13351_1[r15] = 1;
name = r15;
} else {
c13351_1[r15] = r22 + 1;
name = r15 + `~${r22}`;
}
c13351_0[channel.id] = {
id: channel.id,
name
};
});
const r91 = (function calculateGuildHasElevatedPermissions(a0, a1) {
const guild = GuildStore.getGuild(a1);
if (guild != null && hasElevatedPermissions2(a0, guild)) {
return true;
}
let r26 = c1618_24[a1];
if (r26 == null) {
r26 = rebuildGuildChannels(a1);
}
const r30 = r26[c1618_21];
const r32 = r26[c1618_22];
for (const item of r30) {
if (!hasElevatedPermissions2(a0, item.channel)) {
continue;
}
return true;
}
for (const item2 of r32) {
if (!hasElevatedPermissions2(a0, item2.channel)) {
continue;
}
return true;
}
return false;
})(UserStore.getCurrentUser(), a0);
if (r91) {
c1618_26[a0] = true;
} else {
delete c1618_26[a0];
}
return r5;
};
const handleGuildUpdates = function handleGuildUpdates(a0) {
const id2 = a0.guild.id;
if (id2 == null) {
return false;
}
c1618_24[id2] = void 0;
if (c1618_23 === id2) {
rebuildGuildChannels(id2);
}
};
const handleChannelUpdate = function handleChannelUpdate(a0) {
const guild_id = a0.channel.guild_id;
if (guild_id == null) {
return false;
}
c1618_24[guild_id] = void 0;
if (guild_id === c1618_23) {
rebuildGuildChannels(guild_id);
}
};
const handleGuildRoleUpdate = function handleGuildRoleUpdate({ guildId }) {
c1618_24[guildId] = void 0;
if (guildId === c1618_23) {
rebuildGuildChannels(guildId);
}
};
hasElevatedPermissions2 = function hasElevatedPermissions(a0, a1) {
return hasAny(computePermissions({
user: a0,
context: a1,
checkElevated: false
}), ElevatedPermissions);
};
handleFavoritesUpdate = function handleFavoritesUpdate() {
rebuildGuildChannels(FAVORITES);
};
const { NULL_STRING_GUILD_ID, NULL_STRING_CHANNEL_ID } = _Constants;
c1618_21 = "SELECTABLE";
c1618_22 = "VOCAL";
c1618_23 = null;
c1618_24 = {};
c1618_25 = {};
c1618_26 = {};
channelId = null;
c1618_28 = {};
c1618_29 = {
comparator: -1,
channel: createChannelRecord({
id: NULL_STRING_CHANNEL_ID,
type: ChannelTypes.GUILD_CATEGORY,
name: "Uncategorized"
})
};
const r72 = {
id: NULL_STRING_GUILD_ID,
SELECTABLE: [],
VOCAL: []
};
r72[ChannelTypes.GUILD_CATEGORY] = [c1618_29];
r72.count = 0;
c1618_30 = r72;
c1618_31 = [];
c1618_32 = {};
class GuildChannelStore extends Module589.Store {
static displayName = "GuildChannelStore";
initialize() {
this.waitFor(AuthenticationStore, ChannelStore, FavoriteStore, GatedChannelStore, GuildMemberStore, GuildStore, PermissionStore, UserStore);
this.syncWith([FavoriteStore], handleFavoritesUpdate);
}
getAllGuilds() {
return c1618_24;
}
getChannels(a0) {
let r2;
if (a0 != null) {
let r6 = c1618_24[a0];
if (r6 == null) {
r6 = rebuildGuildChannels(a0);
}
r2 = r6;
} else {
r2 = c1618_30;
}
return r2;
}
getFirstChannelOfType(a0, a1, a2) {
const r9 = this.getChannels(a0)[a2].find(a1);
return r9 != null ? r9.channel : null;
}
getFirstChannel(a0, a1, r4 = false) {
let r8 = this.getFirstChannelOfType(a0, a1, c1618_21);
if (r8 == null) {
r8 = r4 ? this.getFirstChannelOfType(a0, a1, c1618_22) : null;
}
return r8;
}
getDefaultChannel(a0, r6 = false, r3 = Permissions.VIEW_CHANNEL) {
const VIEW_CHANNEL = r3;
return this.getFirstChannel(a0, (a0) => PermissionStore.can(VIEW_CHANNEL, a0.channel), r6);
}
getSFWDefaultChannel(a0, r6 = false, r3 = Permissions.VIEW_CHANNEL) {
const VIEW_CHANNEL2 = r3;
return this.getFirstChannel(a0, (a0) => PermissionStore.can(VIEW_CHANNEL2, a0.channel) && !a0.channel.nsfw, r6);
}
getSelectableChannelIds(a0) {
return this.getChannels(a0)[c1618_21].map((item) => item.channel.id);
}
getSelectableChannels(a0) {
return this.getChannels(a0)[c1618_21];
}
getVocalChannelIds(a0) {
return this.getChannels(a0)[c1618_22].map((item) => item.channel.id);
}
getDirectoryChannelIds(a0) {
const r7 = c1618_28[a0];
let r8 = r7 == null ? void 0 : r7.map((item) => item.channel.id);
if (r8 == null) {
r8 = c1618_31;
}
return r8;
}
hasSelectableChannel(a0, a1) {
return this.getSelectableChannelIds(a0).includes(a1);
}
hasElevatedPermissions(a0) {
return c1618_26[a0] || false;
}
hasChannels(a0) {
return this.getChannels(a0).count > 0;
}
hasCategories(a0) {
return this.getChannels(a0)[ChannelTypes.GUILD_CATEGORY].length > 1;
}
getTextChannelNameDisambiguations(a0) {
let r1;
if (a0 != null) {
let r5 = c1618_25[a0];
if (r5 == null) {
r5 = c1618_32;
}
r1 = r5;
} else {
r1 = c1618_32;
}
return r1;
}
}
const guildChannelStore = new GuildChannelStore(Dispatcher, {
BACKGROUND_SYNC: resetAllGuildChannels,
CHANNEL_SELECT: function handleChannelSelect({ guildId }) {
let r6 = guildId;
if (r6 == null) {
r6 = null;
}
c1618_23 = r6;
let r2 = guildId != null;
if (r2) {
let r10 = c1618_24[guildId] == null;
if (r10) {
rebuildGuildChannels(guildId);
r10 = void 0;
}
r2 = r10;
}
return r2;
},
CONNECTION_OPEN: resetAllGuildChannels,
OVERLAY_INITIALIZE: resetAllGuildChannels,
CACHE_LOADED_LAZY: resetAllGuildChannels,
GUILD_CREATE: handleGuildUpdates,
GUILD_UPDATE: handleGuildUpdates,
GUILD_DELETE: function handleGuildDelete(a0) {
const id2 = a0.guild.id;
delete c1618_24[id2];
delete c1618_25[id2];
delete c1618_26[id2];
delete c1618_28[id2];
return true;
},
GUILD_MEMBER_UPDATE: function handleGuildMemberUpdate({ guildId, user }) {
if (AuthenticationStore.getId() !== user.id) {
return false;
}
c1618_24[guildId] = void 0;
if (guildId === c1618_23) {
rebuildGuildChannels(guildId);
}
},
CHANNEL_CREATE: handleChannelUpdate,
CHANNEL_DELETE: handleChannelUpdate,
CHANNEL_UPDATES: function handleChannelUpdates({ channels }) {
let r0 = false;
for (const item of channels) {
const guild_id = item.guild_id;
if (guild_id != null) {
c1618_24[guild_id] = void 0;
r0 = true;
if (c1618_23 === guild_id) {
rebuildGuildChannels(guild_id);
}
}
}
return r0;
},
GUILD_ROLE_CREATE: handleGuildRoleUpdate,
GUILD_ROLE_UPDATE: handleGuildRoleUpdate,
GUILD_ROLE_DELETE: handleGuildRoleUpdate,
IMPERSONATE_UPDATE: handleGuildRoleUpdate,
IMPERSONATE_STOP: handleGuildRoleUpdate,
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect({ channelId: channelId2 }) {
let r14;
if (channelId2 == null && channelId != null) {
const channel2 = ChannelStore.getChannel(channelId);
channelId = null;
let r24 = channel2 == null ? void 0 : channel2.getGuildId();
if (r24 == null) {
r24 = null;
}
let r26 = r24 != null;
if (r26) {
c1618_24[r24] = void 0;
r26 = true;
if (r24 === c1618_23) {
rebuildGuildChannels(r24);
r26 = true;
}
}
r14 = r26;
} else {
const channel = ChannelStore.getChannel(channelId2);
channelId = channelId2;
let r12 = channel == null ? void 0 : channel.getGuildId();
if (r12 == null) {
r12 = null;
}
r14 = r12 != null;
if (r14) {
c1618_24[r12] = void 0;
r14 = true;
if (r12 === c1618_23) {
rebuildGuildChannels(r12);
r14 = true;
}
}
}
return r14;
},
VOICE_CHANNEL_STATUS_UPDATE: function handleVoiceChannelStatusUpdate(a0) {
const basicChannel = ChannelStore.getBasicChannel(a0.id);
if (basicChannel != null && basicChannel.guild_id != null) {
rebuildGuildChannels(basicChannel.guild_id);
}
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((acc, { channelId: channelId2, sessionId }) => {
const sessionId2 = AuthenticationStore.getSessionId();
let r12 = acc;
if (sessionId2 === sessionId) {
const channel = ChannelStore.getChannel(channelId2);
channelId = channelId2;
let r16 = channel == null ? void 0 : channel.getGuildId();
if (r16 == null) {
r16 = null;
}
let r18 = r16 != null;
if (r18) {
c1618_24[r16] = void 0;
r18 = true;
if (r16 === c1618_23) {
rebuildGuildChannels(r16);
r18 = true;
}
}
if (!r18) {
r18 = acc;
}
r12 = r18;
}
return r12;
}, false);
}
});
export default guildChannelStore;
export const GUILD_SELECTABLE_CHANNELS_KEY = "SELECTABLE";
export const GUILD_VOCAL_CHANNELS_KEY = "VOCAL";
+72
View File
@@ -0,0 +1,72 @@
// Metro module 4110 (f4111).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2368_0, c2368_1;
const handleInviteData = function handleInviteData({ invite }) {
const { guild, approximate_presence_count } = invite;
if (guild?.id != null && approximate_presence_count != null) {
c2368_1[guild.id] = approximate_presence_count;
return void 0;
}
return false;
};
c2368_0 = {};
c2368_1 = {};
class GuildMemberCountStore extends Module589.Store {
static displayName = "GuildMemberCountStore";
getMemberCounts() {
return c2368_0;
}
getMemberCount(a0) {
return a0 != null ? c2368_0[a0] : null;
}
getOnlineCount(a0) {
return a0 != null ? c2368_1[a0] : null;
}
}
const guildMemberCountStore = new GuildMemberCountStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen({ guilds }) {
c2368_0 = {};
guilds.forEach((guild) => {
c2368_0[guild.id] = guild.member_count;
});
},
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
c2368_0 = {
...a0.guildMemberCounts
};
},
GUILD_CREATE: function handleGuildCreate({ guild }) {
c2368_0[guild.id] = guild.member_count;
},
GUILD_DELETE: function handleGuildDelete({ guild }) {
if (c2368_0[guild.id] == null && c2368_1[guild.id] == null) {
return false;
}
delete c2368_0[guild.id];
delete c2368_1[guild.id];
},
GUILD_MEMBER_LIST_UPDATE: function handleGuildMemberListUpdate({ guildId, memberCount, onlineCount }) {
const r8 = c2368_0[guildId];
let r0 = false;
if (r8 !== memberCount) {
c2368_0[guildId] = memberCount;
r0 = true;
}
if (c2368_1[guildId] !== onlineCount) {
c2368_1[guildId] = onlineCount;
r0 = true;
}
return r0;
},
INVITE_ACCEPT_SUCCESS: handleInviteData,
INVITE_RESOLVE_SUCCESS: handleInviteData,
ONLINE_GUILD_MEMBER_COUNT_UPDATE: function handleOnlineCountUpdate({ guildId, count }) {
if (guildId != null && count != null) {
c2368_1[guildId] = count;
return void 0;
}
return false;
}
});
export default guildMemberCountStore;
+170
View File
@@ -0,0 +1,170 @@
// Metro module 5015 (f5016).
import ChannelStore from "./ChannelStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildMemberRequester from "../lib/guild/GuildMemberRequester";
import Dispatcher from "../Dispatcher";
import Module589 from "../_bundle/Module589";
function $mk75218($env) {
return (a0) => {
const r1 = $env;
const { author, mentions } = a0;
if (author != null) {
$env.$parent[4].request(r1[0], author.id);
}
if (mentions != null) {
mentions.forEach($mk104083(r1));
}
};
}
function $mk104083($env) {
return (a0) => {
$env.$parent[4].request($env[0], a0.id);
return false;
};
}
let c3021_4, c3021_5;
let env3021 = {};
const handleConnectionReset = function handleConnectionReset() {
c3021_4.reset();
};
const handleLoadMessages = function handleLoadMessages({ channelId, messages }) {
const channel = ChannelStore.getChannel(channelId);
let r0 = channel != null && channel.guild_id != null;
if (r0) {
let env14534;
const guild_id = channel.guild_id;
const r11 = env14534 = {
$parent: env3021
};
env14534[0] = guild_id;
messages.forEach($mk75218(r11));
r0 = false;
}
return r0;
};
const handleLoadSearchResults = function handleLoadSearchResults({ guildId, data }) {
if (guildId == null) {
return false;
}
let env14536;
const r7 = [];
let c14535_0 = r7;
data.forEach((a0) => {
a0.messages.forEach((message) => {
message.forEach((item) => {
c14535_0.push(item);
});
});
});
const r10 = env14536 = {
$parent: env3021
};
env14536[0] = guildId;
r7.forEach($mk75218(r10));
return false;
};
c3021_4 = new GuildMemberRequester(GuildMemberStore.isMember, (a0, a1) => {
Dispatcher.dispatch({
type: "GUILD_MEMBERS_REQUEST",
guildIds: [a0],
userIds: a1
});
});
class GuildMemberRequesterStore extends Module589.Store {
static displayName = "GuildMemberRequesterStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(ChannelStore, GuildMemberStore);
}
requestMember(a0, a1) {
c3021_4.request(a0, a1);
}
getDebugState(a0) {
return c3021_4.getDebugState(a0);
}
}
c3021_5 = GuildMemberRequesterStore;
const r50 = new GuildMemberRequesterStore(Dispatcher, {
CONNECTION_CLOSED: handleConnectionReset,
CONNECTION_OPEN: handleConnectionReset,
CONNECTION_RESUMED: function handleConnectionResumed() {
c3021_4.requestUnacknowledged();
return false;
},
GUILD_MEMBERS_CHUNK_BATCH: function handleGuildMembersChunkBatch({ chunks }) {
const _loop = function _loop(a0) {
a0.members.forEach((member) => {
c3021_4.acknowledge(a0.guildId, member.user.id);
});
if (a0.notFound != null) {
a0.notFound.forEach((item) => c3021_4.acknowledge(a0.guildId, item));
}
};
for (const item of chunks) {
_loop(item);
}
return false;
},
SEARCH_MESSAGES_SUCCESS: handleLoadSearchResults,
MOD_VIEW_SEARCH_MESSAGES_SUCCESS: handleLoadSearchResults,
LOCAL_MESSAGES_LOADED: handleLoadMessages,
LOAD_MESSAGES_SUCCESS: handleLoadMessages,
LOAD_MESSAGES_AROUND_SUCCESS: handleLoadMessages,
LOAD_RECENT_MENTIONS_SUCCESS: handleLoadMessages,
LOAD_PINNED_MESSAGES_SUCCESS: function handleLoadPinnedMessages(a0) {
const pins = a0.pins;
const channel = ChannelStore.getChannel(a0.channelId);
let r0 = channel != null && channel.guild_id != null;
if (r0) {
let env14537;
const guild_id = channel.guild_id;
const r14 = pins.map((pin) => pin.message);
const r15 = env14537 = {
$parent: env3021
};
env14537[0] = guild_id;
r14.forEach($mk75218(r15));
r0 = false;
}
return r0;
},
CONVERSATION_FETCH_SUCCESS: function handleConversationFetchSuccess({ channelId, messages, messageReferences }) {
const channel = ChannelStore.getChannel(channelId);
let r0 = channel != null && channel.guild_id != null;
if (r0) {
let env14538;
const guild_id = channel.guild_id;
const r13 = messages.concat(messageReferences);
const r14 = env14538 = {
$parent: env3021
};
env14538[0] = guild_id;
r13.forEach($mk75218(r14));
r0 = false;
}
return r0;
},
CONVERSATIONS_FETCH_SUCCESS: function handleConversationsFetchSuccess({ channelId, rawConversations }) {
const channel = ChannelStore.getChannel(channelId);
if (channel != null && channel.guild_id != null) {
let env14539;
const r14 = rawConversations.map(({ messages }) => {
if (messages == null) {
messages = [];
}
return messages;
}).flat();
const guild_id = channel.guild_id;
const r16 = env14539 = {
$parent: env3021
};
env14539[0] = guild_id;
r14.forEach($mk75218(r16));
return false;
}
return false;
}
});
export default r50;
File diff suppressed because it is too large. Load diff
+80
View File
@@ -0,0 +1,80 @@
// Metro module 1374 (f1375).
import Module589 from "../_bundle/Module589";
import Dispatcher, { DispatchBand } from "../Dispatcher";
import { $callWithNewTarget } from "../_hermes/prelude";
function $mk69151($env) {
return (a0) => $env[0].handleCacheLoaded(a0);
}
function $mk69152($env) {
return (a0) => $env[0].handleCacheLoadedLazy(a0);
}
function $mk69153($env) {
return (a0) => $env[0].handleConnectionOpen(a0);
}
function $mk69154($env) {
return (a0) => $env[0].handleGuildCreate(a0);
}
function $mk69155($env) {
return (a0) => $env[0].handleGuildDelete(a0);
}
let c1143_0;
let env1143;
class GuildMembershipStore extends Module589.Store {
constructor() {
let env13006;
const r2 = env13006 = {};
env13006[0] = void 0;
const r16 = {
CACHE_LOADED: $mk69151(r2),
CACHE_LOADED_LAZY: $mk69152(r2),
CONNECTION_OPEN: $mk69153(r2),
GUILD_CREATE: $mk69154(r2),
GUILD_DELETE: $mk69155(r2)
};
const Early = DispatchBand.Early;
super(Dispatcher, r16, Early);
env13006[0] = this;
this.guildIds = new Set();
}
allGuildIds() {
return this.guildIds;
}
isMember(a0) {
return this.guildIds.has(a0);
}
handleConnectionOpen(a0) {
this.guildIds = new Set([...a0.guilds.map((guild) => guild.id), ...a0.unavailableGuilds]);
}
handleCacheLoaded(a0) {
this.guildIds = new Set(a0.guilds.map((guild) => guild.id));
}
handleCacheLoadedLazy(a0) {
for (const guild of a0.guilds) {
this.guildIds.add(guild.id);
}
}
handleGuildCreate(a0) {
this.guildIds.add(a0.guild.id);
}
handleGuildDelete(a0) {
if (a0.guild.unavailable !== true) {
this.guildIds.delete(a0.guild.id);
}
}
}
const r37 = env1143 = {};
c1143_0 = void 0;
const prototypeOf = Object.getPrototypeOf(GuildMembershipStore);
const r42 = {
CACHE_LOADED: $mk69151(r37),
CACHE_LOADED_LAZY: $mk69152(r37),
CONNECTION_OPEN: $mk69153(r37),
GUILD_CREATE: $mk69154(r37),
GUILD_DELETE: $mk69155(r37)
};
const Early = DispatchBand.Early;
const r50 = Object.create(GuildMembershipStore.prototype);
const r51 = $callWithNewTarget(prototypeOf, r50, GuildMembershipStore, Dispatcher, r42, Early);
c1143_0 = r51 instanceof Object ? r51 : r50;
c1143_0.guildIds = new Set();
export default c1143_0;
+32
View File
@@ -0,0 +1,32 @@
// Metro module 4404 (f4405).
import { Storage } from "../_bundle/Module595";
import Module589 from "../_bundle/Module589";
import * as _AgeGateUtils from "../modules/age_gate/AgeGateUtils";
import Dispatcher from "../Dispatcher";
let c2634_2 = "GuildNSFWAgreeStore";
let c2634_3 = {};
class GuildNSFWAgreeStore extends Module589.Store {
static displayName = "GuildNSFWAgreeStore";
initialize() {
let r10 = Storage.get(c2634_2);
if (r10 == null) {
r10 = c2634_3;
}
c2634_3 = r10;
}
didAgree(a0) {
let r1 = a0 != null;
if (r1) {
const shouldAgeVerifyForAgeGate = _AgeGateUtils.shouldAgeVerifyForAgeGate();
r1 = shouldAgeVerifyForAgeGate ? !shouldAgeVerifyForAgeGate : c2634_3[a0] || false;
}
return r1;
}
}
const guildNSFWAgreeStore = new GuildNSFWAgreeStore(Dispatcher, {
GUILD_NSFW_AGREE: function handleGuildNSFWAgree(a0) {
c2634_3[a0.guildId] = true;
Storage.set(c2634_2, c2634_3);
}
});
export default guildNSFWAgreeStore;
+971
View File
@@ -0,0 +1,971 @@
// Metro module 5921 (f5922).
import RecentMentionsStore from "../modules/inbox/RecentMentionsStore";
import NotificationCenterItemsStore from "../modules/notification_center/NotificationCenterItemsStore";
import ActiveJoinedThreadsStore from "../modules/threads/ActiveJoinedThreadsStore";
import JoinedThreadsStore from "../modules/threads/JoinedThreadsStore";
import { isThread, isGuildVocalChannelType, getBasicAccessPermissions } from "../records/ChannelRecord";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import GuildStore from "./GuildStore";
import MobileCacheSnapshotStore from "./MobileCacheSnapshotStore";
import PermissionStore from "./PermissionStore";
import ReadStateStore from "./ReadStateStore";
import SelectedChannelStore from "./SelectedChannelStore";
import UserGuildSettingsStore from "./UserGuildSettingsStore";
import UserStore from "./UserStore";
import { NULL_STRING_GUILD_ID } from "../Constants";
import { ChannelFlags } from "../modules/channel/ChannelConstants";
import { ReadStateTypes, UnreadSetting } from "../modules/read_states/ReadStateConstants";
import * as _isOptInEnabled from "../modules/opt_in_channels/isOptInEnabled";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import * as _FavoritesUtils from "../modules/favorites/FavoritesUtils";
import Module12 from "../_bundle/Module12";
import { doesThreadMembersActionAffectMe } from "../modules/threads/ThreadActionUtils";
function $mk77356($env) {
return (a0) => {
const r3 = $env;
const r2 = $env.$parent;
const r7 = r2[14].lastMessageId(a0);
const _ackMessageId = r3[2]._ackMessageId;
if ((0, r2[1])(r2[2][18]).compare(r7, _ackMessageId) > 0) {
r3[1] = r3[1] + r3[0].mentionCounts[a0].count;
}
};
}
let isCountableChannel, updateNotificationCenterMentions, aggregateGuildState, recountChannels, updateNonChannel, recountGuild, handleOverlayInitialize, handleConnectionOpen, recomputeAllGuilds, handleGuildCreate, handleGuildDelete, handleChannelDelete, handleWindowFocus, handleGuildMemberUpdate, handleGenericUpdate, handleMessageCreate, handleChannelSelect, handleChannelUpdate, handleChannelUpdates, handleBulkAck, handleThreadUpdate, handleGuildEventUpdate, handleGuildEventDelete, handleGuildFeatureAck, handleThreadMemberUpdate, handleThreadMembersUpdate, handleThreadListSync, handlePassiveUpdateV2, handleMarkGuildAsRead, handleGuildUpdate, handleUserGuildSettingsFullUpdate, handleClearNotifCenterGuildMentions, handleUserGuildSettingsUpdate, handleRecentMentionsSuccess, c3707_60, c3707_61;
let $mk77355 = function() {
return (a0) => {
const [r22, r23] = a0;
return Number(r22) !== ReadStateTypes.GUILD_EVENT && r23;
};
};
let env3707 = {};
const updateGuildUnreadSentinel = function updateGuildUnreadSentinel(a0) {
let r8 = a0;
const r6 = env3707[22];
const r4 = a0 == null ? NULL_STRING_GUILD_ID : a0;
let r10 = env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0];
if (r10 == null) {
const r11 = env3707[22];
if (a0 == null) {
r8 = NULL_STRING_GUILD_ID;
}
let sentinel = r11[r8]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
r10 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
}
r6[r4] = r10;
r10.sentinel = r10.sentinel + 1;
env3707[24] = env3707[24] + 1;
};
isCountableChannel = function isCountableChannel(a0, r6 = 0, r2 = false) {
if (a0 == null) {
return false;
}
if (a0.isGuildVocal() && r6 === 0) {
return false;
}
if (a0.hasFlag(ChannelFlags.IS_GUILD_RESOURCE_CHANNEL)) {
return false;
}
const r1 = r6 === 0;
if (!(!r1 && !r2) && (a0.isThread() ? JoinedThreadsStore.isMuted(a0.id) || UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(a0.guild_id, a0.parent_id) : UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(a0.guild_id, a0.id))) {
return false;
}
if (!a0.isPrivate()) {
let r38 = _isOptInEnabled.isOptInEnabledForGuild(a0.guild_id);
let r40 = a0.guild_id != null;
if (r40) {
if (r38) {
r38 = !((0, isThread)(a0.type) || UserGuildSettingsStore.isChannelRecordOrParentOptedIn(a0));
}
if (r38) {
r38 = r1;
}
r40 = r38;
}
if (r40) {
return false;
}
if (!PermissionStore.can(a0.accessPermissions, a0)) {
return false;
}
}
return r6 > 0 || UserGuildSettingsStore.resolveUnreadSetting(a0) === UnreadSetting.ALL_MESSAGES;
};
updateNotificationCenterMentions = function updateNotificationCenterMentions(a0, a1) {
if (!NotificationCenterItemsStore.tabFocused) {
let env15263;
const r16 = env15263 = {
$parent: env3707
};
env15263[0] = a0;
env15263[1] = 0;
const currentUser = UserStore.getCurrentUser();
const r17 = currentUser == null ? void 0 : ReadStateStore.getNotifCenterReadState(currentUser.id);
env15263[2] = r17;
if (r17 != null) {
SnowflakeUtils.keys(a0.mentionCounts).forEach($mk77356(r16));
}
let env15264;
const r30 = env15263[1];
const r31 = env15264 = {
$parent: env3707
};
env15264[0] = a1;
env15264[1] = 0;
const currentUser2 = UserStore.getCurrentUser();
const r35 = currentUser2 == null ? void 0 : ReadStateStore.getNotifCenterReadState(currentUser2.id);
env15264[2] = r35;
if (!(a1 == null || r35 == null)) {
SnowflakeUtils.keys(a1.mentionCounts).forEach($mk77356(r31));
}
const r49 = env15264[1];
const r51 = Math;
let r54 = a1?.ncMentionCount;
if (r54 == null) {
r54 = 0;
}
a0.ncMentionCount = r51.max(r54 + (r30 - r49), 0);
}
};
aggregateGuildState = function aggregateGuildState(a0, a1, a2) {
a1.unread = Object.entries(a1.unreadByType).some($mk77355());
a1.lowImportanceMentionCount = 0;
a1.highImportanceMentionCount = 0;
SnowflakeUtils.forEach(a1.mentionCounts, ({ count, isMentionLowImportance }) => {
if (isMentionLowImportance) {
a1.lowImportanceMentionCount = a1.lowImportanceMentionCount + count;
} else {
a1.highImportanceMentionCount = a1.highImportanceMentionCount + count;
}
});
let r27 = a1.unread !== a2.unread || a1.lowImportanceMentionCount !== a2.lowImportanceMentionCount || a1.highImportanceMentionCount !== a2.highImportanceMentionCount;
if (r27) {
let r32 = a0;
env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0] = a1;
if (a0 != null) {
const unread = a1.unread;
const r36 = env3707[23];
if (unread) {
r36.add(a0);
} else {
r36.delete(a0);
}
}
env3707[24] = env3707[24] + 1;
if (a0 == null) {
r32 = NULL_STRING_GUILD_ID;
}
updateGuildUnreadSentinel(r32);
updateNotificationCenterMentions(a1, a2);
r27 = true;
}
return r27;
};
recountChannels = function recountChannels(a0, a1) {
const r6 = NULL_STRING_GUILD_ID !== a0 && (a0 !== null && a0 !== void 0) ? a0 : null;
let c15266_1, c15266_2;
let c15266_0 = r6;
const r7 = env3707[22];
const r4 = r6 == null ? NULL_STRING_GUILD_ID : r6;
let r18 = env3707[22][r6 == null ? NULL_STRING_GUILD_ID : r6];
if (r18 == null) {
let sentinel = env3707[22][r6 == null ? NULL_STRING_GUILD_ID : r6]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
r18 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
}
r7[r4] = r18;
const r24 = env3707[22];
let r25 = r6;
if (r25 == null) {
r25 = NULL_STRING_GUILD_ID;
}
const r26 = r24[r25];
const r28 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel: null
};
let sentinel2 = r26?.sentinel;
if (sentinel2 == null) {
sentinel2 = 0;
}
L32: {
r28.sentinel = sentinel2;
r28.mentionCounts = {
...r18.mentionCounts
};
r28.unreadByType = {
...r18.unreadByType
};
c15266_1 = r28;
c15266_2 = false;
a1.forEach((item) => {
L15: {
const channel = ChannelStore.getChannel(item);
if (channel != null) {
const guildId = channel.getGuildId();
if (guildId === c15266_0) {
const mentionCount = ReadStateStore.getMentionCount(item);
if (c15266_0 !== null && !c15266_2 && ReadStateStore.hasUnread(channel.id) && isCountableChannel(channel, mentionCount, true)) {
c15266_2 = true;
c15266_1.unreadChannelId = channel.id;
}
if (mentionCount > 0 && isCountableChannel(channel, mentionCount)) {
c15266_1.mentionCounts[channel.id] = {
count: mentionCount,
isMentionLowImportance: ReadStateStore.getIsMentionLowImportance(item)
};
break L15;
}
delete c15266_1.mentionCounts[channel.id];
}
} else {
delete c15266_1.mentionCounts[item];
}
}
});
r28.unreadByType[ReadStateTypes.CHANNEL] = c15266_2;
if (r28.unreadByType[ReadStateTypes.CHANNEL] !== r18.unreadByType[ReadStateTypes.CHANNEL] && !r28.unreadByType[ReadStateTypes.CHANNEL]) {
const channel = ChannelStore.getChannel(r18.unreadChannelId);
if (channel != null && !a1.includes(channel.id) && ReadStateStore.hasUnread(channel.id) && isCountableChannel(channel)) {
if (r6 != null) {
env3707[23].add(r6);
}
r28.unreadByType[ReadStateTypes.CHANNEL] = true;
break L32;
}
return recountGuild(r6);
}
}
return aggregateGuildState(r6, r28, r18);
};
updateNonChannel = function updateNonChannel(a0, a1) {
if (a0 != null) {
const r7 = env3707[22];
const r4 = a0 == null ? NULL_STRING_GUILD_ID : a0;
let r17 = env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0];
if (r17 == null) {
let sentinel = env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
r17 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
}
r7[r4] = r17;
let sentinel2 = env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0]?.sentinel;
if (sentinel2 == null) {
sentinel2 = 0;
}
const r28 = {
unread: false,
unreadByType: {
...r17.unreadByType
},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {
...r17.mentionCounts
},
ncMentionCount: 0,
sentinel: sentinel2
};
const unreadByType = r28.unreadByType;
const GUILD_EVENT = ReadStateTypes.GUILD_EVENT;
const hasUnread2 = ReadStateStore.hasUnread(a0, a1);
const GUILD_EVENT2 = ReadStateTypes.GUILD_EVENT;
let r44 = hasUnread2;
if (a1 === GUILD_EVENT2) {
const isMuted = UserGuildSettingsStore.isMuted(a0);
let r47 = !isMuted;
if (!isMuted) {
const isMuteScheduledEventsEnabled = UserGuildSettingsStore.isMuteScheduledEventsEnabled(a0);
r47 = isMuteScheduledEventsEnabled ? !isMuteScheduledEventsEnabled : hasUnread2;
}
r44 = r47;
}
unreadByType[GUILD_EVENT] = r44;
return aggregateGuildState(a0, r28, r17);
}
};
recountGuild = function recountGuild(a0, a1) {
let r19 = NULL_STRING_GUILD_ID !== a0 && (a0 !== null && a0 !== void 0) ? a0 : null;
let sentinel = env3707[22][r19 == null ? NULL_STRING_GUILD_ID : r19]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
const r48 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
if (r19 == null) {
const mutablePrivateChannels = ChannelStore.getMutablePrivateChannels();
for (const key4 in mutablePrivateChannels) {
const r178 = key4;
const r179 = mutablePrivateChannels[r178];
const mentionCount3 = ReadStateStore.getMentionCount(r178);
if (mentionCount3 > 0 && isCountableChannel(r179, mentionCount3)) {
r48.highImportanceMentionCount = r48.highImportanceMentionCount + mentionCount3;
r48.mentionCounts[r179.id] = {
count: mentionCount3,
isMentionLowImportance: false
};
}
}
} else {
const isMuted = UserGuildSettingsStore.isMuted(r19);
if (isMuted && a1 === false) {
return false;
}
const mutedChannels = UserGuildSettingsStore.getMutedChannels(r19);
const channelOverrides = UserGuildSettingsStore.getChannelOverrides(r19);
const isOptInEnabledForGuild = _isOptInEnabled.isOptInEnabledForGuild(r19);
const mutableBasicGuildChannelsForGuild = ChannelStore.getMutableBasicGuildChannelsForGuild(r19);
for (const key in mutableBasicGuildChannelsForGuild) {
const r28 = mutableBasicGuildChannelsForGuild[key];
const r33 = (isMuted ? isMuted : mutedChannels.has(key)) || r28.parent_id != null && mutedChannels.has(r28.parent_id);
const r36 = r48.unreadByType[ReadStateTypes.CHANNEL];
const guildChannelUnreadState = ReadStateStore.getGuildChannelUnreadState(r28, isOptInEnabledForGuild, channelOverrides, r33, r36);
const { mentionCount, unread, isMentionLowImportance } = guildChannelUnreadState;
const r13 = mentionCount > 0;
if (!r13 && r33) {
continue;
}
const r77 = (r36 ? !r36 : r33 ? r13 : !r33) && unread;
if (!r77 && !r13) {
continue;
}
const r80 = (0, isGuildVocalChannelType)(r28.type);
let r81 = r80 ? mentionCount !== 0 : !r80;
if (r81) {
let r87 = !!PermissionStore.canBasicChannel((0, getBasicAccessPermissions)(r28.type), r28);
if (r87) {
const r89 = r28.guild_id != null && (isOptInEnabledForGuild && !((0, isThread)(r28.type) || UserGuildSettingsStore.isChannelRecordOrParentOptedIn(r28)) && mentionCount === 0);
let r10 = !r89;
if (!r89) {
const r8 = "flags" in r28;
r10 = (r8 ? !r28.hasFlag(ChannelFlags.IS_GUILD_RESOURCE_CHANNEL) : !r8) && (mentionCount > 0 || UserGuildSettingsStore.resolveUnreadSetting(r28) === UnreadSetting.ALL_MESSAGES);
}
r87 = r10;
}
r81 = r87;
}
if (r81) {
if (r77) {
r48.unreadByType[ReadStateTypes.CHANNEL] = true;
r48.unreadChannelId = key;
}
if (r13) {
if (isMentionLowImportance) {
r48.lowImportanceMentionCount = r48.lowImportanceMentionCount + mentionCount;
} else {
r48.highImportanceMentionCount = r48.highImportanceMentionCount + mentionCount;
}
r48.mentionCounts[r28.id] = {
count: mentionCount,
isMentionLowImportance
};
}
}
}
const activeJoinedThreadsForGuild = ActiveJoinedThreadsStore.getActiveJoinedThreadsForGuild(r19);
for (const key2 in activeJoinedThreadsForGuild) {
const r121 = activeJoinedThreadsForGuild[key2];
for (const key3 in r121) {
if (!(r48.unreadByType[ReadStateTypes.CHANNEL] || !ReadStateStore.hasUnread(key3) || JoinedThreadsStore.isMuted(key3) || isMuted)) {
r48.unreadByType[ReadStateTypes.CHANNEL] = true;
r48.unreadChannelId = key3;
}
const mentionCount2 = ReadStateStore.getMentionCount(key3);
const isMentionLowImportance2 = ReadStateStore.getIsMentionLowImportance(key3);
if (mentionCount2 > 0) {
if (isMentionLowImportance2) {
r48.lowImportanceMentionCount = r48.lowImportanceMentionCount + mentionCount2;
} else {
r48.highImportanceMentionCount = r48.highImportanceMentionCount + mentionCount2;
}
r48.mentionCounts[key3] = {
count: mentionCount2,
isMentionLowImportance: isMentionLowImportance2
};
}
}
}
const r152 = r48.unreadByType[ReadStateTypes.GUILD_EVENT];
let r153 = !r152;
if (!r152) {
const GUILD_EVENT = ReadStateTypes.GUILD_EVENT;
const hasUnread2 = ReadStateStore.hasUnread(r19, GUILD_EVENT);
const GUILD_EVENT2 = ReadStateTypes.GUILD_EVENT;
let r159 = hasUnread2;
if (GUILD_EVENT === GUILD_EVENT2) {
const isMuted2 = UserGuildSettingsStore.isMuted(r19);
let r163 = !isMuted2;
if (!isMuted2) {
const isMuteScheduledEventsEnabled = UserGuildSettingsStore.isMuteScheduledEventsEnabled(r19);
r163 = isMuteScheduledEventsEnabled ? !isMuteScheduledEventsEnabled : hasUnread2;
}
r159 = r163;
}
r153 = r159;
}
if (r153) {
r48.unreadByType[ReadStateTypes.GUILD_EVENT] = true;
}
}
r48.unread = Object.entries(r48.unreadByType).some($mk77355());
const r198 = env3707[22];
const r199 = r19 == null ? NULL_STRING_GUILD_ID : r19;
let r202 = env3707[22][r19 == null ? NULL_STRING_GUILD_ID : r19];
if (r202 == null) {
let sentinel2 = env3707[22][r19 == null ? NULL_STRING_GUILD_ID : r19]?.sentinel;
if (sentinel2 == null) {
sentinel2 = 0;
}
r202 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel: sentinel2
};
}
r198[r199] = r202;
let r213 = r48.unread !== r202.unread || r48.highImportanceMentionCount !== r202.highImportanceMentionCount || r48.lowImportanceMentionCount !== r202.lowImportanceMentionCount;
if (r213) {
env3707[22][r19 == null ? NULL_STRING_GUILD_ID : r19] = r48;
if (r19 != null) {
const unread2 = r48.unread;
const r221 = env3707[23];
if (unread2) {
r221.add(r19);
} else {
r221.delete(r19);
}
}
env3707[24] = env3707[24] + 1;
if (r19 == null) {
r19 = NULL_STRING_GUILD_ID;
}
updateGuildUnreadSentinel(r19);
updateNotificationCenterMentions(r48, r202);
r213 = true;
}
return r213;
};
handleOverlayInitialize = function handleOverlayInitialize({ guilds }) {
env3707[22] = {};
env3707[24] = 0;
env3707[23] = new Set();
recountGuild(null);
const length = guilds.length;
const r20 = 0 < length;
let r0 = 0;
if (r20) {
do {
const r21 = guilds[r0];
const r1 = r0;
if (r21 != null) {
recountGuild(r21.properties.id);
}
r0 = r1 + 1;
} while (r0 < length);
}
};
handleConnectionOpen = function handleConnectionOpen({ guilds, readState }) {
env3707[22] = {};
env3707[24] = 0;
env3707[23] = new Set();
const r32 = readState.entries.length < 500;
const set = new Set();
let c15267_0 = set;
if (r32) {
readState.entries.forEach((entry) => {
const r1 = entry.mention_count != null && entry.mention_count > 0;
L9: {
if (r1) {
if (entry.read_state_type != null && entry.read_state_type !== ReadStateTypes.CHANNEL) {
c15267_0.add(entry.id);
break L9;
}
c15267_0.add(ChannelStore.getChannel(entry.id)?.guild_id);
}
}
});
}
recountGuild(null);
for (const item of guilds) {
recountGuild(item.id, r32 ? set.has(item.id) : void 0);
}
};
recomputeAllGuilds = function recomputeAllGuilds() {
env3707[22] = {};
env3707[23] = new Set();
recountGuild(null);
for (const item of Object.values(GuildStore.getGuildIds())) {
recountGuild(item);
}
};
handleGuildCreate = function handleGuildCreate(a0) {
return recountGuild(a0.guild.id);
};
handleGuildDelete = function handleGuildDelete({ guild }) {
let r9 = env3707[22][guild.id] != null;
if (r9) {
delete env3707[22][guild.id];
env3707[23].delete(guild.id);
env3707[24] = env3707[24] + 1;
r9 = true;
}
return r9;
};
handleChannelDelete = function handleChannelDelete({ channel }) {
return recountChannels(channel.guild_id, [channel.id]);
};
handleWindowFocus = function handleWindowFocus() {
const channel = ChannelStore.getChannel(SelectedChannelStore.getChannelId());
return channel != null && recountChannels(channel.getGuildId(), [channel.id]);
};
handleGuildMemberUpdate = function handleGuildMemberUpdate({ user, guildId }) {
return user.id === AuthenticationStore.getId() && recountGuild(guildId);
};
handleGenericUpdate = function handleGenericUpdate(a0) {
const channel = ChannelStore.getChannel(a0.channelId);
return channel != null && recountChannels(channel.getGuildId(), [channel.id]);
};
handleMessageCreate = function handleMessageCreate({ channelId }) {
let r28;
const channel = ChannelStore.getChannel(channelId);
if (channel == null) {
return false;
}
L22: {
if (channel.guild_id != null) {
let guild_id = channel.guild_id;
const r8 = env3707[22];
const r6 = guild_id == null ? NULL_STRING_GUILD_ID : guild_id;
let r16 = env3707[22][guild_id == null ? NULL_STRING_GUILD_ID : guild_id];
if (r16 == null) {
const r17 = env3707[22];
if (guild_id == null) {
guild_id = NULL_STRING_GUILD_ID;
}
let sentinel = r17[guild_id]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
r16 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
}
r8[r6] = r16;
if (channel.isThread()) {
const hasJoined = JoinedThreadsStore.hasJoined(channel.id);
r28 = hasJoined ? JoinedThreadsStore.isMuted(channel.id) : !hasJoined;
} else {
r28 = UserGuildSettingsStore.isGuildOrCategoryOrChannelMuted(channel.guild_id, channel.id);
}
if (!r28 && !r16.unreadByType[ReadStateTypes.CHANNEL]) {
break L22;
}
if (ReadStateStore.getMentionCount(channelId) === 0) {
return false;
}
}
}
return recountChannels(channel.getGuildId(), [channel.id]);
};
handleChannelSelect = function handleChannelSelect({ channelId, guildId }) {
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(guildId);
return isFavoritesGuildId ? !isFavoritesGuildId : channelId != null && recountChannels(guildId, [channelId]);
};
handleChannelUpdate = function handleChannelUpdate({ channel }) {
return recountChannels(channel.getGuildId(), [channel.id]);
};
handleChannelUpdates = function handleChannelUpdates(a0) {
return Module12(a0.channels).groupBy((item) => item.getGuildId()).reduce((acc, a1, index) => recountChannels(index, a1.map((item) => item.id)) || acc, false);
};
handleBulkAck = function handleBulkAck(a0) {
return Module12(a0.channels).map((item) => item.channelId).filter((item) => ChannelStore.getChannel(item) != null).groupBy((item) => {
const channel = ChannelStore.getChannel(item);
return channel == null ? void 0 : channel.getGuildId();
}).reduce((acc, item, index) => recountChannels(index, item) || acc, false);
};
handleThreadUpdate = function handleThreadUpdate({ channel }) {
return recountChannels(channel.getGuildId(), [channel.id, channel.parent_id]);
};
handleGuildEventUpdate = function handleGuildEventUpdate(a0) {
return updateNonChannel(a0.guildScheduledEvent.guild_id, ReadStateTypes.GUILD_EVENT);
};
handleGuildEventDelete = function handleGuildEventDelete(a0) {
return updateNonChannel(a0.guildScheduledEvent.guild_id, ReadStateTypes.GUILD_EVENT);
};
handleGuildFeatureAck = function handleGuildFeatureAck(a0) {
return updateNonChannel(a0.id, a0.ackType);
};
handleThreadMemberUpdate = function handleThreadMemberUpdate(a0) {
return recountChannels(a0.guildId, [a0.id]);
};
handleThreadMembersUpdate = function handleThreadMembersUpdate(a0) {
return doesThreadMembersActionAffectMe(a0) && recountChannels(a0.guildId, [a0.id]);
};
handleThreadListSync = function handleThreadListSync(a0) {
return recountChannels(a0.guildId, a0.threads.filter((thread) => JoinedThreadsStore.hasJoined(thread.id)).map((item) => item.id));
};
handlePassiveUpdateV2 = function handlePassiveUpdateV2(a0) {
return a0.channels.length > 0 && recountChannels(a0.guildId, a0.channels.map((channel) => channel.id));
};
handleMarkGuildAsRead = function handleMarkGuildAsRead(a0) {
return recountGuild(a0.guildId);
};
handleGuildUpdate = function handleGuildUpdate(a0) {
return recountGuild(a0.guildId);
};
handleUserGuildSettingsFullUpdate = function handleUserGuildSettingsFullUpdate({ userGuildSettings }) {
let c15268_0 = new Set(userGuildSettings.map(({ guild_id }) => {
if (guild_id == null) {
guild_id = NULL_STRING_GUILD_ID;
}
return guild_id;
}));
return SnowflakeUtils.keys(env3707[22]).reduce((acc, item) => c15268_0.has(item) && recountGuild(item) || acc, false);
};
handleClearNotifCenterGuildMentions = function handleClearNotifCenterGuildMentions() {
const r5 = env3707[22];
for (const key in r5) {
env3707[22][key].ncMentionCount = 0;
}
};
handleUserGuildSettingsUpdate = function handleUserGuildSettingsUpdate(a0) {
return recountGuild(a0.guildId);
};
handleRecentMentionsSuccess = function handleRecentMentionsSuccess(a0) {
new Set(a0.messages.map((message) => message.channel_id)).forEach((item) => {
const channel = ChannelStore.getChannel(item);
if (channel != null) {
recountChannels(channel.getGuildId(), [item]);
}
});
};
env3707[22] = {};
env3707[23] = new Set();
env3707[24] = 0;
c3707_60 = void 0;
class GuildReadStateStore extends MobileCacheSnapshotStore {
static displayName = "GuildReadStateStore";
static LATEST_SNAPSHOT_VERSION = 1;
constructor() {
const r10 = {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleOverlayInitialize,
CACHE_LOADED_LAZY: () => this.loadCache(),
GUILD_CREATE: handleGuildCreate,
GUILD_DELETE: handleGuildDelete,
MESSAGE_CREATE: handleMessageCreate,
MESSAGE_ACK: handleGenericUpdate,
BULK_ACK: handleBulkAck,
UPDATE_CHANNEL_DIMENSIONS: handleGenericUpdate,
CHANNEL_SELECT: handleChannelSelect,
CHANNEL_DELETE: handleChannelDelete,
WINDOW_FOCUS: handleWindowFocus,
GUILD_ACK: handleMarkGuildAsRead,
GUILD_ROLE_CREATE: handleGuildUpdate,
GUILD_ROLE_DELETE: handleGuildUpdate,
GUILD_ROLE_UPDATE: handleGuildUpdate,
CHANNEL_CREATE: handleChannelUpdate,
CHANNEL_UPDATES: handleChannelUpdates,
THREAD_CREATE: handleThreadUpdate,
THREAD_UPDATE: handleThreadUpdate,
THREAD_DELETE: handleThreadUpdate,
THREAD_LIST_SYNC: handleThreadListSync,
THREAD_MEMBER_UPDATE: handleThreadMemberUpdate,
THREAD_MEMBERS_UPDATE: handleThreadMembersUpdate,
PASSIVE_UPDATE_V2: handlePassiveUpdateV2,
GUILD_MEMBER_UPDATE: handleGuildMemberUpdate,
USER_GUILD_SETTINGS_FULL_UPDATE: handleUserGuildSettingsFullUpdate,
USER_GUILD_SETTINGS_CHANNEL_UPDATE: handleUserGuildSettingsUpdate,
USER_GUILD_SETTINGS_CHANNEL_UPDATE_BULK: handleUserGuildSettingsUpdate,
USER_GUILD_SETTINGS_GUILD_UPDATE: handleUserGuildSettingsUpdate,
USER_GUILD_SETTINGS_GUILD_AND_CHANNELS_UPDATE: handleUserGuildSettingsUpdate,
GUILD_FEATURE_ACK: handleGuildFeatureAck,
GUILD_SCHEDULED_EVENT_CREATE: handleGuildEventUpdate,
GUILD_SCHEDULED_EVENT_UPDATE: handleGuildEventUpdate,
GUILD_SCHEDULED_EVENT_DELETE: handleGuildEventDelete,
CHANNEL_RTC_UPDATE_CHAT_OPEN: handleGenericUpdate,
LOAD_MESSAGES_SUCCESS: handleGenericUpdate,
CHANNEL_ACK: handleGenericUpdate,
CHANNEL_LOCAL_ACK: handleGenericUpdate,
NOTIFICATION_SETTINGS_UPDATE: recomputeAllGuilds,
RECOMPUTE_READ_STATES: recomputeAllGuilds,
VOICE_CHANNEL_SELECT: handleGenericUpdate,
ENABLE_AUTOMATIC_ACK: handleGenericUpdate,
RESORT_THREADS: handleGenericUpdate,
NOTIFICATION_CENTER_CLEAR_GUILD_MENTIONS: handleClearNotifCenterGuildMentions,
TRY_ACK: handleGenericUpdate,
LOAD_RECENT_MENTIONS_SUCCESS: handleRecentMentionsSuccess
};
super(r10);
}
initialize() {
this.waitFor(ChannelStore, SelectedChannelStore, ReadStateStore, PermissionStore, AuthenticationStore, UserStore, UserGuildSettingsStore, ActiveJoinedThreadsStore, JoinedThreadsStore, RecentMentionsStore);
}
loadCache() {
const r8 = this.readSnapshot(c3707_60.LATEST_SNAPSHOT_VERSION);
if (r8 != null) {
env3707[22] = r8.guilds;
env3707[23] = new Set(r8.unreadGuilds);
}
}
takeSnapshot() {
return {
version: c3707_60.LATEST_SNAPSHOT_VERSION,
data: {
guilds: env3707[22],
unreadGuilds: Array.from(env3707[23])
}
};
}
hasAnyUnread() {
return env3707[23].size > 0;
}
getStoreChangeSentinel() {
return env3707[24];
}
getMutableUnreadGuilds() {
return env3707[23];
}
getMutableGuildStates() {
return env3707[22];
}
shouldCountChannelUnread(a0, r4 = 0) {
return isCountableChannel(a0, r4, true);
}
hasUnread(a0) {
return env3707[23].has(a0);
}
getMentionCount(a0) {
let r7 = a0;
const r5 = env3707[22];
const r4 = a0 == null ? NULL_STRING_GUILD_ID : a0;
let r9 = env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0];
if (r9 == null) {
const r10 = env3707[22];
if (a0 == null) {
r7 = NULL_STRING_GUILD_ID;
}
let sentinel = r10[r7]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
r9 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
}
r5[r4] = r9;
return r9.highImportanceMentionCount + r9.lowImportanceMentionCount;
}
getIsMentionLowImportance(a0) {
let r7 = a0;
const r5 = env3707[22];
const r4 = a0 == null ? NULL_STRING_GUILD_ID : a0;
let r9 = env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0];
if (r9 == null) {
const r10 = env3707[22];
if (a0 == null) {
r7 = NULL_STRING_GUILD_ID;
}
let sentinel = r10[r7]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
r9 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
}
r5[r4] = r9;
return r9.highImportanceMentionCount === 0;
}
getGuildHasUnreadIgnoreMuted(a0) {
const mutableGuildChannelsForGuild = ChannelStore.getMutableGuildChannelsForGuild(a0);
for (const key in mutableGuildChannelsForGuild) {
const r16 = mutableGuildChannelsForGuild[key];
if (r16 != null) {
if (r16.isGuildVocal() && ReadStateStore.getMentionCount(key) === 0) {
continue;
}
if (PermissionStore.can(r16.accessPermissions, r16) && ReadStateStore.hasUnreadOrMentions(key)) {
return true;
}
}
}
const activeJoinedThreadsForGuild = ActiveJoinedThreadsStore.getActiveJoinedThreadsForGuild(a0);
for (const key2 in activeJoinedThreadsForGuild) {
if (ChannelStore.getChannel(key2) != null) {
const r40 = activeJoinedThreadsForGuild[key2];
for (const key3 in r40) {
if (ReadStateStore.hasUnreadOrMentions(key3)) {
return true;
}
}
}
}
return !!ReadStateStore.hasUnreadOrMentions(a0, ReadStateTypes.GUILD_EVENT);
}
getTotalMentionCount(a0) {
let r13;
const r9 = env3707[22];
let r7 = 0;
const r16 = a0 === true;
let r17 = 0;
for (const key in r9) {
r13 = r7;
r17 = r13;
const r18 = env3707[22][key];
r7 = r16 && key === NULL_STRING_GUILD_ID ? r13 : r13 + r18.highImportanceMentionCount;
}
r13 = r7;
r17 = r13;
return r17;
}
getTotalNotificationsMentionCount(a0) {
let r13;
const r9 = env3707[22];
let r7 = 0;
const r16 = a0 === true;
let r17 = 0;
for (const key in r9) {
r13 = r7;
r17 = r13;
const r18 = env3707[22][key];
r7 = r16 && key === NULL_STRING_GUILD_ID ? r13 : r13 + r18.ncMentionCount;
}
r13 = r7;
r17 = r13;
return r17;
}
getPrivateChannelMentionCount() {
let r7 = env3707[22][NULL_STRING_GUILD_ID]?.highImportanceMentionCount;
if (r7 == null) {
r7 = 0;
}
return r7;
}
getMentionCountForPrivateChannel(a0) {
const r7 = env3707[22][NULL_STRING_GUILD_ID];
let r8 = r7 == null ? void 0 : r7.mentionCounts[a0];
if (r8 == null) {
r8 = 0;
}
return r8;
}
getHighImportanceMentionCountForChannel(a0, a1) {
let r4 = a0;
const r3 = env3707[22];
if (a0 == null) {
r4 = NULL_STRING_GUILD_ID;
}
const r6 = r3[r4];
const r7 = r6 == null ? void 0 : r6.mentionCounts[a1];
return r7 == null ? 0 : r7.isMentionLowImportance ? 0 : r7.count;
}
getGuildChangeSentinel(a0) {
let r7 = a0;
const r5 = env3707[22];
const r4 = a0 == null ? NULL_STRING_GUILD_ID : a0;
let r9 = env3707[22][a0 == null ? NULL_STRING_GUILD_ID : a0];
if (r9 == null) {
const r10 = env3707[22];
if (a0 == null) {
r7 = NULL_STRING_GUILD_ID;
}
let sentinel = r10[r7]?.sentinel;
if (sentinel == null) {
sentinel = 0;
}
r9 = {
unread: false,
unreadByType: {},
unreadChannelId: null,
lowImportanceMentionCount: 0,
highImportanceMentionCount: 0,
mentionCounts: {},
ncMentionCount: 0,
sentinel
};
}
r5[r4] = r9;
return r9.sentinel;
}
}
c3707_60 = GuildReadStateStore;
c3707_61 = GuildReadStateStore;
const r140 = new GuildReadStateStore();
export default r140;
+173
View File
@@ -0,0 +1,173 @@
// Metro module 1935 (f1936).
import { constructInPlace } from "../lib/PlainRecord";
import { LibdiscoreStore } from "../modules/libdiscore/stores/LibdiscoreStore";
import { getGuildEveryoneRoleId } from "../records/GuildRecord";
import { GuildRoleRecordTypeTag } from "../records/GuildRoleRecord";
import { deserialize } from "../_bundle/HighLow";
import { fromSyncOperation, toSerializedPartition, fromServerArray, fromSerializedPartition, fromServer } from "../utils/GuildRoleRecordUtils";
import { sortGuildRoleRecords, filterRoleDeletes } from "../utils/GuildRoleUtils";
import { LibdiscoreBatchStoreRefactorExperiment } from "../modules/libdiscore/libdiscoreExperiments";
let syncRoles, checkGuildRolesExist;
const createGuildRoleRecordFromRust = function createGuildRoleRecordFromRust(a0) {
return constructInPlace(GuildRoleRecordTypeTag, {
...a0,
permissions: deserialize(a0.permissions)
});
};
syncRoles = function syncRoles(id, roles, a2) {
if (!(roles.op === "update" && roles.writes.length === 0 && roles.deletes.length === 0)) {
a2.setPartition(id, fromSyncOperation(id, roles, a2.getPartition(id)));
}
};
checkGuildRolesExist = function checkGuildRolesExist(a0, id, a2) {
if (a2.partitionLength(id) === 0) {
throw new Error(`Guild data was missing from store for guild ${id}: missing roles. (phase: ${a0})`);
}
};
class GuildRoleStore extends LibdiscoreStore {
static displayName = "GuildRoleStore";
database = this.addKKVDatabase("guild_roles", createGuildRoleRecordFromRust);
getSortedRoles = this.database.memoizedPartition((a0, a1) => sortGuildRoleRecords(Object.values(a1)));
getRolesSnapshot = this.database.memoizedPartition((a0, a1) => ({
...a1
}));
stateWrapper() {
return this.database;
}
serializeAllGuildRoles() {
return this.database.mapPartitions(toSerializedPartition);
}
getUnsafeMutableRoles(a0) {
return this.database.getPartition(a0);
}
getManyRoles(a0, a1) {
return this.database.getManyRecords(a0, a1);
}
getRole(a0, a1) {
return this.database.getRecord(a0, a1);
}
getNumRoles(a0) {
return this.database.partitionLength(a0);
}
getEveryoneRole(a0) {
const record = this.database.getRecord(a0.id, getGuildEveryoneRoleId(a0));
if (record == null) {
throw new Error("Guild does not have an @everyone role");
}
return record;
}
partitionVersion(a0) {
return this.database.partitionVersion(a0);
}
}
const guildRoleStore = new GuildRoleStore({
BACKGROUND_SYNC: (a0, a1) => {
let r53;
for (const guild of a0.guilds) {
const nullablePartition = a1.getNullablePartition(guild.id);
if (nullablePartition != null && guild.data_mode !== "unavailable") {
const setPartition = a1.setPartition;
const id = guild.id;
if (guild.data_mode === "partial") {
r53 = filterRoleDeletes(guild.id, nullablePartition, guild.partial_updates.roles, guild.partial_updates.deleted_role_ids);
} else {
r53 = fromServerArray(guild.id, guild.roles);
}
setPartition.call(a1, id, r53);
}
}
},
OVERLAY_INITIALIZE: (a0, a1) => {
a1.clear();
for (const serializedGuildRole of a0.serializedGuildRoles) {
const partitionKey = serializedGuildRole.partitionKey;
a1.setPartition(partitionKey, fromSerializedPartition(partitionKey, serializedGuildRole.values));
}
},
LOGOUT: (a0, a1) => {
a1.clear();
},
RESET_SOCKET: (a0, a1) => {
a1.clear();
},
CONNECTION_OPEN: ({ guilds, unavailableGuilds }, a1) => {
let r22;
const set = new Set(guilds.map((guild) => guild.id));
let r31 = unavailableGuilds[Symbol.iterator]();
const next = r31.next;
while (true) {
const r8 = r31 === void 0 ? void 0 : (r22 = next.call(r31)).done ? r31 = void 0 : r22.value;
if (r31 === void 0) {
for (const item of a1.getPartitionKeys()) {
if (!set.has(item)) {
a1.removePartition(item);
}
}
for (const item2 of guilds) {
const id = item2.id;
syncRoles(id, item2.roles, a1);
checkGuildRolesExist("connection_open", id, a1);
}
return void 0;
} else {
try {
set.add(r8);
} catch (r37) {
if (r31 !== void 0 && typeof r31.return === "function") {
try {
r31.return();
} catch {}
}
throw r37;
}
}
}
},
CACHE_LOADED: ({ guilds }, a1) => {
a1.clear();
for (const item of guilds) {
const id = item.id;
a1.setPartition(id, fromSerializedPartition(id, item.roles));
checkGuildRolesExist("cache_loaded", id, a1);
}
},
CACHE_LOADED_LAZY: (a0, a1) => {
if (a0.guilds.length !== 0) {
a1.clear();
for (const guild of a0.guilds) {
const id = guild.id;
a1.setPartition(id, fromSerializedPartition(id, guild.roles));
checkGuildRolesExist("cache_loaded_lazy", id, a1);
}
}
},
GUILD_CREATE: ({ guild }, a1) => {
const { id, roles } = guild;
if (!(roles.op === "update" && roles.writes.length === 0 && roles.deletes.length === 0)) {
a1.setPartition(id, fromSyncOperation(id, roles, a1.getPartition(id)));
}
if (a1.partitionLength(id) === 0) {
throw new Error(`Guild data was missing from store for guild ${id}: missing roles. (phase: guild_create)`);
}
},
GUILD_UPDATE: ({ guild }, a1) => {
const id = guild.id;
a1.setPartition(id, fromServerArray(id, guild.roles));
},
GUILD_DELETE: ({ guild }, a1) => {
const id = guild.id;
if (!guild.unavailable) {
a1.removePartition(id);
}
},
GUILD_ROLE_CREATE: (a0, a1) => {
a1.setRecord(a0.guildId, a0.role.id, fromServer(a0.guildId, a0.role));
},
GUILD_ROLE_UPDATE: (a0, a1) => {
a1.setRecord(a0.guildId, a0.role.id, fromServer(a0.guildId, a0.role));
},
GUILD_ROLE_DELETE: (a0, a1) => {
a1.removeRecord(a0.guildId, a0.roleId);
}
}, LibdiscoreBatchStoreRefactorExperiment.getCachedBridgedStoreMode());
export default guildRoleStore;
+164
View File
@@ -0,0 +1,164 @@
// Metro module 1862 (f1863).
import { constructInPlace, set } from "../lib/PlainRecord";
import { LibdiscoreStore } from "../modules/libdiscore/stores/LibdiscoreStore";
import { GuildRecordTypeTag, updateGameApplications, updateJoinedAt } from "../records/GuildRecord";
import AuthenticationStore from "./AuthenticationStore";
import { FAVORITES_GUILD_RECORD } from "../modules/favorites/FavoritesConstants";
import { toSetInplace } from "../_bundle/Module1414";
import { isFavoritesGuildId } from "../modules/favorites/FavoritesUtils";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import { fromBackgroundSync, fromServer, fromGuildPropertiesWithAdditionalFields, fromSerializedGuildRecord, fromGuild } from "../utils/GuildRecordUtils";
import { LibdiscoreBatchStoreRefactorExperiment } from "../modules/libdiscore/libdiscoreExperiments";
const createGuildRecordFromRust = function createGuildRecordFromRust(a0) {
return constructInPlace(GuildRecordTypeTag, {
...a0,
features: toSetInplace(a0.features),
joinedAt: a0.joinedAt != null ? new Date(a0.joinedAt) : null,
premiumProgressBarEnabledUserUpdatedAt: a0.premiumProgressBarEnabledUserUpdatedAt != null ? new Date(a0.premiumProgressBarEnabledUserUpdatedAt) : null
});
};
class GuildStore extends LibdiscoreStore {
static displayName = "GuildStore";
database = this.addKVDatabase("guilds", createGuildRecordFromRust);
getGuild = (a0) => {
if (a0 != null) {
return isFavoritesGuildId(a0) ? FAVORITES_GUILD_RECORD : this.database.get(a0);
}
};
getGuilds = this.database.memoized((a0) => ({
...a0
}));
getGuildsArray = this.database.memoized((a0) => Object.values(a0));
getGuildIds = this.database.memoized((a0) => SnowflakeUtils.keys(a0));
stateWrapper() {
return this.database;
}
getGuildCount() {
return this.database.length();
}
}
const guildStore = new GuildStore({
BACKGROUND_SYNC: (a0, a1) => {
for (const guild of a0.guilds) {
const r34 = a1.get(guild.id);
if (r34 != null && guild.data_mode !== "unavailable") {
const set2 = a1.set;
set2.call(a1, guild.id, fromBackgroundSync(guild, r34));
}
}
},
LOGOUT: (a0, a1) => {
a1.clear();
},
RESET_SOCKET: (a0, a1) => {
a1.clear();
},
CONNECTION_OPEN: ({ guilds, unavailableGuilds }, a1) => {
let r28;
const allRecords = a1.getAllRecords();
const set2 = new Set(Object.keys(allRecords));
let r37 = guilds[Symbol.iterator]();
const next = r37.next;
while (true) {
const r40 = r37 === void 0 ? void 0 : (r28 = next.call(r37)).done ? r37 = void 0 : r28.value;
if (r37 === void 0) {
for (const item of unavailableGuilds) {
set2.delete(item);
}
for (const item2 of set2) {
a1.remove(item2);
}
return void 0;
} else {
try {
set2.delete(r40.id);
if (r40.properties == null && allRecords[r40.id] == null) {
throw new Error("Guild data was missing from store, but hash was still available.");
}
const set3 = a1.set;
set3.call(a1, r40.id, fromServer(r40, allRecords[r40.id]));
} catch (r63) {
if (r37 !== void 0 && typeof r37.return === "function") {
try {
r37.return();
} catch {}
}
throw r63;
}
}
}
},
OVERLAY_INITIALIZE: ({ guilds }, a1) => {
a1.clear();
if (guilds != null) {
for (const item of guilds) {
const { properties, additionalFields } = item;
a1.set.call(a1, properties.id, fromGuildPropertiesWithAdditionalFields(properties, {
joinedAt: additionalFields.joinedAt != null ? new Date(additionalFields.joinedAt) : null,
premiumSubscriberCount: additionalFields.premiumSubscriberCount
}));
}
}
},
CACHE_LOADED: ({ guilds }, a1) => {
a1.clear();
for (const item of guilds) {
a1.set(item.id, fromSerializedGuildRecord(item));
}
},
CACHE_LOADED_LAZY: ({ guilds }, a1) => {
if (guilds.length !== 0) {
a1.clear();
for (const item of guilds) {
a1.set(item.id, fromSerializedGuildRecord(item));
}
}
},
GUILD_CREATE: ({ guild }, a1) => {
const r6 = a1.get(guild.id);
if (guild.properties == null && r6 == null) {
throw new Error("Guild data was missing from store, but hash was still available.");
}
a1.set(guild.id, fromServer(guild, r6));
},
GUILD_UPDATE: ({ guild }, a1) => {
a1.set(guild.id, fromGuild(guild, a1.get(guild.id)));
},
GUILD_THEME_PREVIEW_SAVE_SUCCESS: ({ guildId, guildTheme }, a1) => {
const r6 = a1.get(guildId);
if (r6 != null) {
a1.set(guildId, set(r6, "guildTheme", guildTheme));
}
},
GUILD_SETTINGS_GUILD_THEME_SAVE_SUCCESS: ({ guildId, guildTheme }, a1) => {
const r6 = a1.get(guildId);
if (r6 != null) {
a1.set(guildId, set(r6, "guildTheme", guildTheme));
}
},
GUILD_DELETE: ({ guild }, a1) => {
if (!guild.unavailable) {
a1.remove(guild.id);
}
},
GUILD_MEMBER_ADD: ({ guildId, joinedAt, user }, a1) => {
const id = AuthenticationStore.getId();
const r16 = a1.get(guildId);
if (id === user.id && r16 != null) {
let r18 = joinedAt;
if (typeof r18 === "string") {
r18 = new Date(joinedAt);
}
if (r18 !== r16.joinedAt && r18 != null) {
a1.set(guildId, updateJoinedAt(r16, r18));
}
}
},
GUILD_OFFICIAL_GAME_APPLICATIONS_UPDATE: ({ guildId, gameApplicationIds }, a1) => {
const r5 = a1.get(guildId);
if (r5 != null) {
a1.set(guildId, updateGameApplications(r5, gameApplicationIds));
}
}
}, LibdiscoreBatchStoreRefactorExperiment.getCachedBridgedStoreMode());
export default guildStore;
+382
View File
@@ -0,0 +1,382 @@
// Metro module 6054 (f6055).
import ExperimentStore from "../modules/experiments/ExperimentStore";
import LurkingStore from "../modules/lurker_mode/LurkingStore";
import SpotifyStore from "../modules/spotify/SpotifyStore";
import AuthenticationStore from "./AuthenticationStore";
import { EVERYONE_CHANNEL_ID } from "./ChannelMemberStore";
import ChannelSectionStore from "./ChannelSectionStore";
import ChannelStore from "./ChannelStore";
import GuildAvailabilityStore from "./GuildAvailabilityStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildStore from "./GuildStore";
import RTCConnectionStore from "./RTCConnectionStore";
import RelationshipStore from "./RelationshipStore";
import SelectedChannelStore from "./SelectedChannelStore";
import SelectedGuildStore from "./SelectedGuildStore";
import { ChannelSections, ChannelTypes } from "../Constants";
import GuildSubscriptions from "../lib/guild/GuildSubscriptions";
import Dispatcher from "../Dispatcher";
import Module12 from "../_bundle/Module12";
import * as _FavoritesUtils from "../modules/favorites/FavoritesUtils";
import Module589 from "../_bundle/Module589";
function $mk77657($env) {
return (a0) => {
const r4 = $env.$parent;
let r0 = a0 === r4[18].getGuildId() || a0 === r4[15].getGuildId();
if (!r0) {
const channel = r4[11].getChannel(r4[17].getChannelId());
r0 = a0 === (channel == null ? void 0 : channel.getGuildId());
}
if (!r0) {
r0 = r4[3] != null && r4[3].guildId === a0;
}
if (!r0) {
const r25 = $env;
const r26 = r4[20];
r26.clearWithoutFlushing(a0, r25[0]);
if (r25[1]) {
r25[2][a0] = r26.get(a0);
}
}
};
}
let resubscribe, handleSpotifyUpdate, c3837_20, c3837_23;
let env3837 = {};
const handleConnectionOpenOrResumed = function handleConnectionOpenOrResumed({ type }) {
if (type === "CONNECTION_OPEN") {
let env15409;
const r13 = env15409 = {
$parent: env3837
};
env15409[0] = true;
env15409[1] = false;
const subscriptions = {};
env15409[2] = subscriptions;
c3837_20.forEach($mk77657(r13));
if (!Module12.isEmpty(subscriptions)) {
Dispatcher.dispatch({
type: "GUILD_SUBSCRIPTIONS_FLUSH",
subscriptions
});
}
}
const guildId3 = SelectedGuildStore.getGuildId();
if (guildId3 != null) {
const channelId = SelectedChannelStore.getChannelId(guildId3);
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(guildId3);
let r41 = guildId3;
if (isFavoritesGuildId) {
r41 = guildId3;
if (channelId != null) {
const channel = ChannelStore.getChannel(channelId);
let r45 = channel == null ? void 0 : channel.getGuildId();
if (r45 == null) {
r45 = guildId3;
}
r41 = r45;
}
}
c3837_20.subscribeToGuild(r41);
}
const subscriptions2 = {};
let c15408_0 = subscriptions2;
let c15408_1 = new Set(LurkingStore.lurkingGuildIds());
let c15408_2 = LurkingStore.mostRecentLurkedGuildId();
c3837_20.forEach((item) => {
if (GuildStore.getGuild(item) == null) {
c3837_20.clearWithoutFlushing(item, true);
} else if (!(c15408_1.has(item) && item !== c15408_2)) {
c15408_0[item] = c3837_20.get(item);
}
});
if (!Module12.isEmpty(subscriptions2)) {
Dispatcher.dispatch({
type: "GUILD_SUBSCRIPTIONS_FLUSH",
subscriptions: subscriptions2
});
}
};
const handleChannelSelect = function handleChannelSelect({ guildId: guildId3, channelId }) {
const isUnavailable = GuildAvailabilityStore.isUnavailable(guildId3);
let r0 = !isUnavailable;
if (!isUnavailable) {
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(guildId3);
let r18 = guildId3;
if (isFavoritesGuildId) {
r18 = guildId3;
if (channelId != null) {
const channel = ChannelStore.getChannel(channelId);
let r21 = channel == null ? void 0 : channel.getGuildId();
if (r21 == null) {
r21 = guildId3;
}
r18 = r21;
}
}
c3837_20.subscribeToGuild(r18);
r0 = false;
}
return r0;
};
resubscribe = function resubscribe() {
const guildId3 = SelectedGuildStore.getGuildId();
const channelId = SelectedChannelStore.getChannelId();
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(guildId3);
let r17 = guildId3;
if (isFavoritesGuildId) {
r17 = guildId3;
if (channelId != null) {
const channel = ChannelStore.getChannel(channelId);
let r20 = channel == null ? void 0 : channel.getGuildId();
if (r20 == null) {
r20 = guildId3;
}
r17 = r20;
}
}
c3837_20.subscribeToGuild(r17);
return false;
};
handleSpotifyUpdate = function handleSpotifyUpdate() {
const syncingWith = SpotifyStore.getSyncingWith();
if (syncingWith == null) {
if (env3837[3] != null) {
c3837_20.unsubscribeUser(env3837[3].guildId, env3837[3].userId);
env3837[3] = null;
}
} else {
const userId = syncingWith.userId;
if (env3837[3] != null && env3837[3].userId === userId) {
return false;
}
if (RelationshipStore.isFriend(userId)) {
return false;
}
const r17 = GuildMemberStore.memberOf(userId);
if (r17.length === 0) {
return false;
}
const [guildId3] = r17;
env3837[3] = {
guildId: guildId3,
userId
};
c3837_20.subscribeUser(guildId3, userId);
}
return false;
};
ChannelSections;
c3837_20 = new GuildSubscriptions((a0) => {
for (const key in a0) {
if (!(GuildStore.getGuild(key) != null || GuildAvailabilityStore.isUnavailable(key))) {
delete a0[key];
}
}
Dispatcher.dispatch({
type: "GUILD_SUBSCRIPTIONS_FLUSH",
subscriptions: a0
});
});
class GuildSubscriptionsStore extends Module589.Store {
static displayName = "GuildSubscriptionsStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(AuthenticationStore, ChannelSectionStore, ChannelStore, ExperimentStore, GuildAvailabilityStore, GuildMemberStore, GuildStore, LurkingStore, RTCConnectionStore, RelationshipStore, SelectedChannelStore, SelectedGuildStore, SpotifyStore);
this.syncWith([SpotifyStore], handleSpotifyUpdate);
this.syncWith([ChannelSectionStore], resubscribe);
}
getSubscribedThreadIds() {
return c3837_20.getSubscribedThreadIds();
}
isSubscribedToThreads(a0) {
return c3837_20.isSubscribedToThreads(a0);
}
isSubscribedToAnyMember(a0) {
return c3837_20.isSubscribedToAnyMember(a0);
}
isSubscribedToMemberUpdates(a0) {
return c3837_20.isSubscribedToMemberUpdates(a0);
}
isSubscribedToAnyGuildChannel(a0) {
const channels = c3837_20.get(a0).channels;
return channels != null && Object.keys(channels).length > 0;
}
}
c3837_23 = GuildSubscriptionsStore;
const r99 = new GuildSubscriptionsStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpenOrResumed,
CONNECTION_RESUMED: handleConnectionOpenOrResumed,
CONNECTION_CLOSED: function handleConnectionClosed() {
let env15410;
const r2 = env15410 = {
$parent: env3837
};
env15410[0] = false;
env15410[1] = false;
const subscriptions = {};
env15410[2] = subscriptions;
c3837_20.forEach($mk77657(r2));
if (!Module12.isEmpty(subscriptions)) {
Dispatcher.dispatch({
type: "GUILD_SUBSCRIPTIONS_FLUSH",
subscriptions
});
}
},
IDLE: function handleIdle(a0) {
if (a0.idle) {
let env15411;
const r2 = env15411 = {
$parent: env3837
};
env15411[0] = false;
env15411[1] = true;
const subscriptions = {};
env15411[2] = subscriptions;
c3837_20.forEach($mk77657(r2));
if (!Module12.isEmpty(subscriptions)) {
Dispatcher.dispatch({
type: "GUILD_SUBSCRIPTIONS_FLUSH",
subscriptions
});
}
return void 0;
}
return false;
},
LOGOUT: function handleLogout() {
c3837_20.reset();
},
VOICE_CHANNEL_SELECT: handleChannelSelect,
CHANNEL_SELECT: handleChannelSelect,
GUILD_CREATE: function handleGuildCreate(a0) {
if (a0.guild.id === SelectedGuildStore.getGuildId()) {
const guildId3 = SelectedGuildStore.getGuildId();
const channelId = SelectedChannelStore.getChannelId();
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(guildId3);
let r22 = guildId3;
if (isFavoritesGuildId) {
r22 = guildId3;
if (channelId != null) {
const channel = ChannelStore.getChannel(channelId);
let r25 = channel == null ? void 0 : channel.getGuildId();
if (r25 == null) {
r25 = guildId3;
}
r22 = r25;
}
}
c3837_20.subscribeToGuild(r22);
}
},
GUILD_DELETE: function handleGuildDelete(a0) {
c3837_20.clearWithoutFlushing(a0.guild.id, true);
},
GUILD_SUBSCRIPTIONS_MEMBERS_ADD: function handleMembersAdd(a0) {
const guildId = a0.guildId;
a0.userIds.forEach((userId) => {
if (userId !== AuthenticationStore.getId()) {
c3837_20.subscribeUser(guildId, userId);
}
});
return false;
},
GUILD_SUBSCRIPTIONS_MEMBERS_REMOVE: function handleMembersRemove(a0) {
const guildId2 = a0.guildId;
a0.userIds.forEach((userId) => {
c3837_20.unsubscribeUser(guildId2, userId);
});
return false;
},
GUILD_SUBSCRIPTIONS_ADD_MEMBER_UPDATES: function handleAddMemberUpdatesGuildSubscription(a0) {
c3837_20.subscribeToMemberUpdates(a0.guildId);
},
GUILD_SUBSCRIPTIONS_REMOVE_MEMBER_UPDATES: function handleRemoveMemberUpdatesGuildSubscription(a0) {
c3837_20.unsubscribeFromMemberUpdates(a0.guildId);
},
GUILD_SUBSCRIPTIONS_CHANNEL: function handleChannel({ guildId: guildId3, channelId, ranges }) {
let r17;
if (channelId === EVERYONE_CHANNEL_ID) {
r17 = c3837_20.subscribeChannel(guildId3, channelId, ranges);
} else {
const channel = ChannelStore.getChannel(channelId);
const r1 = channel == null;
r17 = false;
if (!r1) {
const guildId4 = channel.getGuildId();
if (guildId4 !== guildId3 && _FavoritesUtils.isFavoritesGuildId(guildId3)) {
c3837_20.subscribeToGuild(guildId4);
}
r17 = (channel == null ? void 0 : channel.isThread()) ? channel.type === ChannelTypes.ANNOUNCEMENT_THREAD ? c3837_20.subscribeChannel(guildId4, channel.parent_id, ranges) : !!channel.isActiveThread() && c3837_20.subscribeThreadMemberList(guildId4, channelId, SelectedChannelStore.getChannelId()) : c3837_20.subscribeChannel(guildId4, channelId, ranges);
}
}
return r17;
},
GUILD_SUBSCRIPTIONS: function handleGuild(a0) {
return c3837_20.subscribeToGuild(a0.guildId);
},
CHANNEL_PRELOAD: function handleChannelPreload({ guildId: guildId3, channelId }) {
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(guildId3);
let r14 = guildId3;
if (isFavoritesGuildId) {
r14 = guildId3;
if (channelId != null) {
const channel = ChannelStore.getChannel(channelId);
let r17 = channel == null ? void 0 : channel.getGuildId();
if (r17 == null) {
r17 = guildId3;
}
r14 = r17;
}
}
c3837_20.subscribeToGuild(r14);
return false;
},
OVERLAY_TEXT_CHAT_SELECT_CHANNEL: function handleOverlayTextChatSelectChannel({ guildId: guildId3, channelId }) {
const isFavoritesGuildId = _FavoritesUtils.isFavoritesGuildId(guildId3);
let r14 = guildId3;
if (isFavoritesGuildId) {
r14 = guildId3;
if (channelId != null) {
const channel = ChannelStore.getChannel(channelId);
let r17 = channel == null ? void 0 : channel.getGuildId();
if (r17 == null) {
r17 = guildId3;
}
r14 = r17;
}
}
c3837_20.subscribeToGuild(r14);
return false;
},
INBOX_OPEN: function handleInboxOpen(a0) {
for (const guildId3 of a0.guildIds) {
if (guildId3 != null) {
c3837_20.subscribeToGuild(guildId3);
}
}
return false;
},
THREAD_UPDATE: function handleThreadUpdate({ channel }) {
let r18;
if (channel.isArchivedThread()) {
r18 = c3837_20.unsubscribeThreadMemberList(channel.guild_id, channel.id);
} else {
const isActiveThread = channel.isActiveThread();
const r0 = isActiveThread ? SelectedChannelStore.getChannelId() !== channel.id : !isActiveThread;
r18 = !r0;
if (!r0) {
c3837_20.subscribeThreadMemberList(channel.guild_id, channel.id, SelectedChannelStore.getChannelId());
r18 = void 0;
}
}
return r18;
},
THREAD_DELETE: function handleThreadDelete({ channel }) {
return c3837_20.unsubscribeThreadMemberList(channel.guild_id, channel.id);
},
THREAD_LIST_SYNC: resubscribe
});
export default r99;
+272
View File
@@ -0,0 +1,272 @@
// Metro module 5003 (f5004).
import { isGuildOwner } from "../records/GuildRecord";
import GuildMemberStore from "./GuildMemberStore";
import GuildRoleStore from "./GuildRoleStore";
import GuildStore from "./GuildStore";
import UserStore from "./UserStore";
import { GuildFeatures, VerificationCriteria, VerificationLevels } from "../Constants";
import { GuildMemberFlags } from "../modules/guild_member/GuildMemberConstants";
import { hasFlag } from "../_bundle/Module1384";
import Dispatcher from "../Dispatcher";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import Module589 from "../_bundle/Module589";
let c3011_12, c3011_13, c3011_14, clearGuild;
const recomputeGuild = function recomputeGuild(a0) {
let r43;
const guildId = a0;
clearGuild(a0);
c3011_13.add(a0);
const guild = GuildStore.getGuild(a0);
const currentUser = UserStore.getCurrentUser();
const r51 = guild != null && guild.verificationLevel !== VerificationLevels.NONE;
const r18 = guild != null && guild.verificationRoleId != null;
L69: {
if (guild != null && currentUser != null) {
if (!r51 && !r18) {
break L69;
}
if (!isGuildOwner(guild, currentUser)) {
const member = GuildMemberStore.getMember(guild.id, currentUser.id);
if (member != null) {
let flags = member.flags;
if (flags == null) {
flags = 0;
}
if (hasFlag(flags, GuildMemberFlags.BYPASSES_VERIFICATION)) {
break L69;
}
}
let r68 = r18 && member != null;
let missingVerificationRole = false;
if (r68) {
r68 = !member.roles.includes(guild.verificationRoleId);
missingVerificationRole = r68;
}
const verificationRole = r68 ? GuildRoleStore.getRole(guild.id, guild.verificationRoleId) : void 0;
let r77 = 0;
let r78 = 0;
let newMember = false;
let newAccount = false;
let notPhoneVerified = false;
let notEmailVerified = false;
let notClaimed = false;
if (r51) {
const isPhoneVerified = currentUser.isPhoneVerified();
r77 = 0;
r78 = 0;
newMember = false;
newAccount = false;
notPhoneVerified = false;
notEmailVerified = false;
notClaimed = false;
if (!isPhoneVerified) {
const r15 = member != null;
let r83 = false;
if (r15) {
const set = new Set();
let r20 = member.roles[Symbol.iterator]();
const next = r20.next;
while (true) {
const r30 = r20 === void 0 ? void 0 : (r43 = next.call(r20)).done ? r20 = void 0 : r43.value;
if (r20 === void 0) {
const date = new Date("2022-12-02 00:00:00");
const r106 = member.joinedAt == null || new Date(member.joinedAt) < date;
const r118 = guild.features.has(GuildFeatures.GUILD_ONBOARDING_EVER_ENABLED) && !r106;
const r119 = (r18 ? !r18 : !r118) && set.size > 0;
r83 = false;
if (!r119) {
break;
}
r83 = true;
break;
}
try {
const role = GuildRoleStore.getRole(guild.id, r30);
if (!(role == null || role.managed)) {
set.add(r30);
}
} catch (r100) {
if (r20 !== void 0 && typeof r20.return === "function") {
try {
r20.return();
} catch {}
}
throw r100;
}
}
}
r77 = 0;
r78 = 0;
newMember = false;
newAccount = false;
notPhoneVerified = false;
notEmailVerified = false;
notClaimed = false;
if (!r83) {
const r132 = +currentUser.createdAt + 60000 * VerificationCriteria.ACCOUNT_AGE - Date.now();
const r141 = +guild.joinedAt + 60000 * VerificationCriteria.MEMBER_AGE - Date.now();
const r145 = guild.verificationLevel >= VerificationLevels.LOW && !currentUser.isClaimed();
const isStaff = currentUser.isStaff();
let r150 = false;
let r151 = false;
let r152 = false;
let r14 = false;
if (!isStaff) {
const r155 = guild.verificationLevel >= VerificationLevels.LOW && !currentUser.verified;
const r159 = guild.verificationLevel >= VerificationLevels.VERY_HIGH;
const r162 = guild.verificationLevel >= VerificationLevels.MEDIUM && r132 > 0;
r150 = guild.verificationLevel >= VerificationLevels.HIGH && r141 > 0;
r151 = r162;
r152 = r159;
r14 = r155;
}
newMember = r150;
newAccount = r151;
notPhoneVerified = r152;
notEmailVerified = r14;
r77 = r141;
r78 = r132;
notClaimed = r145;
}
}
}
const r166 = [];
if (newMember) {
r166.push(r77);
}
if (newAccount) {
r166.push(r78);
}
const r172 = r166.length > 0;
let timeoutRef = void 0;
if (r172) {
const r175 = setTimeout;
const r176 = Math;
timeoutRef = r175(() => Dispatcher.dispatch({
type: "GUILD_VERIFICATION_CHECK",
guildId
}), r176.max.apply(r176, [...r166]));
}
const r187 = {
notClaimed,
notEmailVerified,
notPhoneVerified,
newAccount,
newMember,
missingVerificationRole,
verificationRole,
canChat: null,
accountDeadline: null,
memberDeadline: null,
timeoutRef: null
};
if (!notClaimed) {
notClaimed = notEmailVerified;
}
if (!notClaimed) {
notClaimed = notPhoneVerified;
}
if (!notClaimed) {
notClaimed = newAccount;
}
if (!notClaimed) {
notClaimed = newMember;
}
if (!notClaimed) {
notClaimed = missingVerificationRole;
}
r187.canChat = !notClaimed;
r187.accountDeadline = new Date(Date.now() + r78);
r187.memberDeadline = new Date(Date.now() + r77);
r187.timeoutRef = timeoutRef;
c3011_14[a0] = r187;
}
}
}
};
clearGuild = function clearGuild(a0) {
const r3 = c3011_14[a0];
if (r3 != null) {
clearTimeout(r3.timeoutRef);
}
delete c3011_14[a0];
};
const handleCreateOrUpdateGuild = function handleCreateOrUpdateGuild(a0) {
c3011_13.delete(a0.guild.id);
recomputeGuild(a0.guild.id);
};
c3011_12 = {
notClaimed: false,
notEmailVerified: false,
notPhoneVerified: false,
newAccount: false,
newMember: false,
missingVerificationRole: false,
canChat: true
};
c3011_13 = new Set();
c3011_14 = {};
class GuildVerificationStore extends Module589.Store {
static displayName = "GuildVerificationStore";
initialize() {
this.waitFor(GuildMemberStore, GuildRoleStore, GuildStore, UserStore);
}
getCheck(a0) {
let r10;
if (a0 == null) {
r10 = c3011_12;
} else {
if (!c3011_13.has(a0)) {
recomputeGuild(a0);
}
r10 = c3011_14[a0];
if (r10 == null) {
r10 = c3011_12;
}
}
return r10;
}
canChatInGuild(a0) {
return this.getCheck(a0).canChat;
}
}
const guildVerificationStore = new GuildVerificationStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c3011_13.clear();
for (const key in c3011_14) {
const r12 = c3011_14[key];
if (r12 != null) {
clearTimeout(r12.timeoutRef);
}
delete c3011_14[key];
}
},
CONNECTION_CLOSED: function handleConnectionClosed() {
SnowflakeUtils.keys(c3011_14).forEach(clearGuild);
},
CURRENT_USER_UPDATE: function handleCurrentUserUpdate() {
c3011_13.clear();
},
GUILD_CREATE: handleCreateOrUpdateGuild,
GUILD_UPDATE: handleCreateOrUpdateGuild,
GUILD_DELETE: function handleDeleteGuild(a0) {
const id = a0.guild.id;
const r3 = c3011_14[id];
if (r3 != null) {
clearTimeout(r3.timeoutRef);
}
delete c3011_14[id];
},
GUILD_MEMBER_UPDATE: function handleGuildMemberUpdate(a0) {
const guildId2 = a0.guildId;
if (a0.user.id !== UserStore.getCurrentUser()?.id) {
return false;
}
c3011_13.delete(guildId2);
recomputeGuild(guildId2);
},
GUILD_VERIFICATION_CHECK: function handleGuildVerificationCheck(a0) {
recomputeGuild(a0.guildId);
}
});
export default guildVerificationStore;
+26
View File
@@ -0,0 +1,26 @@
// Metro module 4280 (f4281).
import { MediaEngineHookTypes } from "../Constants";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2519_1 = {};
class HookErrorStore extends Module589.Store {
static displayName = "HookErrorStore";
getHookError(a0) {
return c2519_1[a0];
}
}
const hookErrorStore = new HookErrorStore(Dispatcher, {
MEDIA_ENGINE_SET_GO_LIVE_SOURCE: function handleSetGoLiveSource() {
c2519_1 = {};
},
MEDIA_ENGINE_SOUNDSHARE_TRANSMITTING: function handleSoundshareTransmitting() {
delete c2519_1[MediaEngineHookTypes.SOUND];
},
MEDIA_ENGINE_SOUNDSHARE_FAILED: function handleSoundshareFailed(a0) {
c2519_1[MediaEngineHookTypes.SOUND] = {
errorMessage: a0.errorMessage,
errorCode: a0.errorCode
};
}
});
export default hookErrorStore;
+196
View File
@@ -0,0 +1,196 @@
// Metro module 5000 (f5001).
import AuthenticationStore from "./AuthenticationStore";
import { AppStates, IDLE_DURATION } from "../Constants";
import { SpeakingFlags } from "../_bundle/Module4250";
import { isAndroid, isPlatformEmbedded } from "../utils/PlatformUtils";
import { AfkTimeout } from "../modules/user_settings/UserSettings";
import Durations from "../utils/Durations";
import Dispatcher from "../Dispatcher";
import DiscordNative from "../lib/DiscordNative";
import SelectedChannelActionCreators from "../actions/SelectedChannelActionCreators";
import debounce from "../_bundle/debounce";
import Module589 from "../_bundle/Module589";
let c3008_3, idleSince, idle, afk, c3008_11, c3008_12, c3008_13, checkNativeIdle2;
const checkIdleAFK = function checkIdleAFK() {
L12: {
if (!(Date.now() - idleSince > IDLE_DURATION) && !(c3008_11 || c3008_12 || isAndroid() && c3008_13)) {
if (!idle) {
break L12;
}
Dispatcher.dispatch({
type: "IDLE",
idle: false
});
} else if (!idle) {
Dispatcher.dispatch({
type: "IDLE",
idle: true,
idleSince
});
}
}
L26: {
const setting = AfkTimeout.getSetting();
if (setting !== 0 && c3008_3 == null && !(Date.now() - idleSince > Math.min(setting * Durations.Millis.SECOND, IDLE_DURATION)) && !(c3008_11 || c3008_12 || isAndroid() && c3008_13)) {
if (!afk) {
break L26;
}
Dispatcher.dispatch({
type: "AFK",
afk: false
});
} else if (!afk) {
Dispatcher.dispatch({
type: "AFK",
afk: true
});
}
}
};
idleSince = Date.now();
idle = false;
afk = false;
c3008_11 = false;
c3008_12 = false;
c3008_13 = false;
if (isPlatformEmbedded) {
if (DiscordNative?.powerMonitor != null) {
checkNativeIdle2 = function checkNativeIdle() {
if ((DiscordNative == null ? void 0 : DiscordNative.powerMonitor?.getSystemIdleTimeMs) != null) {
const systemIdleTimeMs = DiscordNative.powerMonitor.getSystemIdleTimeMs();
if (systemIdleTimeMs instanceof Promise) {
systemIdleTimeMs.then(function handleIdleTime(result) {
const r9 = Date.now() - result;
if (c3008_3 == null || r9 > c3008_3) {
idleSince = Math.max(r9, idleSince);
c3008_3 = null;
}
checkIdleAFK();
setTimeout(checkNativeIdle2, 10 * Durations.Millis.SECOND);
});
} else {
const r13 = Date.now() - systemIdleTimeMs;
if (c3008_3 == null || r13 > c3008_3) {
idleSince = Math.max(r13, idleSince);
c3008_3 = null;
}
checkIdleAFK();
setTimeout(checkNativeIdle2, 10 * Durations.Millis.SECOND);
}
}
};
checkNativeIdle2();
DiscordNative.powerMonitor.on("resume", () => {
c3008_11 = false;
checkIdleAFK();
});
DiscordNative.powerMonitor.on("suspend", () => {
c3008_11 = true;
c3008_3 = Date.now();
checkIdleAFK();
SelectedChannelActionCreators.disconnect();
});
DiscordNative.powerMonitor.on("lock-screen", () => {
c3008_12 = true;
c3008_3 = Date.now();
checkIdleAFK();
});
DiscordNative.powerMonitor.on("unlock-screen", () => {
c3008_12 = false;
checkIdleAFK();
});
} else {
setInterval(checkIdleAFK, 30 * Durations.Millis.SECOND);
}
} else {
setInterval(checkIdleAFK, 30 * Durations.Millis.SECOND);
}
const handleGenericAction = function handleGenericAction(a0) {
let timestamp = a0.timestamp;
const { type, bypassIdleUpdate } = a0;
const r0 = type === "OVERLAY_SET_NOT_IDLE" && timestamp != null;
if (!(r0 && timestamp <= idleSince || bypassIdleUpdate)) {
c3008_3 = null;
if (!r0) {
timestamp = Date.now();
}
idleSince = timestamp;
checkIdleAFK();
}
return false;
};
debounce(() => {
const r2 = {};
let timestamp = r2.timestamp;
const { type, bypassIdleUpdate } = r2;
const r0 = type === "OVERLAY_SET_NOT_IDLE" && timestamp != null;
if (!(r0 && timestamp <= idleSince || bypassIdleUpdate)) {
c3008_3 = null;
if (!r0) {
timestamp = Date.now();
}
idleSince = timestamp;
checkIdleAFK();
}
}, 500);
class IdleStore extends Module589.Store {
static displayName = "IdleStore";
initialize() {
this.waitFor(AuthenticationStore);
}
isIdle() {
return idle;
}
isAFK() {
return afk;
}
getIdleSince() {
return idle ? idleSince : null;
}
getSystemSuspended() {
return c3008_11;
}
getSystemLocked() {
return c3008_12;
}
}
const idleStore = new IdleStore(Dispatcher, {
IDLE: function handleIdle(a0) {
idle = a0.idle;
},
AFK: function handleAFK(a0) {
afk = a0.afk;
},
SPEAKING: function handleSpeaking(a0) {
const userId = a0.userId;
if (a0.speakingFlags !== SpeakingFlags.NONE && userId === AuthenticationStore.getId()) {
const r12 = {};
let timestamp = r12.timestamp;
const { type, bypassIdleUpdate } = r12;
const r16 = type === "OVERLAY_SET_NOT_IDLE" && timestamp != null;
if (!(r16 && timestamp <= idleSince || bypassIdleUpdate)) {
c3008_3 = null;
if (!r16) {
timestamp = Date.now();
}
idleSince = timestamp;
checkIdleAFK();
}
}
return false;
},
APP_STATE_UPDATE: function handleAppStateUpdate(a0) {
c3008_13 = a0.state === AppStates.BACKGROUND;
c3008_3 = null;
idleSince = Date.now();
checkIdleAFK();
return false;
},
OVERLAY_SET_NOT_IDLE: handleGenericAction,
CHANNEL_SELECT: handleGenericAction,
VOICE_CHANNEL_SELECT: handleGenericAction,
WINDOW_FOCUS: handleGenericAction,
OVERLAY_INITIALIZE: handleGenericAction,
OVERLAY_SET_INPUT_LOCKED: handleGenericAction
});
export default idleStore;
+175
View File
@@ -0,0 +1,175 @@
// Metro module 6696 (f6697).
import InviteRecord from "../records/InviteRecord";
import { InviteTargetTypes } from "../modules/instant_invite/Constants";
import Module6698 from "../_bundle/Module6698";
import reverse from "../_bundle/reverse";
import Module6701 from "../_bundle/Module6701";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c4295_2;
let c4295_5 = {};
let c4295_6 = {};
let c4295_7 = {};
let c4295_8 = {};
let c4295_9 = false;
let c4295_10 = false;
let c4295_11 = false;
let c4295_12 = new Map();
class InstantInviteStore extends Module589.Store {
static displayName = "InstantInviteStore";
getInvite(a0, r2 = {}) {
let r13;
const { targetType, targetUserId, targetApplicationId } = r2;
if (targetType === InviteTargetTypes.STREAM && targetUserId != null) {
const r19 = c4295_6[a0];
r13 = r19 == null ? void 0 : r19[targetUserId];
} else if (targetType === InviteTargetTypes.EMBEDDED_APPLICATION && targetApplicationId != null) {
const r15 = c4295_7[a0];
r13 = r15 == null ? void 0 : r15[targetApplicationId];
} else {
r13 = c4295_5[a0];
}
return r13;
}
getFriendInvite() {
return c4295_2;
}
getFriendInvitesFetching() {
return c4295_9;
}
canRevokeFriendInvite() {
return c4295_2 != null && !c4295_10 && !c4295_11;
}
getReceivedInstallationIdForInviteCode(a0) {
return c4295_12.get(a0.toLowerCase());
}
}
const instantInviteStore = new InstantInviteStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c4295_5 = {};
c4295_6 = {};
c4295_7 = {};
c4295_8 = {};
c4295_2 = null;
c4295_10 = false;
c4295_11 = false;
c4295_9 = false;
},
CHANNEL_DELETE: function handleDeleteChannel({ channel }) {
delete c4295_5[channel.id];
delete c4295_6[channel.id];
delete c4295_7[channel.id];
},
FRIEND_INVITE_CREATE_SUCCESS: function handleFriendInviteCreateSuccess(a0) {
c4295_8[a0.invite.code] = InviteRecord.createFromServer(a0.invite);
let r27 = Module6698(reverse(Module6701(Object.values(c4295_8), "createdAt")));
if (r27 == null) {
r27 = null;
}
c4295_2 = r27;
c4295_11 = false;
},
FRIEND_INVITE_CREATE_FAILURE: function handleFriendInviteCreateFailure() {
c4295_11 = false;
},
FRIEND_INVITE_REVOKE_SUCCESS: function handleFriendInviteRevokeSuccess(a0) {
if (a0.invites != null) {
a0.invites.forEach((invite) => {
if (c4295_8[invite.code] != null) {
delete c4295_8[invite.code];
}
});
}
let r25 = Module6698(reverse(Module6701(Object.values(c4295_8), "createdAt")));
if (r25 == null) {
r25 = null;
}
c4295_2 = r25;
c4295_10 = false;
},
INSTANT_INVITE_CREATE_SUCCESS: function handleInstantInviteCreateSuccess(a0) {
const channelId = a0.channelId;
const fromServer = InviteRecord.createFromServer(a0.invite);
if (fromServer.targetType === InviteTargetTypes.STREAM && fromServer.targetUser != null) {
if (c4295_6[channelId] == null) {
c4295_6[channelId] = {};
}
c4295_6[channelId][String(fromServer.targetUser.id)] = fromServer;
} else if (fromServer.targetType === InviteTargetTypes.EMBEDDED_APPLICATION && fromServer.targetApplication != null) {
if (c4295_7[channelId] == null) {
c4295_7[channelId] = {};
}
c4295_7[channelId][fromServer.targetApplication.id] = fromServer;
} else {
c4295_5[channelId] = fromServer;
}
},
INSTANT_INVITE_CREATE_FAILURE: function handleInstantInviteCreateFailure(a0) {
c4295_5[a0.channelId] = null;
},
INSTANT_INVITE_REVOKE_SUCCESS: function handleInstantInviteRevokeSuccess(a0) {
c4295_5[a0.channelId] = null;
},
FRIEND_INVITE_REVOKE_REQUEST: function handleFriendInviteRevokeRequest() {
c4295_10 = true;
},
FRIEND_INVITE_CREATE_REQUEST: function handleFriendInviteCreateRequest() {
c4295_11 = true;
},
FRIEND_INVITES_FETCH_REQUEST: function handleFriendInviteFetchRequest() {
c4295_9 = true;
},
FRIEND_INVITES_FETCH_RESPONSE: function handleFriendInviteFetchResponse(a0) {
c4295_8 = {};
a0.invites.forEach((invite) => {
c4295_8[invite.code] = InviteRecord.createFromServer(invite);
});
let r25 = Module6698(reverse(Module6701(Object.values(c4295_8), "createdAt")));
if (r25 == null) {
r25 = null;
}
c4295_2 = r25;
c4295_9 = false;
},
INSTANT_INVITE_CLEAR: function handleInstantInviteClear(a0) {
delete c4295_5[a0.channelId];
},
INSTANT_INVITE_RECEIVED_INSTALLATION_ID_SET: function handleReceivedInstallationIdSet(a0) {
const map = new Map(c4295_12);
c4295_12 = map;
map.set(a0.inviteCode.toLowerCase(), a0.receivedInstallationId);
},
INSTANT_INVITE_RECEIVED_INSTALLATION_ID_CLEAR: function handleReceivedInstallationIdClear(a0) {
const r9 = a0.inviteCode.toLowerCase();
if (c4295_12.has(r9)) {
const map = new Map(c4295_12);
c4295_12 = map;
map.delete(r9);
return void 0;
}
return false;
},
INVITE_MODAL_CLOSE: function handleInviteModalClose({ inviteCode }) {
let r10 = inviteCode != null;
if (r10) {
const r12 = inviteCode.toLowerCase();
const r14 = c4295_12.has(r12);
let r1 = false;
if (r14) {
const map = new Map(c4295_12);
c4295_12 = map;
map.delete(r12);
r1 = void 0;
}
r10 = r1;
}
return r10;
},
LOGOUT: function handleLogout() {
if (c4295_12.size === 0) {
return false;
}
c4295_12 = new Map();
}
});
export default instantInviteStore;
+200
View File
@@ -0,0 +1,200 @@
// Metro module 4174 (f4175).
import { InviteStates } from "../Constants";
import { parseExtraDataFromInviteKey } from "../modules/instant_invite/InviteCodeUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2403_3, c2403_4, c2403_5, c2403_6;
const updateInvite = function updateInvite(a0, a1) {
const r3 = a0 == null ? "" : a0;
const r15 = parseExtraDataFromInviteKey(r3);
const r17 = c2403_3.get(r3);
const r21 = r17 != null ? {
state: InviteStates.RESOLVING,
...r17
} : {
state: InviteStates.RESOLVING,
code: r15.baseCode
};
a1(r21);
const map = new Map(c2403_3);
c2403_3 = map;
map.set(r3, r21);
const guild = r21.guild;
const r2 = guild == null;
if ((r2 ? void 0 : guild.id) != null) {
const r39 = {
...c2403_5
};
r39[r21.guild.id] = r3;
c2403_5 = r39;
}
};
const handleInviteResolveFailure = function handleInviteResolveFailure(a0) {
let c13878_0 = a0;
updateInvite(a0.code, (a0) => {
a0.state = "banned" in c13878_0 && c13878_0.banned ? InviteStates.BANNED : InviteStates.EXPIRED;
});
};
c2403_3 = new Map();
c2403_4 = new Map();
c2403_5 = {};
c2403_6 = new Map();
class InviteStore extends Module589.Store {
static displayName = "InviteStore";
getInvite(a0) {
return c2403_3.get(a0);
}
getInviteError(a0) {
return c2403_4.get(a0);
}
getInvites() {
return c2403_3;
}
getInviteKeyForGuildId(a0) {
return c2403_5[a0];
}
getFriendMemberIds(a0) {
return c2403_6.get(a0);
}
}
const inviteStore = new InviteStore(Dispatcher, {
INVITE_RESOLVE: function handleInviteResolve({ code }) {
const r6 = parseExtraDataFromInviteKey(code);
const map = new Map(c2403_3);
c2403_3 = map;
map.set(code, {
code: r6.baseCode,
state: InviteStates.RESOLVING
});
},
INVITE_RESOLVE_SUCCESS: function handleInviteResolveSuccess(a0) {
let c13879_0 = a0;
updateInvite(a0.code, (a0) => {
a0.state = InviteStates.RESOLVED;
a0.guild = c13879_0.invite.guild;
a0.channel = c13879_0.invite.channel;
a0.inviter = c13879_0.invite.inviter;
let approximate_member_count = c13879_0.invite.approximate_member_count;
if (approximate_member_count == null) {
approximate_member_count = null;
}
a0.approximate_member_count = approximate_member_count;
let approximate_presence_count = c13879_0.invite.approximate_presence_count;
if (approximate_presence_count == null) {
approximate_presence_count = null;
}
a0.approximate_presence_count = approximate_presence_count;
a0.target_type = c13879_0.invite.target_type;
a0.target_user = c13879_0.invite.target_user;
a0.target_application = c13879_0.invite.target_application;
a0.expires_at = c13879_0.invite.expires_at;
a0.friends_count = c13879_0.invite.friends_count;
a0.is_contact = c13879_0.invite.is_contact;
a0.guild_scheduled_event = c13879_0.invite.guild_scheduled_event;
a0.type = c13879_0.invite.type;
a0.flags = c13879_0.invite.flags;
a0.is_nickname_changeable = c13879_0.invite.is_nickname_changeable;
a0.profile = c13879_0.invite.profile;
a0.roles = c13879_0.invite.roles;
a0.target_channel_id = c13879_0.invite.target_channel_id;
a0.target_message_id = c13879_0.invite.target_message_id;
a0.liveliness = c13879_0.invite.liveliness;
});
},
INVITE_RESOLVE_FAILURE: handleInviteResolveFailure,
INSTANT_INVITE_REVOKE_SUCCESS: handleInviteResolveFailure,
FRIEND_INVITE_CREATE_SUCCESS: function handleFriendInviteCreate(a0) {
let c13880_0 = a0;
updateInvite(a0.invite.code, (a0) => {
a0.state = InviteStates.RESOLVED;
a0.inviter = c13880_0.invite.inviter;
});
},
FRIEND_INVITE_REVOKE_SUCCESS: function handleFriendInviteRevokeSuccess(a0) {
a0.invites.forEach((invite) => {
updateInvite(invite.code, (a0) => {
a0.state = InviteStates.EXPIRED;
});
});
},
INSTANT_INVITE_CREATE_SUCCESS: function handleInstantInviteCreate(a0) {
let c13881_0 = a0;
updateInvite(a0.invite.code, (a0) => {
a0.state = InviteStates.RESOLVED;
a0.guild = c13881_0.invite.guild;
a0.channel = c13881_0.invite.channel;
a0.inviter = c13881_0.invite.inviter;
let approximate_member_count = c13881_0.invite.approximate_member_count;
if (approximate_member_count == null) {
approximate_member_count = null;
}
a0.approximate_member_count = approximate_member_count;
let approximate_presence_count = c13881_0.invite.approximate_presence_count;
if (approximate_presence_count == null) {
approximate_presence_count = null;
}
a0.approximate_presence_count = approximate_presence_count;
a0.target_type = c13881_0.invite.target_type;
a0.target_user = c13881_0.invite.target_user;
a0.target_application = c13881_0.invite.target_application;
a0.guild_scheduled_event = c13881_0.invite.guild_scheduled_event;
a0.type = c13881_0.invite.type;
a0.is_nickname_changeable = c13881_0.invite.is_nickname_changeable;
a0.profile = c13881_0.invite.profile;
a0.roles = c13881_0.invite.roles;
});
},
INVITE_ACCEPT: function handleAcceptInvite(a0) {
updateInvite(a0.code, (a0) => {
a0.state = InviteStates.ACCEPTING;
});
},
INVITE_ACCEPT_SUCCESS: function handleAcceptInviteSuccess(a0) {
let c13882_0 = a0;
updateInvite(a0.code, (a0) => {
a0.state = InviteStates.ACCEPTED;
a0.guild = c13882_0.invite.guild;
a0.new_member = c13882_0.invite.new_member;
a0.channel = {
...a0.channel,
...c13882_0.invite.channel
};
});
},
INVITE_ACCEPT_FAILURE: function handleAcceptInviteFailure(a0) {
c2403_4.set(a0.code, a0.error);
updateInvite(a0.code, (a0) => {
a0.state = InviteStates.ERROR;
});
},
INVITE_APP_OPENING: function handleInviteAppOpening(a0) {
updateInvite(a0.code, (a0) => {
a0.state = InviteStates.APP_OPENING;
});
},
INVITE_APP_OPENED: function handleInviteAppOpened(a0) {
updateInvite(a0.code, (a0) => {
a0.state = InviteStates.APP_OPENED;
});
},
INVITE_APP_NOT_OPENED: function handleInviteAppNotOpened(a0) {
updateInvite(a0.code, (a0) => {
a0.state = InviteStates.APP_NOT_OPENED;
});
},
INVITE_FRIEND_MEMBERS_FETCH_SUCCESS: function handleInviteFriendMembersFetchSuccess(a0) {
const map = new Map(c2403_6);
c2403_6 = map;
map.set(a0.code, a0.friendMemberIds);
},
INVITE_FRIEND_MEMBERS_FETCH_FAILURE: function handleInviteFriendMembersFetchFailure(a0) {
if (c2403_6.has(a0.code)) {
const map = new Map(c2403_6);
c2403_6 = map;
map.delete(a0.code);
return void 0;
}
return false;
}
});
export default inviteStore;
+114
View File
@@ -0,0 +1,114 @@
// Metro module 10087 (f10088).
import QuickSwitcherStore from "../modules/quickswitcher/QuickSwitcherStore";
import UserAffinitiesV2Store from "../modules/user_affinities/UserAffinitiesV2Store";
import ChannelStore from "./ChannelStore";
import PermissionStore from "./PermissionStore";
import RelationshipStore from "./RelationshipStore";
import { ChannelTypes, Permissions } from "../Constants";
import { InviteTargetTypes } from "../modules/instant_invite/Constants";
import { getMostRecentDMedUser, generateRowsForQuery, getUsersAlreadyJoined } from "../utils/InstantInviteUtils";
import { isNotNullish } from "../utils/GlobalUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let length, isFiltered, guild, channel, applicationId, inviteTargetType, omitUserIds, rows, c6713_18, counts, $mk83908 = function() {
return (a0, a1) => {
c6713_18.set(a0, {
index: a1
});
};
};
const _computeRows = function _computeRows(a0) {
const set = new Set();
const type = channel?.type;
const GUILD_VOICE = ChannelTypes.GUILD_VOICE;
const omitGuildId = guild == null || inviteTargetType === InviteTargetTypes.EMBEDDED_APPLICATION || type === GUILD_VOICE ? null : guild.id;
const mostRecentDMedUser = getMostRecentDMedUser(omitUserIds, omitGuildId);
const r38 = mostRecentDMedUser == null || RelationshipStore.isBlockedOrIgnored(mostRecentDMedUser.id);
if (!r38) {
set.add(mostRecentDMedUser.id);
}
for (const item of UserAffinitiesV2Store.getUserAffinities()) {
set.add(item.otherUserId);
}
const set2 = new Set();
let c17677_0 = set2;
if (inviteTargetType === InviteTargetTypes.EMBEDDED_APPLICATION) {
QuickSwitcherStore.getChannelHistory().map((item) => ChannelStore.getChannel(item)).filter(isNotNullish).filter((item) => item.type === ChannelTypes.GUILD_TEXT).filter((item) => PermissionStore.can(Permissions.SEND_MESSAGES, item)).slice(0, 3).forEach((item) => c17677_0.add(item.id));
}
return generateRowsForQuery({
query: a0,
omitUserIds,
suggestedUserIds: set,
maxRowsWithoutQuery: 100,
omitGuildId,
suggestedChannelIds: set2,
inviteTargetType
});
};
omitUserIds = new Set();
rows = [];
c6713_18 = new Map();
counts = {
numFriends: 0,
numDms: 0,
numGroupDms: 0,
numChannels: 0
};
class InviteSuggestionsStore extends Module589.Store {
static displayName = "InviteSuggestionsStore";
initialize() {
this.waitFor(ChannelStore, PermissionStore, QuickSwitcherStore, RelationshipStore, UserAffinitiesV2Store);
}
getInviteSuggestionRows() {
return rows;
}
getTotalSuggestionsCount() {
return length;
}
getInitialCounts() {
return counts;
}
getSelectedInviteMetadata(a0) {
const r6 = c6713_18.get(a0);
const r12 = UserAffinitiesV2Store.getUserAffinities().map((item) => item.otherUserId);
if (r6 != null) {
return {
rowNum: r6.index,
isAffinitySuggestion: a0.isSuggested,
numTotal: rows.length,
numAffinityConnections: r12.length,
isFiltered
};
}
}
}
const inviteSuggestionsStore = new InviteSuggestionsStore(Dispatcher, {
LOAD_INVITE_SUGGESTIONS: function refreshInviteSuggestions({ omitUserIds: omitUserIds2, guild: guild2, channel: channel2, applicationId: applicationId2, inviteTargetType: inviteTargetType2 }) {
guild = channel2 != null ? guild2 : null;
channel = channel2;
applicationId = applicationId2;
inviteTargetType = inviteTargetType2;
omitUserIds = new Set([...omitUserIds2, ...RelationshipStore.getBlockedOrIgnoredIDs(), ...getUsersAlreadyJoined({
channel,
applicationId,
inviteTargetType
})]);
isFiltered = false;
const r44 = _computeRows("");
const { rows: rows2, counts: counts2 } = r44;
rows = rows2;
c6713_18 = new Map();
rows2.forEach($mk83908());
counts = counts2;
length = rows.length;
},
INVITE_SUGGESTIONS_SEARCH: function handleSearch({ query }) {
isFiltered = query !== "";
const rows2 = _computeRows(query).rows;
rows2.sort((a, b) => a.score != null ? b.score != null ? a.score - b.score : 0 : 0);
rows = rows2;
c6713_18 = new Map();
rows2.forEach($mk83908());
}
});
export default inviteSuggestionsStore;
+35
View File
@@ -0,0 +1,35 @@
// Metro module 11565 (f11566).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c7889_0;
const handlePopAllLayers = function handlePopAllLayers() {
c7889_0 = [];
};
c7889_0 = [];
class LayerStore extends Module589.Store {
static displayName = "LayerStore";
hasLayers() {
return c7889_0.length > 0;
}
getLayers() {
return c7889_0;
}
}
const layerStore = new LayerStore(Dispatcher, {
LAYER_PUSH: function handleAddLayer({ component }) {
if (c7889_0.indexOf(component) >= 0) {
return false;
}
c7889_0 = [...c7889_0, component];
},
LAYER_POP: function handleRemoveLayer() {
if (c7889_0.length === 0) {
return false;
}
c7889_0 = c7889_0.slice(0, -1);
},
LAYER_POP_ALL: handlePopAllLayers,
LOGOUT: handlePopAllLayers,
NOTIFICATION_CLICK: handlePopAllLayers
});
export default layerStore;
+237
View File
@@ -0,0 +1,237 @@
// Metro module 4224 (f4225).
import LibraryApplicationRecord from "../records/LibraryApplicationRecord";
import AuthenticationStore from "./AuthenticationStore";
import { LibraryApplicationFlags } from "../Constants";
import { Storage } from "../_bundle/Module595";
import { getComboId, isUserEntitledToLibraryApplication } from "../utils/LibraryApplicationUtils";
import { hasFlag } from "../_bundle/Module1384";
import Module589 from "../_bundle/Module589";
import Module12 from "../_bundle/Module12";
import Dispatcher from "../Dispatcher";
let c2441_7, c2441_8, c2441_9, c2441_10, c2441_11, activeLibraryApplicationBranchIds, activeLaunchOptionIds, c2441_14;
const setLibraryApplications = function setLibraryApplications(a0) {
for (const item of a0) {
const fromServer = LibraryApplicationRecord.createFromServer(item);
c2441_9[getComboId(fromServer.id, fromServer.branchId)] = fromServer;
}
};
const handleLibraryApplicationUpdate = function handleLibraryApplicationUpdate(a0) {
const fromServer = LibraryApplicationRecord.createFromServer(a0.libraryApplication);
const comboId = getComboId(fromServer.id, fromServer.branchId);
c2441_9[comboId] = fromServer;
c2441_11.delete(comboId);
};
c2441_7 = "LibraryApplicationStore";
c2441_8 = false;
c2441_9 = {};
c2441_10 = {};
c2441_11 = new Set();
activeLibraryApplicationBranchIds = {};
activeLaunchOptionIds = {};
c2441_14 = false;
class LibraryApplicationStore extends Module589.Store {
static displayName = "LibraryApplicationStore";
initialize() {
this.waitFor(AuthenticationStore);
const r19 = Storage.get(c2441_7);
if (r19 != null) {
if (r19.activeLaunchOptionIds == null) {
let r27 = Storage.get(c2441_7);
if (r27 == null) {
r27 = {};
}
Storage.set(c2441_7, {
...r27,
activeLaunchOptionIds
});
} else {
activeLaunchOptionIds = r19.activeLaunchOptionIds;
}
if (r19.activeLibraryApplicationBranchIds == null) {
let r42 = Storage.get(c2441_7);
if (r42 == null) {
r42 = {};
}
Storage.set(c2441_7, {
...r42,
activeLibraryApplicationBranchIds
});
} else {
activeLibraryApplicationBranchIds = r19.activeLibraryApplicationBranchIds;
}
}
}
get libraryApplications() {
const r0 = {
...c2441_10,
...c2441_9
};
let c13998_0 = r0;
Object.keys(r0).forEach((item) => {
if (c13998_0[item].isHidden()) {
delete c13998_0[item];
}
});
return r0;
}
getAllLibraryApplications() {
return {
...c2441_10,
...c2441_9
};
}
hasLibraryApplication() {
return Object.keys({
...c2441_10,
...c2441_9
}).length > 0;
}
hasApplication(a0, a1, r3 = false) {
const comboId = getComboId(a0, a1);
let r13 = c2441_9[comboId];
if (r13 == null) {
r13 = c2441_10[comboId];
}
let r15 = r13 != null;
if (r15) {
const r16 = r3 ? !r3 : r13.isHidden();
r15 = r16 ? !r16 : isUserEntitledToLibraryApplication(r13);
}
return r15;
}
getLibraryApplication(a0, a1, r7 = false) {
const comboId = getComboId(a0, a1);
let r13 = c2441_9[comboId];
if (r13 == null) {
r13 = c2441_10[comboId];
}
let r16 = r13;
if (r7) {
r16 = r13;
if (r16 != null) {
r16 = isUserEntitledToLibraryApplication(r13) ? r13 : null;
}
}
return r16;
}
getActiveLibraryApplication(a0, r13 = false) {
L9: {
const r8 = activeLibraryApplicationBranchIds[a0];
if (r8 != null) {
const comboId = getComboId(a0, r8);
let r21 = c2441_9[comboId];
if (r21 == null) {
r21 = c2441_10[comboId];
}
if (r21 != null && isUserEntitledToLibraryApplication(r21)) {
if (!r13 && r21.isHidden()) {
break L9;
}
return r21;
}
}
}
const r10 = {
...c2441_10,
...c2441_9
};
for (const key in r10) {
if (r10[key].id === a0) {
const r38 = r10[key];
if (isUserEntitledToLibraryApplication(r38)) {
if (!r13 && r38.isHidden()) {
continue;
}
return r38;
}
}
}
}
isUpdatingFlags(a0, a1) {
return c2441_11.has(getComboId(a0, a1));
}
getActiveLaunchOptionId(a0, a1) {
return activeLaunchOptionIds[getComboId(a0, a1)];
}
get fetched() {
return c2441_8;
}
get entitledBranchIds() {
return Module12({
...c2441_10,
...c2441_9
}).values().filter((item) => isUserEntitledToLibraryApplication(item)).map((item) => item.branchId).value();
}
get hasRemovedLibraryApplicationThisSession() {
return c2441_14;
}
whenInitialized(c13999_0) {
this.addConditionalChangeListener(() => {
if (c2441_8) {
setImmediate(c13999_0);
return false;
}
});
}
}
const libraryApplicationStore = new LibraryApplicationStore(Dispatcher, {
LOGOUT: function handleLogout() {
c2441_8 = false;
},
LIBRARY_FETCH_SUCCESS: function handleFetchSuccess({ libraryApplications: libraryApplications2 }) {
c2441_9 = {};
setLibraryApplications(libraryApplications2);
c2441_8 = true;
},
SKU_PURCHASE_SUCCESS: function handlePurchaseSuccess(a0) {
setLibraryApplications(a0.libraryApplications);
},
LIBRARY_APPLICATION_FLAGS_UPDATE_START: function handleFlagsUpdateStart({ applicationId, branchId, flags }) {
const comboId = getComboId(applicationId, branchId);
const comboId2 = getComboId(applicationId, branchId);
let r18 = c2441_9[comboId2];
if (r18 == null) {
r18 = c2441_10[comboId2];
}
if (r18 != null && !r18.isHidden() && hasFlag(flags, LibraryApplicationFlags.HIDDEN)) {
c2441_14 = true;
}
c2441_11.add(comboId);
},
LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: handleLibraryApplicationUpdate,
LIBRARY_APPLICATION_UPDATE: handleLibraryApplicationUpdate,
LIBRARY_APPLICATION_ACTIVE_LAUNCH_OPTION_UPDATE: function handleActiveLaunchOptionIdUpdate({ applicationId, branchId, launchOptionId }) {
activeLaunchOptionIds[getComboId(applicationId, branchId)] = launchOptionId;
let r25 = Storage.get(c2441_7);
if (r25 == null) {
r25 = {};
}
Storage.set(c2441_7, {
...r25,
activeLaunchOptionIds
});
},
LIBRARY_APPLICATION_ACTIVE_BRANCH_UPDATE: function handleActiveBranchUpdate({ applicationId, branchId }) {
if (activeLibraryApplicationBranchIds[applicationId] === branchId) {
return false;
}
activeLibraryApplicationBranchIds[applicationId] = branchId;
let r22 = Storage.get(c2441_7);
if (r22 == null) {
r22 = {};
}
Storage.set(c2441_7, {
...r22,
activeLibraryApplicationBranchIds
});
},
LIBRARY_APPLICATIONS_TEST_MODE_ENABLED: function handleTestModeEnabled(a0) {
for (const libraryApplication of a0.libraryApplications) {
c2441_10[getComboId(libraryApplication.id, libraryApplication.branchId)] = libraryApplication;
}
},
DEVELOPER_TEST_MODE_RESET: function handleTestModeDisabled() {
c2441_10 = {};
}
});
export default libraryApplicationStore;
+248
View File
@@ -0,0 +1,248 @@
// Metro module 10472 (f10473).
import _slicedToArray from "../_bundle/_slicedToArray";
import EmbeddedActivitiesStore from "../modules/activities/EmbeddedActivitiesStore";
import ApplicationStore from "../modules/applications/ApplicationStore";
import RunningGameStore_native from "../modules/game_detection/RunningGameStore.native";
import FirstPartyRichPresenceStore from "../modules/rich_presence/FirstPartyRichPresenceStore";
import SpotifyStore from "../modules/spotify/SpotifyStore";
import UserSettingsProtoStore from "../modules/user_settings/UserSettingsProtoStore";
import ApplicationStreamingStore from "./ApplicationStreamingStore";
import ChannelStore from "./ChannelStore";
import DetectableGameStore from "./DetectableGameStore";
import ExternalStreamingStore from "./ExternalStreamingStore";
import SelectedChannelStore from "./SelectedChannelStore";
import SessionsStore from "./SessionsStore";
import { ActivityFlags, ActivityGamePlatforms, ActivityTypes } from "../Constants";
import { CustomStatusSetting } from "../modules/user_settings/UserSettings";
import { getActivityFromCustomStatus } from "../modules/custom_status/utils/userSettingToActivity";
import Module12 from "../_bundle/Module12";
import { doesGameHaveRichPresence } from "../modules/rich_presence/PresenceActivityFiltering";
import { maybeAddAdditionalGameMetadata } from "../modules/roblox_subgame_detection/RobloxSubgameUtils";
import isUndefinedOrNull from "../_bundle/isUndefinedOrNull";
import { computeActivityFlags, isContextlessEmbeddedActivity } from "../modules/activities/utils/ActivityFlagUtils";
import * as _Module1384 from "../_bundle/Module1384";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c7019_19, c7019_20, c7019_21;
const updateActivities = function updateActivities() {
let r88;
let streamerActiveStreamMetadata;
const r7 = [];
let c17986_0 = r7;
const setting = CustomStatusSetting.getSetting();
if (setting != null && (setting.expiresAtMs === "0" || new Date(Number(setting.expiresAtMs)).getTime() - new Date().getTime() > 0)) {
r7.push(getActivityFromCustomStatus(setting));
}
r7.push.apply(r7, [...FirstPartyRichPresenceStore.getActivities()]);
const stream = ExternalStreamingStore.getStream();
if (stream != null) {
r7.push({
type: ActivityTypes.STREAMING,
...stream
});
}
const set = new Set();
let c17986_1 = set;
Module12.forEach(c7019_20, (a0) => {
const [, r4] = a0;
if (r4.application_id != null) {
c17986_1.add(r4.name);
c17986_0.push(r4);
}
});
const r84 = ApplicationStreamingStore.getCurrentUserActiveStream() != null;
const visibleGame = RunningGameStore_native.getVisibleGame();
if (r84) {
streamerActiveStreamMetadata = ApplicationStreamingStore.getStreamerActiveStreamMetadata();
const visibleRunningGames = RunningGameStore_native.getVisibleRunningGames();
const r94 = streamerActiveStreamMetadata?.pid != null;
let r95 = null;
if (r94) {
let r97 = visibleRunningGames.find((visibleRunningGame) => visibleRunningGame.pid === streamerActiveStreamMetadata.pid);
if (r97 == null) {
r97 = null;
}
r95 = r97;
}
if (r95 == null && streamerActiveStreamMetadata?.id != null) {
let r102 = visibleRunningGames.find((visibleRunningGame) => visibleRunningGame.id === streamerActiveStreamMetadata.id);
if (r102 == null) {
r102 = null;
}
r95 = r102;
}
if (r95 != null) {
const r103 = c7019_21;
r88 = r95;
if (r103 == null) {
let start = r95.start;
if (start == null) {
start = Date.now();
}
c7019_21 = start;
r88 = r95;
}
} else {
c7019_21 = null;
r88 = visibleGame;
}
} else {
c7019_21 = null;
r88 = visibleGame;
}
const r107 = r88 != null && r88.name != null && (set.has(r88.name) || doesGameHaveRichPresence(r88, [...r7, ...SessionsStore.getRemoteActivities()]));
const r125 = r88 != null && r88.isLauncher;
L50: {
if (r88 != null && r88.name != null && !r107) {
if (r125 && !r84) {
break L50;
}
const r129 = DetectableGameStore.findGame(r88);
let id = r88.id;
if (id == null) {
id = r129?.id;
}
let start2 = c7019_21;
if (start2 == null) {
start2 = r88.start;
}
r7.push({
type: ActivityTypes.PLAYING,
name: r88.name,
application_id: id,
timestamps: {
start: start2
},
...maybeAddAdditionalGameMetadata(r88)
});
}
}
const activity = SpotifyStore.getActivity();
if (activity != null) {
r7.push({
type: ActivityTypes.LISTENING,
...activity
});
}
if (!isUndefinedOrNull(c7019_19, r7)) {
c7019_19 = r7;
}
};
c7019_19 = [];
c7019_20 = {};
c7019_21 = null;
class LocalActivityStore extends Module589.Store {
static displayName = "LocalActivityStore";
initialize() {
this.waitFor(ApplicationStore, ApplicationStreamingStore, ChannelStore, EmbeddedActivitiesStore, ExternalStreamingStore, FirstPartyRichPresenceStore, DetectableGameStore, RunningGameStore_native, SelectedChannelStore, SessionsStore, SpotifyStore, UserSettingsProtoStore);
this.syncWith([FirstPartyRichPresenceStore], () => {
updateActivities();
});
}
getActivities() {
return c7019_19;
}
getPrimaryActivity() {
return c7019_19[0];
}
getApplicationActivity(c17987_0) {
return this.findActivity((a0) => a0.application_id === c17987_0);
}
getCustomStatusActivity() {
return this.findActivity((a0) => a0.type === ActivityTypes.CUSTOM_STATUS);
}
findActivity(a0) {
return c7019_19.find(a0);
}
getApplicationActivities() {
return c7019_20;
}
getActivityForPID(a0) {
for (const item of Object.values(c7019_20)) {
const [r30, r31] = item;
if (r30 !== a0) {
continue;
}
return r31;
}
return null;
}
}
const localActivityStore = new LocalActivityStore(Dispatcher, {
ROBLOX_SUBGAME_UPDATE: updateActivities,
ROBLOX_SUBGAME_APPLICATION_FETCH_SUCCESS: updateActivities,
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
c7019_20 = {
...a0.localActivities
};
updateActivities();
},
START_SESSION: function handleStartSession() {
c7019_20 = {};
updateActivities();
},
LOCAL_ACTIVITY_UPDATE: function handleLocalActivityUpdate({ socketId, pid, activity, partyPrivacy }) {
if (isUndefinedOrNull(c7019_20[socketId], [pid, activity, partyPrivacy])) {
return false;
}
if (activity != null) {
c7019_20[socketId] = [pid, activity, partyPrivacy];
} else {
delete c7019_20[socketId];
}
updateActivities();
},
RPC_APP_DISCONNECTED: function handleRPCAppDisconnected(a0) {
delete c7019_20[a0.socketId];
updateActivities();
},
RUNNING_GAMES_CHANGE: updateActivities,
LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: updateActivities,
SPOTIFY_PLAYER_STATE: updateActivities,
SPOTIFY_PLAYER_PLAY: updateActivities,
STREAMING_UPDATE: updateActivities,
USER_CONNECTIONS_UPDATE: updateActivities,
STREAM_START: updateActivities,
STREAM_STOP: updateActivities,
USER_SETTINGS_PROTO_UPDATE: function handleUserSettingsProtoUpdate() {
(function recalculateActivityPartyPrivacyFlags() {
const r1 = {};
let r0 = false;
for (const item of Object.entries(c7019_20)) {
const r49 = _slicedToArray(item, 2);
const r50 = r49[0];
const [r53, r54, r56] = r49[1];
let flags = r54.flags;
if (flags == null) {
flags = 0;
}
let r20 = r54?.flags;
if (r20 == null) {
r20 = 0;
}
const hasFlag = _Module1384.hasFlag(r20, ActivityFlags.INSTANCE);
const r72 = computeActivityFlags(r54, hasFlag, r54.platform === ActivityGamePlatforms.EMBEDDED, isContextlessEmbeddedActivity(r54), r56);
if (r72 !== flags) {
r1[r50] = [r53, {
...r54,
flags: r72
}, r56];
r0 = true;
} else {
r1[r50] = [r53, r54, r56];
}
}
const r90 = r0;
let r91 = "NO_CHANGES";
if (r90) {
c7019_20 = r1;
r91 = "APPLICATION_ACTIVITIES_CHANGED";
}
return r91;
})();
updateActivities();
},
EMBEDDED_ACTIVITY_CLOSE: updateActivities,
RUNNING_GAME_TOGGLE_DETECTION: updateActivities
});
export default localActivityStore;
+63
View File
@@ -0,0 +1,63 @@
// Metro module 12799 (f12800).
import { setToken } from "../_bundle/setSecondaryToken";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c8826_3 = false;
let codes = [];
const key = "";
let c8826_6 = false;
let nonces = {
viewNonce: "",
regenerateNonce: ""
};
class MFAStore extends Module589.Store {
static displayName = "MFAStore";
getVerificationKey() {
return key;
}
getBackupCodes() {
return codes;
}
get togglingSMS() {
return c8826_3;
}
getNonces() {
return nonces;
}
get hasSeenBackupPrompt() {
return c8826_6;
}
}
const mFAStore = new MFAStore(Dispatcher, {
MFA_ENABLE_SUCCESS: function handleEnableSuccess({ token, codes: codes2 }) {
if (token !== void 0) {
setToken(token);
}
codes = codes2;
},
MFA_DISABLE_SUCCESS: function handleDisableSuccess(a0) {
setToken(a0.token);
},
MFA_SMS_TOGGLE: function handleSMSToggle() {
c8826_3 = true;
},
MFA_SMS_TOGGLE_COMPLETE: function handleSMSToggleComplete() {
c8826_3 = false;
},
MFA_CLEAR_BACKUP_CODES: function handleClearBackupCodes() {
codes = [];
},
MFA_VIEW_BACKUP_CODES: function handleGetBackupCodes({ codes: codes2, key: key2 }) {
codes = Module12.sortBy(codes2, "code");
key = key2;
},
MFA_SEND_VERIFICATION_KEY: function handleSendVerificationEmail(a0) {
nonces = a0.nonces;
},
MFA_SEEN_BACKUP_CODE_PROMPT: function handleSeenBackupPrompt() {
c8826_6 = true;
},
CONNECTION_OPEN: () => {}
});
export default mFAStore;
+62
View File
@@ -0,0 +1,62 @@
// Metro module 8202 (f8203).
import { SPOTIFY_HOSTNAMES } from "../modules/spotify/SpotifyConstants";
import { getHostname, getProtocol } from "./MaskedLinkStoreMethodsAdditional.native";
import URLUtils from "../utils/URLUtils";
import { Storage } from "../_bundle/Module595";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c5211_4 = "MaskedLinkStore";
let trustedDomains = new Set();
let trustedProtocols = new Set();
const MEDIA_PROXY_ENDPOINT = window.GLOBAL_ENV.MEDIA_PROXY_ENDPOINT;
let c5211_7 = MEDIA_PROXY_ENDPOINT == null ? void 0 : MEDIA_PROXY_ENDPOINT.replace("//", "");
class MaskedLinkStore extends Module589.Store {
static displayName = "MaskedLinkStore";
initialize() {
let r18 = Storage.get(c5211_4);
if (r18 == null) {
r18 = {};
}
const isArray = Array.isArray(r18);
const r8 = r18;
if (isArray) {
trustedDomains = new Set(r8 != null ? Array.from(r8) : null);
trustedProtocols = new Set();
} else {
const { trustedDomains: trustedDomains2, trustedProtocols: trustedProtocols2 } = r8;
trustedDomains = new Set(trustedDomains2 != null ? Array.from(trustedDomains2) : null);
trustedProtocols = new Set(trustedProtocols2 != null ? Array.from(trustedProtocols2) : null);
}
}
isTrustedDomain(a0) {
const hostname = getHostname(a0);
return window.GLOBAL_ENV.INVITE_HOST !== hostname ? window.GLOBAL_ENV.GIFT_CODE_HOST !== hostname ? window.GLOBAL_ENV.GUILD_TEMPLATE_HOST !== hostname ? c5211_7 !== hostname ? location.hostname !== hostname ? SPOTIFY_HOSTNAMES.includes(hostname) || URLUtils.isDiscordHostname(hostname) || trustedDomains.has(hostname) : true : true : true : true : true;
}
isTrustedProtocol(a0) {
return trustedProtocols.has(getProtocol(a0));
}
}
const maskedLinkStore = new MaskedLinkStore(Dispatcher, {
MASKED_LINK_ADD_TRUSTED_DOMAIN: function handleAddTrustedDomain({ url }) {
const hostname = getHostname(url);
if (window.GLOBAL_ENV.INVITE_HOST !== hostname ? window.GLOBAL_ENV.GIFT_CODE_HOST !== hostname ? window.GLOBAL_ENV.GUILD_TEMPLATE_HOST !== hostname ? c5211_7 !== hostname ? location.hostname !== hostname ? SPOTIFY_HOSTNAMES.includes(hostname) || URLUtils.isDiscordHostname(hostname) || trustedDomains.has(hostname) : true : true : true : true : true) {
return false;
}
trustedDomains.add(getHostname(url));
Storage.set(c5211_4, {
trustedDomains,
trustedProtocols
});
},
MASKED_LINK_ADD_TRUSTED_PROTOCOL: function handleAddTrustedProtocol({ url }) {
if (trustedProtocols.has(getProtocol(url))) {
return false;
}
trustedProtocols.add(getProtocol(url));
Storage.set(c5211_4, {
trustedDomains,
trustedProtocols
});
}
});
export default maskedLinkStore;
@@ -0,0 +1,19 @@
// Metro module 8203 (f8204).
export function getHostname(a0) {
let hostname;
try {
hostname = new URL(a0).hostname;
} catch ($e) {
return "";
}
return hostname;
}
export function getProtocol(a0) {
let protocol;
try {
protocol = new URL(a0).protocol;
} catch ($e) {
return "";
}
return protocol;
}
File diff suppressed because it is too large. Load diff
+106
View File
@@ -0,0 +1,106 @@
// Metro module 6073 (f6074).
import LurkingStore from "../modules/lurker_mode/LurkingStore";
import UserRecord from "../records/UserRecord";
import ChannelStore from "./ChannelStore";
import UserStore from "./UserStore";
import { ReactionTypes } from "../modules/messages/MessageReactionsTypes";
import Module589 from "../_bundle/Module589";
import { getReactors } from "../modules/reactions/ReactionActionCreators";
import Dispatcher from "../Dispatcher";
let c3853_6, c3853_7;
const reactionKey = function reactionKey(a0, item2, item) {
const name = item2.name;
let id = item2.id;
if (id == null) {
id = "";
}
return `${a0}:${name}:${id}:${item}`;
};
const handleReaction = function handleReaction(a0) {
const { type, messageId, userId } = a0;
const r10 = Reaction.ensure(messageId, a0.emoji, a0.reactionType);
if (type === "MESSAGE_REACTION_ADD") {
const user = UserStore.getUser(userId);
if (user != null) {
r10.users.set(userId, user);
}
} else {
r10.users.delete(userId);
}
};
c3853_6 = {};
c3853_7 = [ReactionTypes.NORMAL, ReactionTypes.BURST];
class Reaction {
fetched = false;
users = new Map();
static ensure(a0, a1, a2) {
const name = a1.name;
let id = a1.id;
if (id == null) {
id = "";
}
const r19 = `${a0}:${name}:${id}:${a2}`;
let r21 = c3853_6[r19];
if (r21 == null) {
const r26 = {
__proto__: Reaction.prototype
};
r26.fetched = false;
r26.users = new Map();
r21 = r26;
}
c3853_6[r19] = r21;
return r21;
}
}
class MessageReactionsStore extends Module589.Store {
static displayName = "MessageReactionsStore";
initialize() {
this.waitFor(ChannelStore, LurkingStore, UserStore);
}
getKnownReactorIds(a0, a1) {
const set = new Set();
for (const item2 of a1) {
for (const item of c3853_7) {
const r45 = c3853_6[reactionKey(a0, item2, item)];
if (r45 != null) {
for (const item3 of r45.users.keys()) {
set.add(item3);
}
}
}
}
return set;
}
getReactions(a0, a1, a2, a3, a4) {
const r11 = Reaction.ensure(a1, a2, a4);
if (!r11.fetched) {
const channel = ChannelStore.getChannel(a0);
const r7 = channel != null ? channel.getGuildId() : null;
if (r7 != null && LurkingStore.isLurking(r7)) {
return void 0;
}
getReactors({
channelId: a0,
messageId: a1,
emoji: a2,
limit: a3,
type: a4
});
r11.fetched = true;
}
return r11.users;
}
}
const messageReactionsStore = new MessageReactionsStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c3853_6 = {};
},
MESSAGE_REACTION_ADD: handleReaction,
MESSAGE_REACTION_REMOVE: handleReaction,
MESSAGE_REACTION_ADD_USERS: function handleAddUserReactions({ messageId, users, emoji, reactionType }) {
let c15460_0 = Reaction.ensure(messageId, emoji, reactionType);
users.forEach((user) => c15460_0.users.set(user.id, new UserRecord(user)));
}
});
export default messageReactionsStore;
+706
View File
@@ -0,0 +1,706 @@
// Metro module 4407 (f4408).
import ImpersonateStore from "../modules/impersonate/ImpersonateStore";
import EphemeralMessageStore from "../modules/messages/EphemeralMessageStore";
import LocaleStore from "../modules/user_settings/LocaleStore";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import DimensionStore from "./DimensionStore";
import GuildChannelStore from "./GuildChannelStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildStore from "./GuildStore";
import PermissionStore from "./PermissionStore";
import RelationshipStore from "./RelationshipStore";
import SelectedChannelStore from "./SelectedChannelStore";
import SelectedGuildStore from "./SelectedGuildStore";
import UserStore from "./UserStore";
import { MessageTypes, MessageReferenceTypes, MessageFlags, Permissions, MessageStates } from "../Constants";
import Logger from "../modules/debug/Logger";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import ChannelMessages from "../lib/ChannelMessages";
import * as _GatewayConnectionStore from "../modules/gateway/GatewayConnectionStore";
import DatabaseDaos from "../modules/app_database/DatabaseDaos";
import { isIOSPushNotificationRawPayloadFixExperimentEnabled } from "../modules/notifications/IOSPushNotificationRawPayloadFixExperiment";
import { updateMessageRecord } from "../modules/messages/MessageRecordUtils";
import { addFlag } from "../_bundle/Module1384";
import Module12 from "../_bundle/Module12";
import { handleExplicitMediaScanTimeoutForMessage } from "../modules/explicit_media_redaction/ExplicitMediaRedactionUtils";
import { shouldApplyReaction } from "../modules/reactions/ReactionUtils";
import { getFailedMessageId } from "../lib/MessageQueue";
import { isNotAutomodEmbed } from "../modules/guild_automod/GuildAutomodMessageStoreUtils";
import Module589 from "../_bundle/Module589";
import canEditMessage from "../modules/messages/canEditMessage";
import { InteractionTypes, ApplicationCommandType } from "../flow/Server";
import Dispatcher from "../Dispatcher";
function $mk74529($env) {
return (a0) => !$env[0].has(a0.id);
}
function $mk74530($env) {
return (a0) => {
a0._merge($env[1]);
a0._array.sort($mk103796($env.$parent));
};
}
function $mk74535($env) {
return (a0) => {
const r2 = $env.$parent;
if (r2[9].getChannel(a0.channelId)?.guild_id === $env[0]) {
let env25165 = {
$parent: r2
};
const r14 = [];
env25165[0] = r14;
env25165[1] = false;
a0.forEach((item) => {
const r3 = env25165.$parent;
const messageAuthor = (0, r3[0])(r3[2][27]).getMessageAuthor(item);
const { nick, colorString } = messageAuthor;
if (nick === item.nick && colorString === item.colorString) {
env25165[0].push(item);
} else {
env25165[1] = true;
env25165[0].push(item.merge({
nick,
colorString
}));
}
});
if (env25165[1]) {
(0, r2[1])(r2[2][19]).commit(a0.reset(r14));
}
}
};
}
function $mk103796($env) {
return (a0, a1) => {
const r1 = $env;
return (0, r1[1])(r1[2][18]).compare(a0.id, a1.id);
};
}
let receiveMediaMentionMessage, performAuthorUpdate, c2637_24, c2637_25, c2637_32, c2637_31;
let env2637 = {};
const reinjectEphemerals = function reinjectEphemerals(a0, a1) {
let env14239;
const r4 = env14239 = {
$parent: env2637
};
env14239[0] = a1;
if (a1.hasMoreAfter) {
return a1;
}
const messages = EphemeralMessageStore.getMessages(a0);
if (messages.length === 0) {
return a1;
}
const r13 = messages.filter($mk74529(r4));
env14239[1] = r13;
return r13.length !== 0 ? a1.mutate($mk74530(r4), true) : a1;
};
const handleConnectionOpen = function handleConnectionOpen() {
ChannelMessages.forEach((channelMessage) => {
ChannelMessages.commit(channelMessage.mutate({
ready: false,
loadingMore: false
}));
});
c2637_24.clear();
};
env2637[28] = function _addPushNotificationMessageIfNotCached() {
const r8 = async (c25164_0, c25164_1, c25164_2) => {
let c25164_5 = 0;
let c29336_0, c29336_1, c29336_2, c29336_3;
let r11 = "Push notification message not in cache, adding directly";
L17: {
L15: {
L16: {
try {
c29336_0 = c25164_0;
c29336_1 = c25164_1;
c29336_2 = c25164_2;
c29336_3 = void 0;
const r18 = DatabaseDaos.database();
const basicChannel = ChannelStore.getBasicChannel(c25164_0);
if (r18 != null && basicChannel != null) {
c25164_5 = 1;
const r28 = await DatabaseDaos.messages(r18).get(basicChannel.guild_id, c25164_0, c25164_1.id);
r11 = "Push notification message not in cache, adding directly";
if (r28 != null) {
c25164_5 = 0;
break L16;
}
c25164_5 = 0;
c2637_25.log(r11, c29336_1.id, c29336_1.channel_id);
c29336_3 = ChannelMessages.getOrCreate(c29336_0);
ChannelMessages.commit(c29336_3.receivePushNotification(c29336_1, c29336_2));
c2637_31.emitChange();
break L15;
}
c2637_25.log(r11, c29336_1.id, c29336_1.channel_id);
c29336_3 = ChannelMessages.getOrCreate(c29336_0);
ChannelMessages.commit(c29336_3.receivePushNotification(c29336_1, c29336_2));
c2637_31.emitChange();
break L17;
} catch ($e) {
let r32 = $e;
if (c25164_5 !== 0) {
while (true) {
try {
c25164_5 = 0;
c2637_25.log(r11, c29336_1.id, c29336_1.channel_id);
c29336_3 = ChannelMessages.getOrCreate(c29336_0);
ChannelMessages.commit(c29336_3.receivePushNotification(c29336_1, c29336_2));
c2637_31.emitChange();
break L15;
} catch ($e) {
r32 = $e;
if (c25164_5 === 0) {
break;
}
}
}
}
throw r32;
}
}
return void 0;
}
return void 0;
}
};
env2637[28] = r8;
return r8.apply(this, arguments);
};
receiveMediaMentionMessage = function receiveMediaMentionMessage(a0) {
if (a0.media_mention?.message_id != null) {
const attachment_id = a0.media_mention.attachment_id;
ChannelMessages.commit(ChannelMessages.getOrCreate(attachment_id).receiveMessage({
...a0,
channel_id: attachment_id,
type: MessageTypes.MEDIA_MENTION_MESSAGE,
id: a0.media_mention.message_id,
message_reference: {
channel_id: a0.channel_id,
message_id: a0.media_mention.message_id,
type: MessageReferenceTypes.DEFAULT,
guild_id: ChannelStore.getChannel(a0.channel_id)?.guild_id
}
}, false).mutate({
ready: true
}));
}
};
const handleCleanup = function handleCleanup() {
ChannelMessages.forEach(({ channelId }) => {
if (ChannelStore.getChannel(channelId) == null) {
ChannelMessages.clear(channelId);
}
});
};
const handleRelationshipUpdate = function handleRelationshipUpdate() {
let c14240_0 = false;
ChannelMessages.forEach((channelMessage) => {
ChannelMessages.commit(channelMessage.reset(channelMessage.map((item) => {
const blocked = item.blocked;
const isBlockedForMessage = RelationshipStore.isBlockedForMessage(item);
let r9 = item;
if (blocked !== isBlockedForMessage) {
c14240_0 = true;
r9 = item.set("blocked", RelationshipStore.isBlockedForMessage(item));
}
const ignored = r9.ignored;
const isIgnoredForMessage = RelationshipStore.isIgnoredForMessage(r9);
const r16 = r9;
let r17 = r16;
if (ignored !== isIgnoredForMessage) {
c14240_0 = true;
r17 = r16.set("ignored", RelationshipStore.isIgnoredForMessage(r16));
}
return r17;
})));
});
return c14240_0;
};
performAuthorUpdate = function performAuthorUpdate(a0) {
let env14241;
const r1 = env14241 = {
$parent: env2637
};
env14241[0] = a0;
ChannelMessages.forEach($mk74535(r1));
};
const handleReaction = function handleReaction(a0) {
let c14242_4;
let c14242_0 = a0;
const { type, channelId, messageId, userId, emoji, reactionType } = a0;
const r16 = ChannelMessages.get(channelId);
if (r16 == null) {
return false;
}
if (shouldApplyReaction(a0)) {
c14242_4 = AuthenticationStore.getId() === userId;
ChannelMessages.commit(r16.update(messageId, (a0) => type === "MESSAGE_REACTION_ADD" ? a0.addReaction(emoji, c14242_4, c14242_0.colors, reactionType) : a0.removeReaction(emoji, c14242_4, reactionType)));
return void 0;
}
return false;
};
const handleMessageSendFailedAutomod = function handleMessageSendFailedAutomod({ type: type2, messageData }) {
const message2 = messageData.message;
const failedMessageId = getFailedMessageId(messageData);
const orCreate2 = ChannelMessages.getOrCreate(message2.channelId);
if (orCreate2.has(failedMessageId)) {
ChannelMessages.commit(orCreate2.update(failedMessageId, (a0) => {
const embeds = a0.embeds;
const r16 = (embeds == null ? void 0 : embeds.filter(isNotAutomodEmbed).length) > 0 ? a0.set("embeds", []) : a0;
return type2 === "MESSAGE_SEND_FAILED_AUTOMOD" ? r16.set("flags", addFlag(r16.flags, MessageFlags.EPHEMERAL)) : r16;
}));
return void 0;
}
return false;
};
c2637_24 = new Set();
c2637_25 = new Logger("MessageStore");
env2637[26] = false;
class MessageStore extends Module589.Store {
static displayName = "MessageStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(AuthenticationStore, ChannelStore, DimensionStore, EphemeralMessageStore, GuildChannelStore, GuildMemberStore, GuildStore, ImpersonateStore, LocaleStore, PermissionStore, RelationshipStore, SelectedChannelStore, SelectedGuildStore, UserStore);
this.syncWith([ImpersonateStore], () => {});
}
getMessages(a0) {
if (ImpersonateStore.hasViewingRoles()) {
const channel = ChannelStore.getChannel(a0);
if (ImpersonateStore.isViewingRoles(channel == null ? void 0 : channel.getGuildId()) && !PermissionStore.can(Permissions.VIEW_CHANNEL, channel)) {
return new ChannelMessages(a0);
}
}
return ChannelMessages.getOrCreate(a0);
}
getMessage(a0, a1) {
return ChannelMessages.getOrCreate(a0).get(a1);
}
getLastEditableMessage(a0) {
const currentUser = UserStore.getCurrentUser();
return Module12(this.getMessages(a0).toArray()).reverse().find((item) => canEditMessage(item, currentUser?.id));
}
getLastChatCommandMessage(a0) {
const currentUser2 = UserStore.getCurrentUser();
return this.getMessages(a0).toArray().reverse().find((item) => item.interaction?.type === InteractionTypes.APPLICATION_COMMAND && item.interactionData?.type === ApplicationCommandType.CHAT && item.interaction.user.id === currentUser2?.id);
}
getLastMessage(a0) {
return Module12(this.getMessages(a0).toArray()).reverse().get(0);
}
getLastNonCurrentUserMessage(a0) {
const currentUser3 = UserStore.getCurrentUser();
return Module12(this.getMessages(a0).toArray()).reverse().find((item) => item.author.id !== currentUser3?.id);
}
jumpedMessageId(a0) {
return ChannelMessages.get(a0)?.jumpTargetId;
}
focusedMessageId(a0) {
return ChannelMessages.get(a0)?.focusTargetId;
}
hasPresent(a0) {
const r8 = ChannelMessages.get(a0);
return r8 != null && r8.ready && r8.hasPresent();
}
isReady(a0) {
return ChannelMessages.getOrCreate(a0).ready;
}
whenReady(c14247_1, c14247_0) {
this.addConditionalChangeListener(() => {
if (this.isReady(c14247_1)) {
setImmediate(c14247_0);
return false;
}
});
}
isLoadingMessages(a0) {
return ChannelMessages.getOrCreate(a0).loadingMore;
}
hasCurrentUserSentMessage(a0) {
const currentUser4 = UserStore.getCurrentUser();
return this.getMessages(a0).findNewest((a0) => a0.author.id === currentUser4?.id) != null;
}
hasCurrentUserSentWaveBlockingMessage(a0) {
const currentUser5 = UserStore.getCurrentUser();
return this.getMessages(a0).findNewest((a0) => a0.type !== MessageTypes.FRIEND_REQUEST_ACCEPTED && a0.author.id === currentUser5?.id) != null;
}
hasCurrentUserSentMessageSinceAppStart() {
return env2637[26];
}
}
c2637_32 = MessageStore;
c2637_31 = new MessageStore(Dispatcher, {
BACKGROUND_SYNC_CHANNEL_MESSAGES: function handleBackgroundSyncChannelMessages({ changesByChannelId }) {
for (const key in changesByChannelId) {
const r19 = ChannelMessages.get(key);
if (r19 != null) {
const isConnected = _GatewayConnectionStore.default.isConnected();
if (!r19.cached && isConnected) {
c2637_25.log(`Skipping background message sync for ${key} cached:${r19.cached} ready:${r19.ready} hasMoreAfter:${r19.hasMoreAfter} isConnected:${isConnected}`);
continue;
}
r19.mergeDelta(changesByChannelId[key].new_messages, changesByChannelId[key].modified_messages, changesByChannelId[key].deleted_message_ids);
}
}
},
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
CACHE_LOADED: function handleCacheLoaded(a0) {
for (const item of SnowflakeUtils.entries(a0.messages)) {
const [r11, r10] = item;
ChannelMessages.commit(ChannelMessages.getOrCreate(r11).addCachedMessages(r10, true));
}
},
LOAD_MESSAGES: function handleLoadMessages() {
return true;
},
LOAD_MESSAGES_SUCCESS: function handleLoadMessagesSuccess({ channelId, isBefore, isAfter, jump, hasMoreBefore, hasMoreAfter, messages, isStale, truncate, avoidInitialScroll }) {
const r33 = ChannelMessages.getOrCreate(channelId).loadComplete({
newMessages: messages,
isBefore,
isAfter,
jump,
hasMoreBefore,
hasMoreAfter,
cached: isStale,
hasFetched: true,
avoidInitialScroll
});
ChannelMessages.commit(reinjectEphemerals(channelId, truncate == null || (isBefore ? !isBefore : !isAfter) || isBefore && isAfter ? r33 : r33.truncate(isBefore, isAfter)));
for (const item of messages) {
receiveMediaMentionMessage(item);
}
},
LOAD_MESSAGES_FAILURE: function handleLoadMessagesFailure(a0) {
ChannelMessages.commit(ChannelMessages.getOrCreate(a0.channelId).mutate({
loadingMore: false,
error: true
}));
},
LOAD_MESSAGES_SUCCESS_CACHED: function handleLoadMessagesSuccessCached({ channelId, jump, focus, before, after, limit, truncate }) {
const orCreate2 = ChannelMessages.getOrCreate(channelId);
const r30 = jump?.present ? orCreate2.jumpToPresent(limit) : focus?.messageId != null ? orCreate2.focusOnMessage(focus.messageId) : jump?.messageId != null ? orCreate2.jumpToMessage({
messageId: jump.messageId,
flash: jump.flash,
offset: jump.offset,
returnTargetId: jump.returnMessageId,
jumpType: jump.jumpType,
onJumpComplete: jump.onJumpComplete
}) : before == null && after == null ? orCreate2 : orCreate2.loadFromCache(before != null, limit);
const r43 = truncate == null || before == null && after == null || before != null && after != null ? r30 : r30.truncate(before != null, after != null);
let env14250;
const r47 = env14250 = {
$parent: env2637
};
env14250[0] = r43;
const hasMoreAfter = r43.hasMoreAfter;
let r49 = r43;
if (!hasMoreAfter) {
const messages = EphemeralMessageStore.getMessages(channelId);
const length = messages.length;
r49 = r43;
if (length !== 0) {
const r56 = messages.filter($mk74529(r47));
env14250[1] = r56;
r49 = r56.length !== 0 ? r43.mutate($mk74530(r47), true) : r43;
}
}
ChannelMessages.commit(r49);
},
LOCAL_MESSAGES_LOADED: function handleLocalMessagesLoaded(a0) {
const orCreate2 = ChannelMessages.getOrCreate(a0.channelId);
if (!(!a0.isForegroundCacheLoad && (!orCreate2.cached && orCreate2.ready))) {
const r18 = orCreate2.addCachedMessages(a0.messages, a0.stale);
ChannelMessages.commit(a0.isForegroundCacheLoad && a0.messages.length > 0 && r18.jumpTargetId == null ? r18.mutate({
initialScrollSequenceId: r18.initialScrollSequenceId + 1,
suppressRowAnimationSequenceId: r18.suppressRowAnimationSequenceId + 1
}) : r18);
}
},
LOAD_MESSAGE_INTERACTION_DATA_SUCCESS: function handleLoadMessageInteractionDataSuccess(a0) {
let c14251_0 = a0;
const messageId = a0.messageId;
const r12 = ChannelMessages.get(a0.channelId);
if (r12 != null && r12.has(messageId)) {
ChannelMessages.commit(r12.update(messageId, (a0) => a0.set("interactionData", c14251_0.interactionData)));
return void 0;
}
return false;
},
TRUNCATE_MESSAGES: function handleTruncateMessages({ channelId, truncateBottom, truncateTop }) {
c2637_25.log(`Truncating messages for ${channelId} bottom:${truncateBottom} top:${truncateTop}`);
ChannelMessages.commit(ChannelMessages.getOrCreate(channelId).truncate(truncateBottom, truncateTop));
},
CLEAR_MESSAGES: function handleClearMessages({ channelId }) {
c2637_25.log(`Clearing messages for ${channelId}`);
ChannelMessages.clear(channelId);
c2637_24.clear();
},
MESSAGE_CREATE: function handleIncomingMessage({ channelId, message: message2, optimistic, isPushNotification }) {
let r26, r72;
const orCreate2 = ChannelMessages.getOrCreate(channelId);
const isConnected = _GatewayConnectionStore.default.isConnected();
if (isPushNotification) {
if (isIOSPushNotificationRawPayloadFixExperimentEnabled()) {
(function addPushNotificationMessageIfNotCached() {
return env2637[28].apply(this, arguments);
})(channelId, message2, isConnected);
r72 = false;
} else {
c2637_25.log("Inserting message tapped on from a push notification", message2.id, message2.channel_id);
ChannelMessages.commit(orCreate2.receivePushNotification(message2, isConnected));
r72 = void 0;
}
r26 = r72;
} else {
r26 = !!orCreate2.ready;
if (r26) {
let r1 = optimistic ? !orCreate2.has(message2.id) : !optimistic;
if (r1) {
const r31 = message2.nonce != null && message2.state !== MessageStates.SENDING && c2637_24.has(message2.nonce);
let r37 = orCreate2;
if (r31) {
r37 = orCreate2.remove(message2.nonce);
c2637_24.delete(message2.nonce);
}
ChannelMessages.commit(r37.receiveMessage(message2, DimensionStore.isAtBottom(channelId) === true));
receiveMediaMentionMessage(message2);
r1 = void 0;
}
r26 = r1;
}
}
return r26;
},
MESSAGE_SEND_FAILED: function handleSendFailed({ channelId, messageId, reason }) {
const orCreate2 = ChannelMessages.getOrCreate(channelId);
if (orCreate2 != null && orCreate2.has(messageId)) {
const r10 = orCreate2.get(messageId, true);
ChannelMessages.commit((r10 == null ? void 0 : r10.isPoll()) === true ? orCreate2.remove(messageId) : orCreate2.update(messageId, (a0) => {
let r12;
const r9 = a0.set("state", MessageStates.SEND_FAILED);
if (r9.isCommandType()) {
let r16 = reason;
if (reason == null) {
r16 = "";
}
const r19 = r9.set("interactionError", r16);
r12 = r19.set("flags", addFlag(r19.flags, MessageFlags.EPHEMERAL));
} else {
let r7 = reason;
r12 = r9;
if (reason != null) {
if (reason == null) {
r7 = "";
}
r12 = r9.set("interactionError", r7);
}
}
return r12;
}));
return void 0;
}
return false;
},
MESSAGE_SEND_FAILED_AUTOMOD: handleMessageSendFailedAutomod,
MESSAGE_EDIT_FAILED_AUTOMOD: handleMessageSendFailedAutomod,
MESSAGE_UPDATE: function handleMessageUpdate(a0) {
let c14253_0 = a0;
const id = a0.message.id;
const orCreate2 = ChannelMessages.getOrCreate(a0.message.channel_id);
if (orCreate2 != null && orCreate2.has(id)) {
let message;
ChannelMessages.commit(orCreate2.update(id, (a0) => updateMessageRecord(a0, c14253_0.message)));
message = a0.message;
if (message.media_mention?.message_id != null && "content" in message) {
ChannelMessages.commit(ChannelMessages.getOrCreate(message.media_mention.attachment_id).update(message.media_mention.message_id, (a0) => updateMessageRecord(a0, {
content: message.content
})));
}
return void 0;
}
return false;
},
MESSAGE_EXPLICIT_CONTENT_SCAN_TIMEOUT: function handleMessageExplicitContentScanTimeout(a0) {
const messageId = a0.messageId;
const r11 = ChannelMessages.get(a0.channelId);
if (r11 != null && r11.has(messageId)) {
ChannelMessages.commit(r11.update(messageId, handleExplicitMediaScanTimeoutForMessage));
return void 0;
}
return false;
},
MESSAGE_DELETE: function handleMessageDelete(a0) {
const id = a0.id;
const orCreate2 = ChannelMessages.getOrCreate(a0.channelId);
if (orCreate2 != null && orCreate2.has(id)) {
const revealedMessageId = orCreate2.revealedMessageId;
let r18 = orCreate2;
if (revealedMessageId === id) {
const after = orCreate2.getAfter(id);
r18 = after != null && after.blocked ? orCreate2.mutate({
revealedMessageId: after.id
}) : orCreate2.mutate({
revealedMessageId: null
});
}
const r27 = r18.get(id);
if (r27 != null) {
const attachment_id = r27.mediaMention?.attachment_id;
if (attachment_id != null) {
const r33 = ChannelMessages.get(attachment_id);
if (r33 != null) {
const message_id = r27.mediaMention?.message_id;
if (message_id != null) {
ChannelMessages.commit(r33.remove(message_id));
}
}
}
}
ChannelMessages.commit(r18.remove(id));
c2637_24.delete(id);
return void 0;
}
return false;
},
MESSAGE_DELETE_BULK: function handleMessageDeleteBulk({ ids, channelId }) {
let c14255_1;
c14255_1 = void 0;
const orCreate = ChannelMessages.getOrCreate(channelId);
if (orCreate == null) {
return false;
}
ids.forEach((id) => {
const r10 = orCreate.get(id);
if (r10 != null) {
const attachment_id = r10.mediaMention?.attachment_id;
if (attachment_id != null) {
const r16 = ChannelMessages.get(attachment_id);
if (r16 != null) {
const message_id = r10.mediaMention?.message_id;
if (message_id != null) {
ChannelMessages.commit(r16.remove(message_id));
}
}
}
}
});
const r11 = orCreate.removeMany(ids);
c14255_1 = r11;
if (orCreate === r11) {
return false;
}
const revealedMessageId = r11.revealedMessageId;
let r21 = r11;
if (revealedMessageId != null) {
const r25 = Module12.some(ids, (a0) => c14255_1.revealedMessageId === a0);
r21 = r11;
if (r25) {
const after = r11.getAfter(r11.revealedMessageId);
const r31 = after != null && after.blocked ? r11.mutate({
revealedMessageId: after.id
}) : r11.mutate({
revealedMessageId: null
});
c14255_1 = r31;
r21 = r31;
}
}
ChannelMessages.commit(r21);
ids.forEach((id) => {
c2637_24.delete(id);
});
},
MESSAGE_REVEAL: function handleMessageReveal({ channelId, messageId }) {
ChannelMessages.commit(ChannelMessages.getOrCreate(channelId).mutate({
revealedMessageId: messageId
}));
},
THREAD_CREATE_LOCAL: function handleThreadCreateLocal(a0) {
ChannelMessages.commit(ChannelMessages.getOrCreate(a0.channelId).loadComplete({
newMessages: [],
hasMoreAfter: false,
hasMoreBefore: false
}));
},
CHANNEL_DELETE: handleCleanup,
THREAD_DELETE: handleCleanup,
GUILD_DELETE: handleCleanup,
RELATIONSHIP_ADD: handleRelationshipUpdate,
RELATIONSHIP_UPDATE: handleRelationshipUpdate,
RELATIONSHIP_REMOVE: handleRelationshipUpdate,
GUILD_MEMBERS_CHUNK_BATCH: function handleGuildMembersChunkBatch(a0) {
for (const chunk of a0.chunks) {
performAuthorUpdate(chunk.guildId);
}
},
THREAD_MEMBER_LIST_UPDATE: function handleThreadMemberListUpdate({ guildId }) {
let env14256;
const r4 = env14256 = {
$parent: env2637
};
env14256[0] = guildId;
ChannelMessages.forEach($mk74535(r4));
},
MESSAGE_REACTION_ADD: handleReaction,
MESSAGE_REACTION_ADD_MANY: function handleReactionBatch({ channelId, messageId, reactions }) {
const r13 = ChannelMessages.get(channelId);
if (r13 == null) {
return false;
}
ChannelMessages.commit(r13.update(messageId, (a0) => a0.addReactionBatch.call(a0, reactions, UserStore.getCurrentUser()?.id)));
},
MESSAGE_REACTION_REMOVE: handleReaction,
MESSAGE_REACTION_REMOVE_ALL: function handleRemoveAllReactions({ channelId, messageId }) {
const r11 = ChannelMessages.get(channelId);
if (r11 == null) {
return false;
}
ChannelMessages.commit(r11.update(messageId, (a0) => a0.set("reactions", [])));
},
MESSAGE_REACTION_REMOVE_EMOJI: function handleRemoveEmojiReactions({ channelId, messageId, emoji: emoji2 }) {
const r13 = ChannelMessages.get(channelId);
if (r13 == null) {
return false;
}
ChannelMessages.commit(r13.update(messageId, (a0) => a0.removeReactionsForEmoji(emoji2)));
},
LOGOUT: function handleLogout() {
ChannelMessages.forEach((channelMessage) => {
ChannelMessages.clear(channelMessage.channelId);
});
c2637_24.clear();
},
UPLOAD_START: function handleUploadStart({ message: message2 }) {
if (message2?.nonce != null) {
c2637_24.add(message2.nonce);
}
},
UPLOAD_FAIL: function handleUploadFail({ channelId, messageId }) {
if (messageId == null) {
return false;
}
if (c2637_24.has(messageId)) {
const orCreate2 = ChannelMessages.getOrCreate(channelId);
const r9 = orCreate2.get(messageId);
if (r9 == null) {
return false;
}
const r22 = orCreate2.remove(messageId).merge([r9]);
c2637_24.delete(messageId);
ChannelMessages.commit(r22);
return void 0;
}
return false;
},
LOCAL_MESSAGE_CREATE: function handleLocalIncomingMesssage({ message: message2 }) {
const currentUser6 = UserStore.getCurrentUser();
if (message2 != null && message2.author != null && currentUser6 != null && message2.author.id === currentUser6.id) {
env2637[26] = true;
}
}
});
export default c2637_31;
+46
View File
@@ -0,0 +1,46 @@
// Metro module 1220 (f1221).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
import Module38 from "../_bundle/Module38";
import { Storage } from "../_bundle/Module595";
class MobileCacheSnapshotStore extends Module589.Store {
static allStores = [];
constructor(a0, a1) {
const r10 = {
...a0,
CLEAR_CACHES: () => {
this.clear();
return false;
},
WRITE_CACHES: () => {
this.save();
return false;
}
};
super(Dispatcher, r10, a1);
Module38(this.getClass().displayName != null, "Snapshot stores need a display name");
Module38(!("CLEAR_CACHES" in a0), "MobileCacheSnapshotStores cannot use the 'CLEAR_CACHES' action");
Module38(!("WRITE_CACHES" in a0), "MobileCacheSnapshotStores cannot use the 'WRITE_CACHES' action");
MobileCacheSnapshotStore.allStores.push(this);
}
static clearAll() {
MobileCacheSnapshotStore.allStores.forEach((allStore) => allStore.clear());
}
get persistKey() {
return `${this.getClass().displayName}-snapshot`;
}
clear() {
Storage.remove(this.persistKey);
}
save() {
Storage.set(this.persistKey, this.takeSnapshot());
}
readSnapshot(a0) {
const r12 = Storage.get(this.persistKey);
return r12 == null ? null : r12.version === a0 ? r12.data : null;
}
getClass() {
return this.constructor;
}
}
export default MobileCacheSnapshotStore;
+37
View File
@@ -0,0 +1,37 @@
// Metro module 4281 (f4282).
import { NetworkConnectionSpeeds, NetworkConnectionTypes } from "../Constants";
import Module589 from "../_bundle/Module589";
import NetworkUtils from "../utils/NetworkUtils";
import Dispatcher from "../Dispatcher";
let UNKNOWN, UNKNOWN2, serviceProvider, c2520_8;
const handleConnectionInfoChange = function handleConnectionInfoChange(a0) {
UNKNOWN = a0.type != null ? a0.type : NetworkConnectionTypes.UNKNOWN;
let effectiveSpeed = a0.effectiveSpeed;
if (effectiveSpeed == null) {
effectiveSpeed = NetworkConnectionSpeeds.UNKNOWN;
}
UNKNOWN2 = effectiveSpeed;
serviceProvider = a0.serviceProvider;
c2520_8.emitChange();
};
UNKNOWN = NetworkConnectionTypes.UNKNOWN;
UNKNOWN2 = NetworkConnectionSpeeds.UNKNOWN;
serviceProvider = null;
class NetworkStoreClass extends Module589.Store {
static displayName = "NetworkStore";
initialize() {
NetworkUtils.getNetworkInformation().then(handleConnectionInfoChange);
NetworkUtils.addChangeCallback(handleConnectionInfoChange);
}
getType() {
return UNKNOWN;
}
getEffectiveConnectionSpeed() {
return UNKNOWN2;
}
getServiceProvider() {
return serviceProvider;
}
}
c2520_8 = new NetworkStoreClass(Dispatcher, {});
export default c2520_8;
+54
View File
@@ -0,0 +1,54 @@
// Metro module 16338 (f16339).
import { isGuildSelectableChannelType } from "../records/ChannelRecord";
import GuildCategoryStore from "./GuildCategoryStore";
import GuildChannelStore from "./GuildChannelStore";
import GuildMemberCountStore from "./GuildMemberCountStore";
import GuildStore from "./GuildStore";
import UserGuildSettingsStore from "./UserGuildSettingsStore";
import { ChannelTypes, FormStates } from "../Constants";
import Module589 from "../_bundle/Module589";
import getFlattedChannelList from "../modules/channel/getFlattedChannelList";
import Dispatcher from "../Dispatcher";
let guildId;
let CLOSED = FormStates.CLOSED;
class NotificationSettingsModalStore extends Module589.Store {
static displayName = "NotificationSettingsModalStore";
initialize() {
this.waitFor(GuildCategoryStore, GuildChannelStore, GuildMemberCountStore, GuildStore, UserGuildSettingsStore);
this.syncWith([UserGuildSettingsStore, GuildChannelStore, GuildStore], () => this.isOpen());
}
isOpen() {
return CLOSED !== FormStates.CLOSED;
}
getProps() {
const categories = GuildCategoryStore.getCategories(guildId);
return {
guildId,
categories,
guild: GuildStore.getGuild(guildId),
memberCount: GuildMemberCountStore.getMemberCount(guildId),
suppressEveryone: UserGuildSettingsStore.isSuppressEveryoneEnabled(guildId),
suppressRoles: UserGuildSettingsStore.isSuppressRolesEnabled(guildId),
mobilePush: UserGuildSettingsStore.isMobilePushEnabled(guildId),
muted: UserGuildSettingsStore.isMuted(guildId),
muteConfig: UserGuildSettingsStore.getMuteConfig(guildId),
messageNotifications: UserGuildSettingsStore.getMessageNotifications(guildId),
channelOverrides: UserGuildSettingsStore.getChannelOverrides(guildId),
channels: getFlattedChannelList(categories._categories, categories, (a0) => {
const type = a0.channel.type;
return isGuildSelectableChannelType(type) || type === ChannelTypes.GUILD_CATEGORY;
})
};
}
}
const notificationSettingsModalStore = new NotificationSettingsModalStore(Dispatcher, {
NOTIFICATION_SETTINGS_MODAL_OPEN: function handleFormOpen({ guildId: guildId2 }) {
CLOSED = FormStates.OPEN;
guildId = guildId2;
},
NOTIFICATION_SETTINGS_MODAL_CLOSE: function handleFormClose() {
CLOSED = FormStates.CLOSED;
guildId = null;
}
});
export default notificationSettingsModalStore;
+106
View File
@@ -0,0 +1,106 @@
// Metro module 10245 (f10246).
import { DesktopNotificationTypes, NotificationPermissionTypes, TTSNotificationTypes } from "../Constants";
import { isPlatformEmbedded } from "../utils/PlatformUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c6834_5, c6834_6;
const desktopType = isPlatformEmbedded ? DesktopNotificationTypes.ALL : DesktopNotificationTypes.NEVER;
const handleSetDesktopType = function handleSetDesktopType(a0) {
c6834_6.desktopType = a0.desktopType;
};
c6834_5 = {
desktopType,
disableAllSounds: false,
disabledSounds: [],
ttsType: TTSNotificationTypes.NEVER,
disableUnreadBadge: false,
taskbarFlash: true,
notifyMessagesInSelectedChannel: false,
screenDowntimeReminder: true
};
c6834_6 = c6834_5;
class NotificationSettingsStore extends Module589.DeviceSettingsStore {
static displayName = "NotificationSettingsStore";
static persistKey = "notifications";
static migrations = [(a0) => {
const r1 = {
...a0
};
r1.disabledSounds = r1.disabledSounds || [];
r1.disableUnreadBadge = r1.disableUnreadBadge || false;
r1.taskbarFlash = r1.taskbarFlash == null || r1.taskbarFlash;
r1.ttsType = r1.ttsType || TTSNotificationTypes.NEVER;
if (r1.desktopType == null) {
r1.desktopType = isPlatformEmbedded ? DesktopNotificationTypes.ALL : DesktopNotificationTypes.NEVER;
}
return r1;
}];
initialize(a0) {
c6834_6 = {
...c6834_5,
...a0
};
}
getUserAgnosticState() {
return c6834_6;
}
getDesktopType() {
return c6834_6.desktopType;
}
getTTSType() {
return c6834_6.ttsType;
}
getDisabledSounds() {
return c6834_6.disabledSounds;
}
getDisableAllSounds() {
return c6834_6.disableAllSounds;
}
getDisableUnreadBadge() {
return c6834_6.disableUnreadBadge;
}
getNotifyMessagesInSelectedChannel() {
return c6834_6.notifyMessagesInSelectedChannel;
}
get taskbarFlash() {
return c6834_6.taskbarFlash;
}
get screenDowntimeReminder() {
return c6834_6.screenDowntimeReminder;
}
isSoundDisabled(a0) {
return c6834_6.disableAllSounds || c6834_6.disabledSounds.indexOf(a0) !== -1;
}
}
const notificationSettingsStore = new NotificationSettingsStore(Dispatcher, {
NOTIFICATIONS_SET_DESKTOP_TYPE: handleSetDesktopType,
NOTIFICATIONS_SET_TTS_TYPE: function handleSetTTSType(a0) {
c6834_6.ttsType = a0.ttsType;
},
NOTIFICATIONS_SET_DISABLED_SOUNDS: function handleSetDisabledSounds(a0) {
c6834_6.disabledSounds = a0.sounds;
},
NOTIFICATIONS_TOGGLE_ALL_DISABLED: function handleToggleAllDisabled() {
c6834_6.disableAllSounds = !c6834_6.disableAllSounds;
},
NOTIFICATIONS_SET_PERMISSION_STATE: function handleSetHavePermission({ enabled }) {
if (enabled === NotificationPermissionTypes.BLOCKED) {
c6834_6.desktopType = DesktopNotificationTypes.NEVER;
} else if (enabled === NotificationPermissionTypes.ENABLED) {
c6834_6.desktopType = DesktopNotificationTypes.ALL;
}
},
NOTIFICATIONS_SET_DISABLE_UNREAD_BADGE: function handleSetDisableUnreadBadge(a0) {
c6834_6.disableUnreadBadge = a0.disableUnreadBadge;
},
NOTIFICATIONS_SET_TASKBAR_FLASH: function handleSetTaskbarFlash(a0) {
c6834_6.taskbarFlash = a0.taskbarFlash;
},
NOTIFICATIONS_SET_NOTIFY_MESSAGES_IN_SELECTED_CHANNEL: function handleSetNotifyMessagesInSelectedChannel(a0) {
c6834_6.notifyMessagesInSelectedChannel = a0.notify;
},
NOTIFICATIONS_SET_SCREEN_DOWNTIME_REMINDER: function handleSetScreenDowntimeReminder(a0) {
c6834_6.screenDowntimeReminder = a0.screenDowntimeReminder;
}
});
export default notificationSettingsStore;
+233
View File
@@ -0,0 +1,233 @@
// Metro module 12800 (f12801).
import UserAffinitiesV2Store from "../modules/user_affinities/UserAffinitiesV2Store";
import PresenceStore from "./PresenceStore";
import UserStore from "./UserStore";
import { ActivityTypes } from "../Constants";
import getApplicationIdForActivity from "../modules/now_playing/getApplicationIdForActivity";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
function $mk90427($env) {
return (a0) => {
const r3 = $env;
r3[0] = (0, $env.$parent[9])(a0) !== false || r3[0];
};
}
let handleUserAffinitiesV2StoreUpdate, c8827_11;
let env8827 = {};
const _handlePresenceUpdate = function _handlePresenceUpdate({ user, activities }) {
let c20223_1;
c20223_1 = void 0;
if (user == null) {
return false;
}
const r13 = activities.filter((activity) => activity.type !== ActivityTypes.CUSTOM_STATUS);
if (r13.length === 0) {
const id = user.id;
const r22 = env8827[8][id];
const r3 = r22 == null;
let r23 = false;
if (!r3) {
const gameId = r22.gameId;
if (env8827[7][gameId] != null) {
const r27 = {
...env8827[7]
};
env8827[7] = r27;
delete r27[gameId][id];
if (Object.values(env8827[7][gameId]).length === 0) {
delete env8827[7][gameId];
}
}
const r40 = {
...env8827[8]
};
env8827[8] = r40;
delete r40[id];
r23 = true;
}
return r23;
}
c20223_1 = false;
r13.forEach((item) => {
let r70;
const applicationIdForActivity = getApplicationIdForActivity(item);
if (applicationIdForActivity == null) {
const id2 = user.id;
const r73 = env8827[8][id2];
const r5 = r73 == null;
let r2 = false;
if (!r5) {
const gameId2 = r73.gameId;
if (env8827[7][gameId2] != null) {
const r77 = {
...env8827[7]
};
env8827[7] = r77;
delete r77[gameId2][id2];
if (Object.values(env8827[7][gameId2]).length === 0) {
delete env8827[7][gameId2];
}
}
const r93 = {
...env8827[8]
};
env8827[8] = r93;
delete r93[id2];
r2 = true;
}
r70 = r2;
} else {
const r22 = env8827[8][user.id];
if (r22 != null && r22.gameId !== applicationIdForActivity) {
const id = user.id;
const r26 = env8827[8][id];
if (r26 != null) {
const gameId = r26.gameId;
if (env8827[7][gameId] != null) {
const r29 = {
...env8827[7]
};
env8827[7] = r29;
delete r29[gameId][id];
if (Object.values(env8827[7][gameId]).length === 0) {
delete env8827[7][gameId];
}
}
const r40 = {
...env8827[8]
};
env8827[8] = r40;
delete r40[id];
}
}
let startedPlaying = item.timestamps?.start;
if (startedPlaying == null) {
startedPlaying = Date.now();
}
const r52 = {
userId: user.id,
activity: item,
startedPlaying
};
const r53 = {
...env8827[7]
};
const r57 = {
...env8827[7][applicationIdForActivity]
};
r57[r52.userId] = r52;
r53[applicationIdForActivity] = r57;
env8827[7] = r53;
const r63 = {
...env8827[8]
};
r63[r52.userId] = {
gameId: applicationIdForActivity,
startedPlaying: r52.startedPlaying
};
env8827[8] = r63;
r70 = true;
}
if (r70) {
c20223_1 = true;
}
});
return c20223_1;
};
handleUserAffinitiesV2StoreUpdate = function handleUserAffinitiesV2StoreUpdate() {
const r8 = UserAffinitiesV2Store.shouldFetch() || env8827[6];
let r0 = false;
if (!r8) {
env8827[7] = {};
env8827[8] = {};
let c20224_0 = false;
PresenceStore.getUserIds().forEach((item) => {
const user2 = UserStore.getUser(item);
if (user2 != null) {
c20224_0 = _handlePresenceUpdate({
user: user2,
activities: PresenceStore.getActivities(item)
}) || c20224_0;
}
});
r0 = c20224_0;
}
env8827[6] = !UserAffinitiesV2Store.shouldFetch();
return r0;
};
env8827[6] = false;
env8827[7] = {};
env8827[8] = {};
class NowPlayingStore extends Module589.Store {
static displayName = "NowPlayingStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(PresenceStore, UserAffinitiesV2Store, UserStore);
this.syncWith([UserAffinitiesV2Store], handleUserAffinitiesV2StoreUpdate);
}
get games() {
return env8827[7];
}
get usersPlaying() {
return env8827[8];
}
get gameIds() {
return Object.keys(env8827[7]);
}
getNowPlaying(a0) {
return env8827[7][a0];
}
getUserGame(a0) {
return env8827[8][a0];
}
}
c8827_11 = NowPlayingStore;
const r56 = new NowPlayingStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
env8827[7] = {};
env8827[8] = {};
},
CONNECTION_OPEN_SUPPLEMENTAL: function handleConnectionOpenSupplemental({ guilds, presences }) {
let env20226;
let c20225_0 = false;
guilds.forEach(({ presences }) => {
let env27368;
const r6 = env27368 = {
$parent: env8827
};
env27368[0] = false;
presences.forEach($mk90427(r6));
if (env27368[0]) {
c20225_0 = true;
}
});
const r8 = env20226 = {
$parent: env8827
};
env20226[0] = false;
presences.forEach($mk90427(r8));
if (env20226[0]) {
c20225_0 = true;
}
return c20225_0;
},
LOGOUT: function handleLogout() {
env8827[7] = {};
env8827[8] = {};
},
PRESENCE_UPDATES: function handlePresenceUpdates(a0) {
return a0.updates.map((update) => _handlePresenceUpdate(update)).some((item) => item);
},
PRESENCES_REPLACE: function handlePresencesReplace({ presences }) {
let env20227;
const r5 = env20227 = {
$parent: env8827
};
env20227[0] = false;
presences.forEach($mk90427(r5));
return env20227[0];
}
});
export default r56;
+71
View File
@@ -0,0 +1,71 @@
// Metro module 12804 (f12805).
import ChannelStore from "./ChannelStore";
import GuildStore from "./GuildStore";
import { Storage } from "../_bundle/Module595";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let sessionId, channelId;
let c8831_6 = "hideSuppressWarning";
const suppress = false;
let c8831_8 = true;
let c8831_9 = false;
class PermissionSpeakStore extends Module589.Store {
static displayName = "PermissionSpeakStore";
initialize() {
this.waitFor(ChannelStore, GuildStore);
c8831_9 = Storage.get(c8831_6) || c8831_9;
}
isAFKChannel() {
const channel = ChannelStore.getChannel(channelId);
if (channel == null) {
return false;
}
const guild = GuildStore.getGuild(channel.getGuildId());
return guild != null && channel.id === guild.afkChannelId;
}
shouldShowWarning() {
const channel = ChannelStore.getChannel(channelId);
const r8 = channel == null ? void 0 : channel.isGuildStageVoice();
return r8 ? !r8 : !c8831_8;
}
}
const permissionSpeakStore = new PermissionSpeakStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
sessionId = a0.sessionId;
suppress = false;
},
CONNECTION_CLOSED: function handleConnectionClosed() {
sessionId = null;
channelId = null;
c8831_8 = true;
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((r1, voiceState) => {
if (sessionId === voiceState.sessionId) {
if (suppress !== voiceState.suppress) {
suppress = voiceState.suppress;
c8831_8 = !suppress;
}
if (channelId !== voiceState.channelId) {
channelId = voiceState.channelId;
c8831_8 = !suppress;
}
const r14 = c8831_9 || voiceState.channelId == null;
r1 = true;
if (r14) {
c8831_8 = true;
r1 = true;
}
}
return r1;
}, false);
},
PERMISSION_CLEAR_SUPPRESS_WARNING: function handleClearWarning({ forever }) {
c8831_8 = true;
if (forever) {
c8831_9 = true;
Storage.set(c8831_6, c8831_9);
}
}
});
export default permissionSpeakStore;
+525
View File
@@ -0,0 +1,525 @@
// Metro module 3817 (f3818).
import ImpersonateStore from "../modules/impersonate/ImpersonateStore";
import LurkingStore from "../modules/lurker_mode/LurkingStore";
import StageInstanceStore from "../modules/stage_channels/StageInstanceStore";
import JoinedThreadsStore from "../modules/threads/JoinedThreadsStore";
import { ChannelRecordBase, THREAD_CHANNEL_TYPES } from "../records/ChannelRecord";
import { isGuildOwner, isGuildOwnerWithRequiredMfaLevel } from "../records/GuildRecord";
import UserRecord from "../records/UserRecord";
import ChannelStore from "./ChannelStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildStore from "./GuildStore";
import UserStore from "./UserStore";
import { Permissions } from "../Constants";
import { MemberSafetyPagePermissions } from "../modules/guild_mod_dash_member_safety/MemberSafetyConstants";
import * as _PermissionUtils from "../utils/PermissionUtils";
import { applyThreadPermissions, VIEW_GUILD_SETTINGS } from "../utils/PermissionUtils";
import Module12 from "../_bundle/Module12";
import { doesThreadMembersActionAffectMe } from "../modules/threads/ThreadActionUtils";
import { isGuildRecord } from "../utils/GuildRecordUtils";
import Module589 from "../_bundle/Module589";
import { hasAny, has } from "../_bundle/HighLow";
import BasicPermissionUtils from "../utils/BasicPermissionUtils";
import Dispatcher from "../Dispatcher";
let c2156_19, c2156_20, c2156_21, c2156_22, updateGuildVersion, computePermissions2;
const getUncachedChannelPermissions = function getUncachedChannelPermissions(a0, checkElevated = true) {
let r35, NONE;
const currentUser = UserStore.getCurrentUser();
if (currentUser == null) {
return _PermissionUtils.NONE;
}
const channel = ChannelStore.getChannel(a0);
if (channel == null) {
return _PermissionUtils.NONE;
}
const guildId = channel.getGuildId();
const r18 = guildId != null && (LurkingStore.isLurking(guildId) || GuildMemberStore.getMember(guildId, currentUser.id)?.isPending);
L23: {
if (!channel.isScheduledForDeletion() && (!r18 && (Module12.isEmpty(channel.permissionOverwrites) && guildId != null))) {
r35 = c2156_19[guildId];
if (r35 != null) {
break L23;
}
const currentUser2 = UserStore.getCurrentUser();
if (currentUser2 == null) {
r35 = _PermissionUtils.NONE;
break L23;
}
const guild = GuildStore.getGuild(guildId);
if (guild == null) {
NONE = _PermissionUtils.NONE;
} else {
NONE = _PermissionUtils.computePermissions({
user: currentUser2,
context: guild,
checkElevated: true
});
c2156_19[guildId] = NONE;
}
r35 = NONE;
} else {
r35 = _PermissionUtils.computePermissions({
user: currentUser,
context: channel,
checkElevated
});
}
}
return r35;
};
updateGuildVersion = function updateGuildVersion(a0) {
if (a0 != null) {
let r5 = c2156_21[a0];
if (r5 == null) {
r5 = 0;
}
c2156_21[a0] = r5 + 1;
}
};
const handleConnectionOpen = function handleConnectionOpen() {
c2156_19 = {};
c2156_20 = {};
for (const key in c2156_21) {
c2156_21[key] = c2156_21[key] + 1;
}
c2156_22 = c2156_22 + 1;
};
const handleGuild = function handleGuild() {
c2156_19 = {};
c2156_20 = {};
for (const key in c2156_21) {
c2156_21[key] = c2156_21[key] + 1;
}
c2156_22 = c2156_22 + 1;
};
const handleGuildMemberUpdate = function handleGuildMemberUpdate(a0) {
if (a0.user.id !== UserStore.getCurrentUser()?.id) {
return false;
}
c2156_19 = {};
c2156_20 = {};
for (const key in c2156_21) {
c2156_21[key] = c2156_21[key] + 1;
}
c2156_22 = c2156_22 + 1;
};
const handleThreadAction = function handleThreadAction() {
return true;
};
const handleSearchMessagesSuccess = function handleSearchMessagesSuccess(a0) {
return a0.data.some((a0) => {
const messages = a0.messages;
return a0.threads.length > 0 || messages.some((message) => message.some((item) => item.thread != null));
});
};
const handleGuildRole = function handleGuildRole({ guildId }) {
delete c2156_19[guildId];
Module12.forEach(ChannelStore.getMutableBasicGuildChannelsForGuild(guildId), (a0) => {
delete c2156_20[a0.id];
});
c2156_22 = c2156_22 + 1;
if (guildId != null) {
let r21 = c2156_21[guildId];
if (r21 == null) {
r21 = 0;
}
c2156_21[guildId] = r21 + 1;
}
};
const handleStageInstancesChanged = function handleStageInstancesChanged(a0) {
const channel = ChannelStore.getChannel(a0.instance.channel_id);
if (channel == null) {
return false;
}
const r20 = _PermissionUtils.computePermissions({
user: UserStore.getCurrentUser(),
context: channel
});
if (r20 === c2156_20[channel.id]) {
return false;
}
c2156_20[channel.id] = r20;
c2156_22 = c2156_22 + 1;
};
const handleImpersonateUpdate = function handleImpersonateUpdate({ guildId }) {
delete c2156_19[guildId];
Module12.forEach(ChannelStore.getMutableBasicGuildChannelsForGuild(guildId), (a0) => {
delete c2156_20[a0.id];
});
c2156_22 = c2156_22 + 1;
if (guildId != null) {
let r21 = c2156_21[guildId];
if (r21 == null) {
r21 = 0;
}
c2156_21[guildId] = r21 + 1;
}
};
computePermissions2 = function computePermissions(a0, a1, a2, a3) {
let NONE2;
let NONE = _PermissionUtils.NONE;
if (a0 instanceof ChannelRecordBase) {
if (THREAD_CHANNEL_TYPES.has(a0.type)) {
const channel = ChannelStore.getChannel(a0.parent_id);
return channel == null ? _PermissionUtils.NONE : applyThreadPermissions(a0, computePermissions2(channel, a1, a2, a3), JoinedThreadsStore.hasJoined(a0.id), GuildMemberStore.isCurrentUserGuest(a0.guild_id));
}
const id2 = a0.id;
let r51 = c2156_20[id2];
if (r51 == null) {
const uncachedChannelPermissions = getUncachedChannelPermissions(id2, true);
c2156_20[id2] = uncachedChannelPermissions;
r51 = uncachedChannelPermissions;
}
NONE = r51;
} else if (isGuildRecord(a0)) {
const id = a0.id;
let r31 = c2156_19[id];
if (r31 == null) {
const currentUser = UserStore.getCurrentUser();
if (currentUser == null) {
r31 = _PermissionUtils.NONE;
} else {
const guild = GuildStore.getGuild(id);
if (guild == null) {
NONE2 = _PermissionUtils.NONE;
} else {
NONE2 = _PermissionUtils.computePermissions({
user: currentUser,
context: guild,
checkElevated: true
});
c2156_19[id] = NONE2;
}
r31 = NONE2;
}
}
NONE = r31;
}
if (!(a1 === void 0 && (a2 === void 0 && a3 === void 0))) {
NONE = _PermissionUtils.computePermissions({
user: UserStore.getCurrentUser(),
context: a0,
overwrites: a1,
roles: a2,
checkElevated: true,
excludeGuildPermissions: a3
});
}
return NONE;
};
c2156_19 = {};
c2156_20 = {};
c2156_21 = {};
c2156_22 = 0;
class PermissionStore extends Module589.Store {
static displayName = "PermissionStore";
initialize() {
this.waitFor(ChannelStore, GuildMemberStore, GuildStore, ImpersonateStore, JoinedThreadsStore, LurkingStore, StageInstanceStore, UserStore);
}
getChannelPermissions(a0) {
let r10;
if (THREAD_CHANNEL_TYPES.has(a0.type)) {
r10 = getUncachedChannelPermissions(a0.id);
} else {
const id = a0.id;
r10 = c2156_20[id];
if (r10 == null) {
const uncachedChannelPermissions = getUncachedChannelPermissions(id, true);
c2156_20[id] = uncachedChannelPermissions;
r10 = uncachedChannelPermissions;
}
}
return r10;
}
getGuildPermissions({ id }) {
let NONE;
let r11 = c2156_19[id];
if (r11 == null) {
const currentUser = UserStore.getCurrentUser();
if (currentUser == null) {
r11 = _PermissionUtils.NONE;
} else {
const guild = GuildStore.getGuild(id);
if (guild == null) {
NONE = _PermissionUtils.NONE;
} else {
NONE = _PermissionUtils.computePermissions({
user: currentUser,
context: guild,
checkElevated: true
});
c2156_19[id] = NONE;
}
r11 = NONE;
}
}
return r11;
}
getGuildPermissionProps(a0) {
const currentUser = UserStore.getCurrentUser();
return {
canManageGuild: this.can(Permissions.MANAGE_GUILD, a0),
canManageChannels: this.can(Permissions.MANAGE_CHANNELS, a0),
canManageRoles: this.can(Permissions.MANAGE_ROLES, a0),
canManageBans: this.can(Permissions.BAN_MEMBERS, a0),
canManageNicknames: this.can(Permissions.MANAGE_NICKNAMES, a0),
canManageGuildExpressions: this.can(Permissions.MANAGE_GUILD_EXPRESSIONS, a0) || this.can(Permissions.CREATE_GUILD_EXPRESSIONS, a0),
canViewAuditLog: this.can(Permissions.VIEW_AUDIT_LOG, a0),
canViewAuditLogV2: this.can(Permissions.VIEW_AUDIT_LOG, a0),
canManageWebhooks: this.can(Permissions.MANAGE_WEBHOOKS, a0),
canViewGuildAnalytics: this.can(Permissions.VIEW_GUILD_ANALYTICS, a0),
canAccessMembersPage: this.canAccessMemberSafetyPage(a0),
isGuildAdmin: this.can(Permissions.ADMINISTRATOR, a0),
isOwner: currentUser != null && isGuildOwner(a0, currentUser),
isOwnerWithRequiredMfaLevel: currentUser != null && isGuildOwnerWithRequiredMfaLevel(a0, currentUser),
guild: a0
};
}
canAccessMemberSafetyPage({ id }) {
let NONE;
let r17 = c2156_19[id];
if (r17 == null) {
const currentUser = UserStore.getCurrentUser();
if (currentUser == null) {
r17 = _PermissionUtils.NONE;
} else {
const guild = GuildStore.getGuild(id);
if (guild == null) {
NONE = _PermissionUtils.NONE;
} else {
NONE = _PermissionUtils.computePermissions({
user: currentUser,
context: guild,
checkElevated: true
});
c2156_19[id] = NONE;
}
r17 = NONE;
}
}
return hasAny(r17, MemberSafetyPagePermissions);
}
canAccessGuildSettings({ id }) {
let NONE;
let r16 = c2156_19[id];
if (r16 == null) {
const currentUser = UserStore.getCurrentUser();
if (currentUser == null) {
r16 = _PermissionUtils.NONE;
} else {
const guild = GuildStore.getGuild(id);
if (guild == null) {
NONE = _PermissionUtils.NONE;
} else {
NONE = _PermissionUtils.computePermissions({
user: currentUser,
context: guild,
checkElevated: true
});
c2156_19[id] = NONE;
}
r16 = NONE;
}
}
return hasAny(r16, VIEW_GUILD_SETTINGS);
}
canWithPartialContext(a0, a1) {
return "channelId" in a1 && typeof a1.channelId === "string" ? this.can(a0, ChannelStore.getChannel(a1.channelId)) : "guildId" in a1 && typeof a1.guildId === "string" && this.can(a0, GuildStore.getGuild(a1.guildId));
}
can(a0, a1, a2, a3, a4) {
return has(computePermissions2(a1, a2, a3, a4), a0);
}
canBasicChannel(a0, a1, a2, a3, a4) {
return "basicPermissions" in a1 ? BasicPermissionUtils.has(a1.basicPermissions, a0) : has(computePermissions2(a1, a2, a3, a4), BasicPermissionUtils.asBigFlag(a0));
}
computePermissions(a0, a1, a2, a3) {
return computePermissions2(a0, a1, a2, a3);
}
computeBasicPermissions(a0) {
return "basicPermissions" in a0 ? a0.basicPermissions : BasicPermissionUtils.asBasicFlag(computePermissions2(a0));
}
canManageUser(a0, a1, a2) {
const r16 = a1 instanceof UserRecord ? a1.id : a1;
const isGuildOwner2 = isGuildOwner(a2, r16);
if (isGuildOwner2) {
return false;
}
const currentUser = UserStore.getCurrentUser();
if (this.can(a0, a2)) {
const r8 = currentUser != null ? _PermissionUtils.getHighestRole(a2, currentUser.id) : void 0;
const highestRole = _PermissionUtils.getHighestRole(a2, r16);
return currentUser != null && _PermissionUtils.isRoleHigher(a2, currentUser.id, r8, highestRole);
}
return false;
}
getHighestRole(a0) {
const currentUser = UserStore.getCurrentUser();
return currentUser != null ? _PermissionUtils.getHighestRole(a0, currentUser.id) : null;
}
isRoleHigher(a0, a1, a2) {
const currentUser = UserStore.getCurrentUser();
return _PermissionUtils.isRoleHigher(a0, ImpersonateStore.isViewingRoles(a0.id) ? void 0 : currentUser?.id, a1, a2);
}
canImpersonateRole(a0, a1) {
const highestRole = this.getHighestRole(a0);
let r9 = this.can(Permissions.MANAGE_GUILD, a0) && this.can(Permissions.MANAGE_ROLES, a0);
let r14 = this.isRoleHigher(a0, highestRole, a1);
if (r9) {
if (!r14) {
r14 = a1.id === highestRole?.id;
}
r9 = r14;
}
return r9;
}
getGuildVersion(a0) {
let r5 = c2156_21[a0];
if (r5 == null) {
r5 = 0;
}
return r5;
}
getChannelsVersion() {
return c2156_22;
}
}
const permissionStore = new PermissionStore(Dispatcher, {
BACKGROUND_SYNC: handleConnectionOpen,
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
CACHE_LOADED: handleConnectionOpen,
CACHE_LOADED_LAZY: handleConnectionOpen,
CONNECTION_CLOSED: function handleConnectionClose() {
c2156_20 = {};
c2156_19 = {};
c2156_21 = {};
c2156_22 = 0;
},
GUILD_CREATE: handleGuild,
GUILD_UPDATE: handleGuild,
GUILD_DELETE: handleGuild,
GUILD_MEMBER_ADD: handleGuildMemberUpdate,
GUILD_MEMBER_UPDATE: handleGuildMemberUpdate,
CURRENT_USER_UPDATE: handleGuildMemberUpdate,
CHANNEL_CREATE: function handleChannelCreate(a0) {
const channel = ChannelStore.getChannel(a0.channel.id);
if (channel != null && !channel.isPrivate()) {
const r23 = _PermissionUtils.computePermissions({
user: UserStore.getCurrentUser(),
context: channel
});
if (c2156_20[channel.id] === r23) {
return false;
}
c2156_20[channel.id] = r23;
c2156_22 = c2156_22 + 1;
const guildId = channel.getGuildId();
if (guildId != null) {
let r32 = c2156_21[guildId];
if (r32 == null) {
r32 = 0;
}
c2156_21[guildId] = r32 + 1;
}
return void 0;
}
return false;
},
THREAD_CREATE: handleThreadAction,
THREAD_UPDATE: handleThreadAction,
THREAD_LIST_SYNC: handleThreadAction,
LOAD_THREADS_SUCCESS: handleThreadAction,
LOAD_ARCHIVED_THREADS_SUCCESS: handleThreadAction,
CHANNEL_UPDATES: function handleChannelUpdates({ channels }) {
let r1 = false;
for (const item of channels) {
const channel = ChannelStore.getChannel(item.id);
if (channel != null && !channel.isPrivate()) {
const currentUser = UserStore.getCurrentUser();
const context = channel;
const r45 = _PermissionUtils.computePermissions({
user: currentUser,
context
});
if (c2156_20[context.id] !== r45) {
c2156_20[channel.id] = r45;
updateGuildVersion(channel.getGuildId());
r1 = true;
}
}
}
let r61 = !!r1;
if (r61) {
c2156_22 = c2156_22 + 1;
r61 = r1;
}
return r61;
},
LOAD_MESSAGES_SUCCESS: function handleLoadMessagesSuccess(a0) {
return a0.messages.some((message) => message.thread != null);
},
SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
MOD_VIEW_SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
THREAD_MEMBER_UPDATE: function handleThreadMemberUpdate(a0) {
let r12 = UserStore.getCurrentUser()?.id === a0.userId;
if (r12) {
const guildId = a0.guildId;
const r4 = guildId != null;
r12 = true;
if (r4) {
let r15 = c2156_21[guildId];
if (r15 == null) {
r15 = 0;
}
c2156_21[guildId] = r15 + 1;
r12 = true;
}
}
return r12;
},
THREAD_MEMBERS_UPDATE: function handleThreadMembersUpdate(a0) {
let r14 = !!doesThreadMembersActionAffectMe(a0);
if (r14) {
const guildId = a0.guildId;
const r4 = guildId != null;
r14 = true;
if (r4) {
let r17 = c2156_21[guildId];
if (r17 == null) {
r17 = 0;
}
c2156_21[guildId] = r17 + 1;
r14 = true;
}
}
return r14;
},
CHANNEL_DELETE: function handleChannelDelete({ channel }) {
delete c2156_20[channel.id];
c2156_22 = c2156_22 + 1;
const guild_id = channel.guild_id;
if (guild_id != null) {
let r12 = c2156_21[guild_id];
if (r12 == null) {
r12 = 0;
}
c2156_21[guild_id] = r12 + 1;
}
return false;
},
GUILD_ROLE_CREATE: handleGuildRole,
GUILD_ROLE_UPDATE: handleGuildRole,
GUILD_ROLE_DELETE: handleGuildRole,
LOGOUT: function resetState() {
c2156_20 = {};
c2156_19 = {};
c2156_21 = {};
c2156_22 = 0;
},
STAGE_INSTANCE_CREATE: handleStageInstancesChanged,
STAGE_INSTANCE_UPDATE: handleStageInstancesChanged,
STAGE_INSTANCE_DELETE: handleStageInstancesChanged,
IMPERSONATE_UPDATE: handleImpersonateUpdate,
IMPERSONATE_STOP: handleImpersonateUpdate
});
export default permissionStore;
+67
View File
@@ -0,0 +1,67 @@
// Metro module 13461 (f13462).
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import MediaEngineStore from "./MediaEngineStore";
import PermissionStore from "./PermissionStore";
import RTCConnectionStore from "./RTCConnectionStore";
import VoiceStateStore from "./VoiceStateStore";
import { InputModes, Permissions } from "../Constants";
import Dispatcher from "../Dispatcher";
import Module589 from "../_bundle/Module589";
let hasPermission, c9340_11;
const handleUpdateVADPermission = function handleUpdateVADPermission() {
const channelId = RTCConnectionStore.getChannelId();
const r0 = channelId == null;
let r12 = true;
if (!r0) {
const channel = ChannelStore.getChannel(channelId);
const voiceState = VoiceStateStore.getVoiceState(channel == null ? void 0 : channel.getGuildId(), AuthenticationStore.getId());
r12 = MediaEngineStore.getMode() !== InputModes.VOICE_ACTIVITY || channel == null || channel.isPrivate() || channel.isGuildStageVoice() || PermissionStore.can(Permissions.USE_VAD, channel) || (voiceState == null || !!voiceState.suppress || voiceState.requestToSpeakTimestamp != null);
}
let r37 = hasPermission !== r12;
if (r37) {
c9340_11 = r12;
hasPermission = r12;
Dispatcher.dispatch({
type: "SET_VAD_PERMISSION",
hasPermission
});
r37 = true;
}
return r37;
};
hasPermission = true;
c9340_11 = true;
class PermissionVADStore extends Module589.Store {
static displayName = "PermissionVADStore";
initialize() {
this.waitFor(AuthenticationStore, ChannelStore, MediaEngineStore, PermissionStore, RTCConnectionStore, VoiceStateStore);
}
shouldShowWarning() {
return !c9340_11;
}
canUseVoiceActivity() {
return hasPermission;
}
}
const permissionVADStore = new PermissionVADStore(Dispatcher, {
RTC_CONNECTION_STATE: handleUpdateVADPermission,
MEDIA_ENGINE_SET_AUDIO_ENABLED: handleUpdateVADPermission,
AUDIO_SET_MODE: handleUpdateVADPermission,
CHANNEL_UPDATES: handleUpdateVADPermission,
THREAD_UPDATE: handleUpdateVADPermission,
GUILD_ROLE_UPDATE: handleUpdateVADPermission,
GUILD_MEMBER_UPDATE: handleUpdateVADPermission,
IMPERSONATE_UPDATE: handleUpdateVADPermission,
IMPERSONATE_STOP: handleUpdateVADPermission,
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.some((voiceState) => voiceState.userId === AuthenticationStore.getId() && handleUpdateVADPermission());
},
AUDIO_TOGGLE_SELF_MUTE: function handleUnclearWarning() {
c9340_11 = hasPermission;
},
PERMISSION_CLEAR_VAD_WARNING: function handleClearWarning() {
c9340_11 = true;
}
});
export default permissionVADStore;
+19
View File
@@ -0,0 +1,19 @@
// Metro module 16341 (f16342).
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c11756_0 = false;
class PhoneVerificationStore extends Module589.Store {
static displayName = "PhoneVerificationStore";
getCountrySelectorOpened() {
return c11756_0;
}
}
const phoneVerificationStore = new PhoneVerificationStore(Dispatcher, {
VERIFICATION_OPEN_COUNTRY_SELECTOR: function handleOpenCountry() {
c11756_0 = true;
},
VERIFICATION_CLOSE_COUNTRY_SELECTOR: function handleCloseCountrySelector() {
c11756_0 = false;
}
});
export default phoneVerificationStore;
+58
View File
@@ -0,0 +1,58 @@
// Metro module 4425 (f4426).
import { BillingError } from "../errors/index";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let error, giftCode, skuId;
const handleSubscribeFailure = function handleSubscribeFailure(a0) {
error = a0.error;
};
const handleClearError = function handleClearError() {
error = null;
};
error = null;
giftCode = null;
skuId = null;
class PremiumPaymentModalStore extends Module589.Store {
static displayName = "PremiumPaymentModalStore";
get paymentError() {
return error;
}
getGiftCode(a0) {
return a0 === skuId ? giftCode : null;
}
}
const premiumPaymentModalStore = new PremiumPaymentModalStore(Dispatcher, {
PREMIUM_PAYMENT_SUBSCRIBE_FAIL: handleSubscribeFailure,
PREMIUM_PAYMENT_UPDATE_FAIL: handleSubscribeFailure,
PREMIUM_PAYMENT_SUBSCRIBE_SUCCESS: function handleSubscribeSuccess() {
error = null;
},
PREMIUM_PAYMENT_UPDATE_SUCCESS: handleClearError,
PREMIUM_PAYMENT_ERROR_CLEAR: handleClearError,
BRAINTREE_TOKENIZE_PAYPAL_FAIL: function handlePayPalTokenizeFailure(a0) {
error = new BillingError(a0.message);
},
BRAINTREE_TOKENIZE_VENMO_FAIL: function handleVenmoTokenizeFailure(a0) {
error = new BillingError(a0.message);
},
SKU_PURCHASE_SUCCESS: function handleSKUPurchaseSuccess(a0) {
giftCode = a0.giftCode;
skuId = a0.skuId;
},
SKU_PURCHASE_FAIL: function handleSKUPurchaseFail(a0) {
error = a0.error;
},
SKU_PURCHASE_AWAIT_CONFIRMATION: function handleSKUPurchaseAwaitConfirmation(a0) {
if (a0.isGift) {
skuId = a0.skuId;
}
},
GIFT_CODE_CREATE: function handleGiftCodeCreate({ giftCode: giftCode2 }) {
if (giftCode2.uses === 0 && giftCode2.sku_id === skuId) {
giftCode = giftCode2.code;
return void 0;
}
return false;
}
});
export default premiumPaymentModalStore;
+27
View File
@@ -0,0 +1,27 @@
// Metro module 12805 (f12806).
import AuthenticationStore from "./AuthenticationStore";
import RelationshipStore from "./RelationshipStore";
import Durations from "../utils/Durations";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c8832_4 = 180 * Durations.Millis.DAY;
let c8832_5 = false;
class PremiumPromoStore extends Module589.Store {
static displayName = "PremiumPromoStore";
initialize() {
this.waitFor(RelationshipStore, AuthenticationStore);
}
isEligible() {
return c8832_5;
}
}
const premiumPromoStore = new PremiumPromoStore(Dispatcher, {
CONNECTION_OPEN: function updatePremiumPromoEligibility() {
const r3 = c8832_5;
const r1 = RelationshipStore.getFriendIDs().length >= 10 && SnowflakeUtils.extractTimestamp(AuthenticationStore.getId()) < Date.now() - c8832_4;
c8832_5 = r1;
return r3 !== r1;
}
});
export default premiumPromoStore;
+573
View File
@@ -0,0 +1,573 @@
// Metro module 4276 (f4277).
import AuthenticationStore from "./AuthenticationStore";
import UserStore from "./UserStore";
import { ActivityTypes, ClientTypes, ME, StatusTypes, UserFlags } from "../Constants";
import hasRichActivity from "../modules/activities/utils/hasRichActivity";
import Module12 from "../_bundle/Module12";
import isUndefinedOrNull from "../_bundle/isUndefinedOrNull";
import SnowflakeUtils from "../utils/SnowflakeUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
function $mk74181() {
return (a0) => [`${a0.application_id}:${a0.party?.id}`, a0];
}
let activities, presencesForGuilds, statuses, activities2, filteredActivities, hiddenActivities, clientStatuses, activityMetadata, filterPlayingActivities, flattenPresence, flattenPresenceInConnectionOpen, updatePresence, updatePresenceInConnectionOpen, clearPresence, clearPresences;
const sortActivity = function sortActivity(a0, a1) {
const type = a1.type;
const CUSTOM_STATUS = ActivityTypes.CUSTOM_STATUS;
let r0 = 4;
const r1 = CUSTOM_STATUS !== type ? ActivityTypes.COMPETING !== type ? ActivityTypes.STREAMING !== type ? ActivityTypes.PLAYING === type ? 1 : 0 : 2 : 3 : 4;
const type2 = a0.type;
if (ActivityTypes.CUSTOM_STATUS !== type2) {
r0 = ActivityTypes.COMPETING !== type2 ? ActivityTypes.STREAMING !== type2 ? ActivityTypes.PLAYING === type2 ? 1 : 0 : 2 : 3;
}
let r18 = r1 - r0 || (hasRichActivity(a1) ? 1 : 0) - (hasRichActivity(a0) ? 1 : 0);
if (!r18) {
let created_at = a1.created_at;
if (created_at == null) {
created_at = 0;
}
let created_at2 = a0.created_at;
if (created_at2 == null) {
created_at2 = 0;
}
r18 = created_at - created_at2;
}
return r18;
};
filterPlayingActivities = function filterPlayingActivities(a0) {
if (a0.length === 0) {
return a0;
}
const r24 = [];
const r2 = [];
for (const item of a0) {
if (item.type === ActivityTypes.PLAYING) {
r2.push(item);
} else {
r24.push(item);
}
}
if (r2.length <= 1) {
return a0;
}
return [...r24, [...r2].sort(sortActivity)[0]].sort(sortActivity);
};
flattenPresence = function flattenPresence(a0) {
let r12, r36;
L14: {
delete statuses[a0];
delete activities2[a0];
delete filteredActivities[a0];
delete hiddenActivities[a0];
delete clientStatuses[a0];
if (presencesForGuilds[a0] != null) {
L10: {
r12 = Object.values(presencesForGuilds[a0]);
r36 = r12.reduce((acc, item) => {
let r13;
const processedAtTimestamp2 = item.processedAtTimestamp;
const processedAtTimestamp = acc.processedAtTimestamp;
const r4 = item.activities != null ? item.activities.length : 0;
const r5 = acc.activities != null ? acc.activities.length : 0;
L8: {
if (!(processedAtTimestamp2 > processedAtTimestamp)) {
r13 = acc;
if (processedAtTimestamp2 !== processedAtTimestamp) {
break L8;
}
r13 = r4 > r5 ? item : acc;
} else {
r13 = item;
}
}
return r13;
}, r12[0]);
if (r36.status === StatusTypes.OFFLINE) {
if (r36.hiddenActivities != null && r36.hiddenActivities.length > 0) {
break L10;
}
if (Module12.every(presencesForGuilds[a0], (a0) => a0.status === StatusTypes.OFFLINE && (a0.hiddenActivities == null || a0.hiddenActivities.length === 0))) {
delete presencesForGuilds[a0];
break L14;
}
if (!r12.some((item) => item.hiddenActivities != null && item.hiddenActivities.length > 0)) {
break L14;
}
const r59 = Object.values(r12).flatMap(({ hiddenActivities: hiddenActivities2 }) => {
if (hiddenActivities2 == null) {
hiddenActivities2 = [];
}
return hiddenActivities2;
});
hiddenActivities[a0] = r59.length !== 0 ? [...new Map([...r59].reverse().map($mk74181())).values()] : r59;
break L14;
}
}
statuses[a0] = r36.status;
const activities3 = r36.activities;
activities2[a0] = activities3;
filteredActivities[a0] = filterPlayingActivities(activities3);
const r91 = Object.values(r12).flatMap(({ hiddenActivities: hiddenActivities2 }) => {
if (hiddenActivities2 == null) {
hiddenActivities2 = [];
}
return hiddenActivities2;
});
hiddenActivities[a0] = r91.length !== 0 ? [...new Map([...r91].reverse().map($mk74181())).values()] : r91;
if (r36.clientStatus != null) {
clientStatuses[a0] = r36.clientStatus;
}
}
}
};
flattenPresenceInConnectionOpen = function flattenPresenceInConnectionOpen(a0) {
const r11 = presencesForGuilds[a0];
if (r11 != null) {
const r19 = Module12.maxBy(Object.values(r11), (a0) => a0.processedAtTimestamp);
if (r19.status !== StatusTypes.OFFLINE || r19.hiddenActivities != null && r19.hiddenActivities.length > 0) {
statuses[a0] = r19.status;
const activities3 = r19.activities;
activities2[a0] = activities3;
filteredActivities[a0] = filterPlayingActivities(activities3);
let hiddenActivities2 = r19.hiddenActivities;
if (hiddenActivities2 == null) {
hiddenActivities2 = [];
}
hiddenActivities[a0] = hiddenActivities2;
if (r19.clientStatus != null) {
clientStatuses[a0] = r19.clientStatus;
}
}
}
};
updatePresence = function updatePresence(a0) {
const { guildId: guildId3, userId, status, clientStatus, activities: activities3 } = a0;
let hiddenActivities2 = a0.hiddenActivities;
const processedAtTimestamp = a0.processedAtTimestamp;
if (userId === AuthenticationStore.getId()) {
return false;
}
const r3 = status === StatusTypes.OFFLINE && (hiddenActivities2 == null || hiddenActivities2.length === 0);
let r29 = presencesForGuilds[userId];
if (r29 == null) {
if (r3) {
return false;
}
const r31 = {};
presencesForGuilds[userId] = r31;
r29 = r31;
}
if (r3) {
r29[guildId3] = {
status,
clientStatus,
activities,
hiddenActivities: activities,
processedAtTimestamp
};
} else {
const r16 = activities3.length > 1 ? [...activities3].sort(sortActivity) : activities3;
if (hiddenActivities2 == null) {
hiddenActivities2 = [];
}
const hiddenActivities3 = hiddenActivities2.length !== 0 ? [...new Map([...hiddenActivities2].reverse().map($mk74181())).values()] : hiddenActivities2;
const r60 = r29[guildId3];
r29[guildId3] = {
status,
clientStatus,
activities: r60 != null ? isUndefinedOrNull(r60.activities, r16) ? r60.activities : r16 : r16,
hiddenActivities: hiddenActivities3,
processedAtTimestamp
};
}
delete activityMetadata[userId];
flattenPresence(userId);
return true;
};
updatePresenceInConnectionOpen = function updatePresenceInConnectionOpen(a0) {
const { guildId: guildId3, userId, status, clientStatus, activities: activities3 } = a0;
let hiddenActivities2 = a0.hiddenActivities;
const processedAtTimestamp = a0.processedAtTimestamp;
if (userId !== AuthenticationStore.getId()) {
const r3 = status === StatusTypes.OFFLINE && (hiddenActivities2 == null || hiddenActivities2.length === 0);
let r28 = presencesForGuilds[userId];
if (r28 == null) {
if (r3) {
return void 0;
}
const r30 = {};
presencesForGuilds[userId] = r30;
r28 = r30;
}
if (r3) {
r28[guildId3] = {
status,
clientStatus,
activities,
hiddenActivities: activities,
processedAtTimestamp
};
} else {
const activities4 = activities3.length > 1 ? [...activities3].sort(sortActivity) : activities3;
if (hiddenActivities2 == null) {
hiddenActivities2 = [];
}
r28[guildId3] = {
status,
clientStatus,
activities: activities4,
hiddenActivities: hiddenActivities2.length !== 0 ? [...new Map([...hiddenActivities2].reverse().map($mk74181())).values()] : hiddenActivities2,
processedAtTimestamp
};
}
}
};
clearPresence = function clearPresence(a0, item) {
if (item === AuthenticationStore.getId()) {
return false;
}
const r6 = presencesForGuilds[item];
if (r6 != null && r6[a0] != null) {
delete r6[a0];
if (Object.keys(r6).length === 0) {
delete presencesForGuilds[item];
}
flattenPresence(item);
return void 0;
}
return false;
};
clearPresences = function clearPresences(id) {
for (const item of SnowflakeUtils.keys(presencesForGuilds)) {
clearPresence(id, item);
}
};
activities = Object.freeze([]);
presencesForGuilds = {};
statuses = {};
activities2 = {};
filteredActivities = {};
hiddenActivities = {};
clientStatuses = {};
activityMetadata = {};
class PresenceStore extends Module589.Store {
static displayName = "PresenceStore";
initialize() {
this.waitFor(AuthenticationStore, UserStore);
}
setCurrentUserOnConnectionOpen(a0, a1) {
statuses[AuthenticationStore.getId()] = a0;
const id = AuthenticationStore.getId();
const r17 = [...a1].sort(sortActivity);
activities2[id] = r17;
filteredActivities[id] = filterPlayingActivities(r17);
}
getStatus(a0, r8 = null, r3 = StatusTypes.OFFLINE) {
const user = UserStore.getUser(a0);
if (user != null && user.hasFlag(UserFlags.BOT_HTTP_INTERACTIONS)) {
r3 = StatusTypes.UNKNOWN;
}
if (r8 == null) {
let r22 = statuses[a0];
if (r22 == null) {
r22 = r3;
}
return r22;
}
const r17 = presencesForGuilds[a0];
let r20 = (r17 != null ? r17[r8] : null)?.status;
if (r20 == null) {
r20 = r3;
}
return r20;
}
getActivities(a0, r7 = null) {
if (r7 == null) {
let r15 = filteredActivities[a0];
if (r15 == null) {
r15 = activities;
}
return r15;
}
const r6 = presencesForGuilds[a0];
const r9 = r6 != null ? r6[r7] : null;
return r9 != null && r9.activities != null ? filterPlayingActivities(r9.activities) : activities;
}
getUnfilteredActivities(a0, r6 = null) {
if (r6 == null) {
let r12 = activities2[a0];
if (r12 == null) {
r12 = activities;
}
return r12;
}
const r5 = presencesForGuilds[a0];
const r8 = r5 != null ? r5[r6] : null;
return r8 != null && r8.activities != null ? r8.activities : activities;
}
getHiddenActivities(a0, r7 = null) {
let r10;
if (r7 == null) {
let r12 = hiddenActivities[a0];
if (r12 == null) {
r12 = activities;
}
r10 = r12;
} else {
const r6 = presencesForGuilds[a0];
r10 = (r6 != null ? r6[r7] : null)?.hiddenActivities;
if (r10 == null) {
r10 = activities;
}
}
return r10;
}
getPrimaryActivity(a0, r5 = null) {
return this.getActivities(a0, r5).filter((item) => item.type !== ActivityTypes.HANG_STATUS)[0];
}
getAllApplicationActivities(a0) {
const r0 = [];
for (const item of SnowflakeUtils.keys(filteredActivities)) {
const userId = item;
for (const item2 of filteredActivities[item]) {
const activity = item2;
if (item2.application_id === a0) {
r0.push({
userId,
activity
});
}
}
}
return r0;
}
getApplicationActivity(a0, c14076_0, r5 = null) {
return this.findActivity(a0, (a0) => a0.application_id === c14076_0, r5, true);
}
findActivity(a0, a1, r8 = null, r2 = false) {
if (r2 == null) {
r2 = false;
}
const activities3 = this.getActivities(a0, r8);
return (r2 ? activities3.concat(this.getHiddenActivities(a0, r8)) : activities3).find(a1);
}
getActivityMetadata(a0) {
return activityMetadata[a0];
}
getUserIds() {
return SnowflakeUtils.keys(activities2);
}
isMobileOnline(a0) {
const r6 = clientStatuses[a0];
return r6 != null && r6[ClientTypes.MOBILE] === StatusTypes.ONLINE && r6[ClientTypes.DESKTOP] !== StatusTypes.ONLINE && r6[ClientTypes.VR] !== StatusTypes.ONLINE;
}
isVROnline(a0) {
const r5 = clientStatuses[a0];
return r5 != null && r5[ClientTypes.VR] === StatusTypes.ONLINE;
}
getClientStatus(a0) {
return clientStatuses[a0];
}
getState() {
return {
presencesForGuilds,
statuses,
activities: activities2,
filteredActivities,
hiddenActivities,
activityMetadata,
clientStatuses
};
}
}
const presenceStore = new PresenceStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
return true;
},
CONNECTION_OPEN_SUPPLEMENTAL: function handleConnectionOpenSupplemental({ guilds, presences }) {
const id = AuthenticationStore.getId();
presencesForGuilds = {};
activityMetadata = {};
const r15 = {};
r15[id] = statuses[id];
statuses = r15;
const r17 = {};
r17[id] = activities2[id];
activities2 = r17;
const r20 = {};
r20[id] = filteredActivities[id];
filteredActivities = r20;
const r23 = {};
r23[id] = hiddenActivities[id];
hiddenActivities = r23;
const r26 = {};
r26[id] = {};
clientStatuses = r26;
const set = new Set();
let c14077_0 = set;
guilds.forEach((guild) => {
guild.presences.forEach((presence) => {
const user = presence.user;
updatePresenceInConnectionOpen({
guildId: guild.id,
userId: user.id,
status: presence.status,
clientStatus: presence.clientStatus,
activities: presence.activities,
hiddenActivities: presence.hiddenActivities,
processedAtTimestamp: presence.processedAtTimestamp
});
c14077_0.add(user.id);
});
});
presences.forEach(({ user, status, clientStatus, activities: activities3, hiddenActivities: hiddenActivities2, processedAtTimestamp }) => {
if (user != null) {
updatePresenceInConnectionOpen({
guildId: ME,
userId: user.id,
status,
clientStatus,
activities: activities3,
hiddenActivities: hiddenActivities2,
processedAtTimestamp
});
c14077_0.add(user.id);
}
});
set.delete(id);
set.forEach(flattenPresenceInConnectionOpen);
},
OVERLAY_INITIALIZE: function handleOverlayInitialize({ presences }) {
presencesForGuilds = presences.presencesForGuilds;
statuses = presences.statuses;
activities2 = presences.activities;
hiddenActivities = presences.hiddenActivities;
activityMetadata = presences.activityMetadata;
},
GUILD_CREATE: function handleGuildCreate({ guild }) {
guild.presences.forEach((presence) => {
updatePresence({
guildId: guild.id,
userId: presence.user.id,
status: presence.status,
clientStatus: presence.clientStatus,
activities: presence.activities,
hiddenActivities: presence.hiddenActivities,
processedAtTimestamp: presence.processedAtTimestamp
});
});
},
GUILD_DELETE: function handleGuildDelete(a0) {
clearPresences(a0.guild.id);
},
GUILD_MEMBER_REMOVE: function handleGuildMemberRemove(a0) {
const guildId3 = a0.guildId;
const id = a0.user.id;
const id2 = AuthenticationStore.getId();
let r1 = false;
if (id !== id2) {
const r14 = presencesForGuilds[id];
const r4 = r14 == null;
r1 = false;
if (!r4) {
const r16 = r14[guildId3] == null;
r1 = false;
if (!r16) {
delete r14[guildId3];
if (Object.keys(r14).length === 0) {
delete presencesForGuilds[id];
}
flattenPresence(id);
r1 = void 0;
}
}
}
return r1;
},
PRESENCE_UPDATES: function handlePresenceUpdates(a0) {
return a0.updates.map((update) => {
let guildId3 = update.guildId;
const { user, status, clientStatus, activities: activities3, hiddenActivities: hiddenActivities2, processedAtTimestamp } = update;
if (guildId3 == null) {
guildId3 = ME;
}
return updatePresence({
guildId: guildId3,
userId: user.id,
status,
clientStatus,
activities: activities3,
hiddenActivities: hiddenActivities2,
processedAtTimestamp
});
}).some((item) => item);
},
PRESENCES_REPLACE: function handlePresenceReplace({ presences }) {
clearPresences(ME);
presences.forEach(({ user, status, clientStatus, activities: activities3, hiddenActivities: hiddenActivities2, processedAtTimestamp }) => {
if (user != null) {
updatePresence({
guildId: ME,
userId: user.id,
status,
clientStatus,
activities: activities3,
hiddenActivities: hiddenActivities2,
processedAtTimestamp
});
}
});
},
ACTIVITY_METADATA_UPDATE: function handleActivityMetadataUpdate(a0) {
activityMetadata[a0.userId] = a0.metadata;
return false;
},
THREAD_MEMBER_LIST_UPDATE: function handleThreadMemberListUpdate(a0) {
const guildId = a0.guildId;
a0.members.forEach((member) => {
if (member.presence != null) {
updatePresence({
guildId,
userId: member.user_id,
status: member.presence.status,
clientStatus: member.presence.clientStatus,
activities: member.presence.activities,
hiddenActivities: member.presence.hiddenActivities,
processedAtTimestamp: member.presence.processedAtTimestamp
});
}
});
},
THREAD_MEMBERS_UPDATE: function handleThreadMembersUpdate({ guildId: guildId2, addedMembers }) {
if (addedMembers != null) {
addedMembers.forEach((addedMember) => {
if (addedMember.presence != null) {
updatePresence({
guildId: guildId2,
userId: addedMember.userId,
status: addedMember.presence.status,
clientStatus: addedMember.presence.clientStatus,
activities: addedMember.presence.activities,
hiddenActivities: addedMember.presence.hiddenActivities,
processedAtTimestamp: addedMember.presence.processedAtTimestamp
});
}
});
}
},
SELF_PRESENCE_STORE_UPDATE: function handleCurrentUserPresenceUpdate(a0) {
const id = AuthenticationStore.getId();
if (statuses[id] === a0.status && activities2[id] === a0.activities && hiddenActivities[id] === a0.hiddenActivities) {
return false;
}
statuses[id] = a0.status;
const r9 = [...a0.activities].sort(sortActivity);
activities2[id] = r9;
filteredActivities[id] = filterPlayingActivities(r9);
hiddenActivities[id] = [...a0.hiddenActivities].sort(sortActivity);
delete activityMetadata[id];
}
});
export default presenceStore;
export { sortActivity };
+166
View File
@@ -0,0 +1,166 @@
// Metro module 12806 (f12807).
import { isPrivate } from "../records/ChannelRecord";
import ChannelStore from "./ChannelStore";
import ReadStateStore from "./ReadStateStore";
import SelectedChannelStore from "./SelectedChannelStore";
import PrivateChannelSortStore from "./views/PrivateChannelSortStore";
import { areArraysShallowlyEqual } from "../utils/FunctionUtils";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c8833_7, c8833_8, $mk90434 = function() {
return (a0) => ReadStateStore.getMentionCount(a0) > 0;
};
const rebuildUnreads = function rebuildUnreads() {
const r13 = PrivateChannelSortStore.getPrivateChannelIds().filter($mk90434());
if (r13.length > 20) {
r13.length = 20;
}
const r20 = areArraysShallowlyEqual(r13, c8833_7);
let r21 = !r20;
if (!r20) {
c8833_7 = r13;
c8833_8 = new Set(r13);
r21 = true;
}
return r21;
};
const handleConnectionOpen = function handleConnectionOpen() {
const r13 = PrivateChannelSortStore.getPrivateChannelIds().filter($mk90434());
if (r13.length > 20) {
r13.length = 20;
}
const r20 = areArraysShallowlyEqual(r13, c8833_7);
let r21 = !r20;
if (!r20) {
c8833_7 = r13;
c8833_8 = new Set(r13);
r21 = true;
}
return r21;
};
const handleGenericUpdate = function handleGenericUpdate(a0) {
const channel = ChannelStore.getChannel(a0.channelId);
const r1 = channel == null || !isPrivate(channel.type);
let r18 = !r1;
if (!r1) {
const r24 = PrivateChannelSortStore.getPrivateChannelIds().filter($mk90434());
if (r24.length > 20) {
r24.length = 20;
}
const r32 = areArraysShallowlyEqual(r24, c8833_7);
let r33 = !r32;
if (!r32) {
c8833_7 = r24;
c8833_8 = new Set(r24);
r33 = true;
}
r18 = r33;
}
return r18;
};
c8833_7 = [];
c8833_8 = new Set();
class PrivateChannelReadStateStore extends Module589.Store {
static displayName = "PrivateChannelReadStateStore";
initialize() {
this.waitFor(PrivateChannelSortStore, ChannelStore, SelectedChannelStore, ReadStateStore);
}
getUnreadPrivateChannelIds() {
return c8833_7;
}
}
const privateChannelReadStateStore = new PrivateChannelReadStateStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
MESSAGE_CREATE: handleGenericUpdate,
MESSAGE_ACK: handleGenericUpdate,
CHANNEL_SELECT: function handleChannelSelect(a0) {
const channel = ChannelStore.getChannel(a0.channelId);
const r1 = channel == null || !isPrivate(channel.type);
let r18 = !r1;
if (!r1) {
const r24 = PrivateChannelSortStore.getPrivateChannelIds().filter($mk90434());
if (r24.length > 20) {
r24.length = 20;
}
const r32 = areArraysShallowlyEqual(r24, c8833_7);
let r33 = !r32;
if (!r32) {
c8833_7 = r24;
c8833_8 = new Set(r24);
r33 = true;
}
r18 = r33;
}
return r18;
},
CHANNEL_DELETE: function handleChannelDelete(a0) {
let r15 = !!c8833_8.has(a0.channel.id);
if (r15) {
const r21 = PrivateChannelSortStore.getPrivateChannelIds().filter($mk90434());
if (r21.length > 20) {
r21.length = 20;
}
const r28 = areArraysShallowlyEqual(r21, c8833_7);
let r29 = !r28;
if (!r28) {
c8833_7 = r21;
c8833_8 = new Set(r21);
r29 = true;
}
r15 = r29;
}
return r15;
},
WINDOW_FOCUS: function handleWindowFocus() {
const channel = ChannelStore.getChannel(SelectedChannelStore.getChannelId());
const r1 = channel == null || !isPrivate(channel.type);
let r18 = !r1;
if (!r1) {
const r24 = PrivateChannelSortStore.getPrivateChannelIds().filter($mk90434());
if (r24.length > 20) {
r24.length = 20;
}
const r33 = areArraysShallowlyEqual(r24, c8833_7);
let r34 = !r33;
if (!r33) {
c8833_7 = r24;
c8833_8 = new Set(r24);
r34 = true;
}
r18 = r34;
}
return r18;
},
CHANNEL_CREATE: function handleChannelCreate(a0) {
const channel = ChannelStore.getChannel(a0.channel.id);
const r1 = channel == null || !isPrivate(channel.type);
let r19 = !r1;
if (!r1) {
const r25 = PrivateChannelSortStore.getPrivateChannelIds().filter($mk90434());
if (r25.length > 20) {
r25.length = 20;
}
const r33 = areArraysShallowlyEqual(r25, c8833_7);
let r34 = !r33;
if (!r33) {
c8833_7 = r25;
c8833_8 = new Set(r25);
r34 = true;
}
r19 = r34;
}
return r19;
},
CHANNEL_UPDATES: function handleChannelUpdates({ channels }) {
let r0 = false;
for (const item of channels) {
const channel = ChannelStore.getChannel(item.id);
if (channel != null && isPrivate(channel.type)) {
r0 = true;
}
}
return !!r0 && rebuildUnreads();
}
});
export default privateChannelReadStateStore;
@@ -0,0 +1,378 @@
// Metro module 12807 (f12808).
import ExperimentStore from "../modules/experiments/ExperimentStore";
import UserAffinitiesV2Store from "../modules/user_affinities/UserAffinitiesV2Store";
import { PrivateChannelRecord } from "../records/ChannelRecord";
import ChannelStore from "./ChannelStore";
import ConsentStore from "./ConsentStore";
import FrecencyStore from "./FrecencyStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildStore from "./GuildStore";
import RelationshipStore from "./RelationshipStore";
import UserStore from "./UserStore";
import { NEW_GROUP_DM_POPOUT_ID, Consents } from "../Constants";
import { getFrictionlessGDMsEnabled } from "../modules/header_bar/FrictionlessGDMsExperiment";
import GuildUtils from "../utils/GuildUtils";
import { stripDiacritics } from "../utils/StringUtils";
import UserUtils from "../utils/UserUtils";
import { RestrictedGuildIds } from "../modules/user_settings/UserSettings";
import UserSearchManager from "../modules/autocompleter/UserSearchManager";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let userSearchContext, c8834_15, query, row, results, hasFriends2, isLoading, selectedUsers, channelId, updateHasFriends, sortUserList, getMutualGuildsWithCurrentUser, parseUserResults, performQueryOnAffinityChange, c8834_29;
const performQuery = function performQuery() {
if (c8834_15) {
const channel2 = ChannelStore.getChannel(channelId);
if (query.trim().length === 0) {
if (userSearchContext != null) {
userSearchContext.clearQuery();
}
let c20229_3;
const channel = channel2;
const currentUser = UserStore.getCurrentUser();
const frictionlessGDMsEnabled = getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
const r89 = [...RelationshipStore.getFriendIDs()];
const r96 = (currentUser == null ? void 0 : currentUser.isStaff()) ? Array.from(new Set([...r89, ...UserStore.filter((item) => item.isStaff() && item.id !== currentUser.id, false).map((item) => item.id)])) : r89;
c20229_3 = null;
let r120 = r96;
if (frictionlessGDMsEnabled) {
c20229_3 = new Set(GuildStore.getGuildIds());
r120 = Array.from(new Set([...r96, ...UserAffinitiesV2Store.getUserAffinities().map((item) => item.otherUserId).filter((item) => item !== currentUser?.id).filter((item) => !RelationshipStore.isBlockedOrIgnored(item)).filter((item) => !RelationshipStore.isFriend(item))]));
}
results = ((channel == null ? void 0 : channel.isGroupDM()) ? r120.filter((item) => !channel.recipients.includes(item)) : r120).reduce((acc, item) => {
let mutualGuildsWithCurrentUser;
L19: {
const user = UserStore.getUser(item);
if (user != null && !user.isProvisional) {
if (user.bot) {
if (!user.isStaff()) {
break L19;
}
if (!(currentUser == null ? void 0 : currentUser.isStaff())) {
break L19;
}
}
const r26 = {
user,
comparator: UserUtils.getName(user)
};
if (frictionlessGDMsEnabled) {
if (c20229_3 != null && !RelationshipStore.isFriend(user.id)) {
L16: {
mutualGuildsWithCurrentUser = getMutualGuildsWithCurrentUser(user.id, c20229_3);
if (mutualGuildsWithCurrentUser.length === 0) {
if (user.isStaff() && (currentUser == null ? void 0 : currentUser.isStaff())) {
break L16;
}
return acc;
}
}
if (mutualGuildsWithCurrentUser.length > 0) {
r26.mutualGuilds = mutualGuildsWithCurrentUser;
}
}
}
acc.push(r26);
return acc;
}
}
return acc;
}, []).sort(sortUserList);
if (isLoading !== false) {
isLoading = false;
}
return true;
}
const currentUser2 = UserStore.getCurrentUser();
let staff = currentUser2 == null ? void 0 : currentUser2.isStaff();
if (staff == null) {
staff = false;
}
const frictionlessGDMsEnabled2 = getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
if (frictionlessGDMsEnabled2) {
GuildUtils.requestMembers(null, query);
}
const blacklist = channel2 != null ? channel2.recipients : [];
if (userSearchContext != null) {
const filters = frictionlessGDMsEnabled2 ? void 0 : {
friends: true,
staff,
provisional: false
};
let c20228_0, c20228_1;
const r54 = FrecencyStore.getFrequentlyWithoutFetchingLatest().filter((item) => item instanceof PrivateChannelRecord && item.isDM());
const r14 = Math;
c20228_0 = r14.max.apply(r14, [...r54.map((item) => FrecencyStore.getScoreWithoutFetchingLatest(item.id))]);
const boosters = {};
c20228_1 = boosters;
r54.forEach((item) => {
const scoreWithoutFetchingLatest = FrecencyStore.getScoreWithoutFetchingLatest(item.id);
const recipientId = item.getRecipientId();
c20228_1[recipientId] = 1 + scoreWithoutFetchingLatest / c20228_0 + (RelationshipStore.isFriend(recipientId) ? 0.2 : 0) + (ChannelStore.getDMFromUserId(recipientId) != null ? 0.1 : 0);
});
userSearchContext.setQuery({
query,
filters,
blacklist,
boosters
});
}
return false;
}
return false;
};
updateHasFriends = function updateHasFriends() {
if (c8834_15) {
const r2 = hasFriends2;
const r8 = RelationshipStore.getFriendCount() > 0;
hasFriends2 = r8;
return r8 !== r2;
}
return false;
};
sortUserList = function sortUserList(a0, a1) {
return stripDiacritics(UserUtils.getName(a0.user).toLocaleLowerCase()).localeCompare(stripDiacritics(UserUtils.getName(a1.user).toLocaleLowerCase()));
};
getMutualGuildsWithCurrentUser = function getMutualGuildsWithCurrentUser(id, a1) {
const setting = RestrictedGuildIds.getSetting();
const r29 = [];
for (const item of a1) {
if (!setting.includes(item) && GuildMemberStore.isMember(item, id)) {
const guild = GuildStore.getGuild(item);
if (guild != null) {
r29.push(guild);
}
}
}
return r29;
};
parseUserResults = function parseUserResults({ results: results2 }) {
let mutualGuilds;
if (c8834_15 && query !== "") {
const currentUser2 = UserStore.getCurrentUser();
const frictionlessGDMsEnabled2 = getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
const r6 = frictionlessGDMsEnabled2 ? new Set(GuildStore.getGuildIds()) : null;
const r45 = [];
for (const item of results2) {
const { id, comparator } = item;
if (currentUser2 != null && id === currentUser2.id) {
continue;
}
const user = UserStore.getUser(id);
const user2 = user;
if (user != null && !user2.isProvisional) {
if (user2.bot) {
if (!user2.isStaff()) {
continue;
}
if (!(currentUser2 == null ? void 0 : currentUser2.isStaff())) {
continue;
}
}
const r72 = {
user: user2,
comparator
};
if (frictionlessGDMsEnabled2 && r6 != null && !RelationshipStore.isFriend(user2.id)) {
L24: {
const mutualGuildsWithCurrentUser = getMutualGuildsWithCurrentUser(user2.id, r6);
mutualGuilds = mutualGuildsWithCurrentUser;
if (mutualGuildsWithCurrentUser.length === 0) {
if (!user2.isStaff()) {
continue;
}
if (currentUser2 == null ? void 0 : currentUser2.isStaff()) {
break L24;
}
continue;
}
}
if (mutualGuilds.length > 0) {
r72.mutualGuilds = mutualGuilds;
}
}
r45.push(r72);
}
}
results = r45;
c8834_29.emitChange();
}
};
const handleModalActionSheetOpen = function handleModalActionSheetOpen(a0) {
if (a0.key !== NEW_GROUP_DM_POPOUT_ID) {
return false;
}
c8834_15 = true;
hasFriends2 = RelationshipStore.getFriendCount() > 0;
if (userSearchContext != null) {
userSearchContext.destroy();
userSearchContext = null;
}
userSearchContext = UserSearchManager.getUserSearchContext(parseUserResults, 1000);
channelId = null;
query = "";
row = 0;
performQuery();
};
const handleActionSheetDismiss = function handleActionSheetDismiss(a0) {
if (a0.key !== NEW_GROUP_DM_POPOUT_ID) {
return false;
}
if (userSearchContext != null) {
userSearchContext.destroy();
userSearchContext = null;
}
query = "";
row = 0;
results = [];
selectedUsers = new Set();
c8834_15 = false;
channelId = null;
isLoading = false;
};
performQueryOnAffinityChange = function performQueryOnAffinityChange() {
const r1 = c8834_15 ? !getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore") : !c8834_15;
return r1 ? !r1 : performQuery();
};
Consents;
c8834_15 = false;
query = "";
row = 0;
results = [];
hasFriends2 = false;
isLoading = false;
selectedUsers = new Set();
channelId = null;
class PrivateChannelRecipientsInviteStoreClass extends Module589.Store {
static displayName = "PrivateChannelRecipientsInviteStore";
initialize() {
this.waitFor(ChannelStore, ConsentStore, ExperimentStore, FrecencyStore, GuildMemberStore, GuildStore, RelationshipStore, UserAffinitiesV2Store, UserStore);
this.syncWith([UserStore, ChannelStore], performQuery);
this.syncWith([UserAffinitiesV2Store], performQueryOnAffinityChange);
this.syncWith([RelationshipStore], updateHasFriends);
}
getResults() {
return results;
}
hasFriends() {
return hasFriends2;
}
getSelectedUsers() {
return selectedUsers;
}
getQuery() {
return query;
}
getState() {
return {
query,
selectedRow: row,
selectedUsers,
results,
hasFriends: hasFriends2,
isLoading
};
}
}
c8834_29 = new PrivateChannelRecipientsInviteStoreClass(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
query = "";
row = 0;
results = [];
selectedUsers = new Set();
c8834_15 = false;
channelId = null;
isLoading = false;
},
GUILD_MEMBERS_CHUNK_BATCH: function handleGuildMembersChunkBatch() {
const r0 = c8834_15 ? !getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore") : !c8834_15;
let r12 = !r0;
if (!r0) {
let r14 = isLoading !== false;
if (r14) {
isLoading = false;
r14 = true;
}
r12 = r14;
}
return r12;
},
GUILD_MEMBERS_REQUEST: function handleGuildMembersRequest({ query: query2 }) {
const r0 = c8834_15 ? !getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore") : !c8834_15;
let r15 = !r0;
if (!r0) {
let r19 = query2 === query.toLocaleLowerCase();
if (r19) {
let r20 = isLoading !== true;
if (r20) {
isLoading = true;
r20 = true;
}
r19 = r20;
}
r15 = r19;
}
return r15;
},
CHANNEL_SELECT: function handleChannelSelect({ guildId, channelId: channelId2 }) {
if (guildId != null) {
return false;
}
const r10 = c8834_15;
query = "";
row = 0;
results = [];
selectedUsers = new Set();
isLoading = false;
c8834_15 = r10;
channelId = channelId2;
return performQuery();
},
MODAL_PUSH: handleModalActionSheetOpen,
SHOW_ACTION_SHEET: handleModalActionSheetOpen,
PRIVATE_CHANNEL_RECIPIENTS_INVITE_OPEN: function handleInviteOpen(a0) {
c8834_15 = true;
hasFriends2 = RelationshipStore.getFriendCount() > 0;
if (userSearchContext != null) {
userSearchContext.destroy();
userSearchContext = null;
}
userSearchContext = UserSearchManager.getUserSearchContext(parseUserResults, 1000);
channelId = a0.channelId;
query = "";
row = 0;
performQuery();
},
MODAL_POP: handleActionSheetDismiss,
HIDE_ACTION_SHEET: handleActionSheetDismiss,
PRIVATE_CHANNEL_RECIPIENTS_INVITE_CLOSE: function handleClose() {
if (userSearchContext != null) {
userSearchContext.destroy();
userSearchContext = null;
}
query = "";
row = 0;
results = [];
selectedUsers = new Set();
c8834_15 = false;
channelId = null;
isLoading = false;
},
PRIVATE_CHANNEL_RECIPIENTS_INVITE_QUERY: function handleQuery(a0) {
channelId = a0.channelId;
query = a0.query;
row = 0;
performQuery();
},
PRIVATE_CHANNEL_RECIPIENTS_INVITE_SELECT: function handleSelect(a0) {
row = a0.row;
},
PRIVATE_CHANNEL_RECIPIENTS_ADD_USER: function handleAddUser(a0) {
selectedUsers.add(a0.userId);
selectedUsers = new Set(selectedUsers);
},
PRIVATE_CHANNEL_RECIPIENTS_REMOVE_USER: function handleRemoveUser(a0) {
selectedUsers.delete(a0.userId);
selectedUsers = new Set(selectedUsers);
}
});
export default c8834_29;
+194
View File
@@ -0,0 +1,194 @@
// Metro module 12809 (f12810).
import VoiceStateRecord from "../records/VoiceStateRecord";
import ChannelStore from "./ChannelStore";
import RTCConnectionStore from "./RTCConnectionStore";
import UserStore from "./UserStore";
import VoiceStateStore from "./VoiceStateStore";
import { makeSortedVoiceState } from "./views/SortedVoiceStateStore";
import { ME, RTCConnectionStates } from "../Constants";
import { ParticipantTypes } from "../modules/calls/CallConstants";
import CachedEntriesMap from "../lib/CachedEntriesMap";
import NicknameUtils from "../utils/NicknameUtils";
import { getAvatarDecoration } from "../modules/collectibles/avatar_decorations/useAvatarDecoration";
import { MediaEngineContextTypes } from "../_bundle/Module4286";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c8835_12, c8835_13, c8835_14;
const retryFailedUsers = function retryFailedUsers() {
const channelId = RTCConnectionStore.getChannelId();
if (channelId == null) {
return false;
}
const channel = ChannelStore.getChannel(channelId);
const guildId = channel == null ? void 0 : channel.getGuildId();
let c20230_2 = false;
c8835_14.forEach((item) => {
if (VoiceStateStore.getVoiceStateForChannel(channelId, item) == null) {
const user = UserStore.getUser(item);
if (user != null) {
c20230_2 = true;
c8835_14.delete(item);
const r27 = {
userId: user.id,
channelId
};
const r28 = Object.create(VoiceStateRecord.prototype);
const voiceStateRecord = new VoiceStateRecord(r27);
const r30 = guildId == null ? ME : guildId;
const voiceState = voiceStateRecord;
c8835_12.set(user.id, makeSortedVoiceState(voiceState, r30, user.id));
c8835_13.set(user.id, {
type: ParticipantTypes.USER,
user,
id: user.id,
streamId: null,
voiceState,
voicePlatform: null,
speaking: false,
lastSpoke: 0,
soundsharing: false,
ringing: false,
userNick: NicknameUtils.getName(guildId, channelId, user),
userAvatarDecoration: getAvatarDecoration(user, guildId),
localVideoDisabled: false,
isPoppedOut: false
});
}
} else {
c8835_14.delete(item);
}
});
return c20230_2;
};
c8835_12 = new CachedEntriesMap();
c8835_13 = new CachedEntriesMap();
c8835_14 = new Set();
class RTCConnectionDesyncStore extends Module589.Store {
static displayName = "RTCConnectionDesyncStore";
initialize() {
this.waitFor(VoiceStateStore, UserStore, ChannelStore, RTCConnectionStore);
this.syncWith([UserStore], retryFailedUsers);
}
get desyncedVoiceStatesCount() {
return c8835_12.size();
}
getDesyncedUserIds() {
return c8835_12.keys();
}
getDesyncedVoiceStates() {
return c8835_12.values();
}
getDesyncedParticipants() {
return c8835_13.values();
}
}
const rTCConnectionDesyncStore = new RTCConnectionDesyncStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c8835_12.clear();
c8835_13.clear();
c8835_14.clear();
},
VOICE_CHANNEL_SELECT: function handleReset() {
c8835_12.clear();
c8835_13.clear();
c8835_14.clear();
},
RTC_CONNECTION_STATE: function handleRTCConnectionState(a0) {
const state = a0.state;
let r0 = a0.context === MediaEngineContextTypes.DEFAULT;
if (r0) {
let r1 = state === RTCConnectionStates.DISCONNECTED;
if (r1) {
c8835_12.clear();
c8835_13.clear();
c8835_14.clear();
r1 = void 0;
}
r0 = r1;
}
return r0;
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates({ voiceStates }) {
const channelId2 = RTCConnectionStore.getChannelId();
return channelId2 != null && voiceStates.reduce((acc, voiceState) => {
const userId = voiceState.userId;
let r9 = voiceState.channelId === channelId2;
if (r9) {
let r11 = c8835_12.delete(userId);
const r13 = c8835_13.delete(userId);
const r16 = c8835_14.delete(userId);
if (!r11) {
r11 = r13;
}
if (!r11) {
r11 = r16;
}
r9 = !!r11;
}
if (!r9) {
r9 = acc;
}
return r9;
}, false);
},
RTC_CONNECTION_CLIENT_CONNECT: function handleRTCConnectionClientConnect(a0) {
const { userIds, guildId: guildId2, channelId: channelId3 } = a0;
return a0.context === MediaEngineContextTypes.DEFAULT && userIds.reduce((acc, a1) => {
let r51;
if (VoiceStateStore.getVoiceStateForChannel(channelId3, a1) != null) {
return acc;
}
const user = UserStore.getUser(a1);
if (user == null) {
c8835_14.add(a1);
r51 = acc;
} else {
const r21 = {
userId: user.id,
channelId: channelId3
};
const r22 = Object.create(VoiceStateRecord.prototype);
const voiceStateRecord = new VoiceStateRecord(r21);
const r24 = guildId2 == null ? ME : guildId2;
const voiceState = voiceStateRecord;
c8835_12.set(user.id, makeSortedVoiceState(voiceState, r24, user.id));
c8835_13.set(user.id, {
type: ParticipantTypes.USER,
user,
id: user.id,
streamId: null,
voiceState,
voicePlatform: null,
speaking: false,
lastSpoke: 0,
soundsharing: false,
ringing: false,
userNick: NicknameUtils.getName(guildId2, channelId3, user),
userAvatarDecoration: getAvatarDecoration(user, guildId2),
localVideoDisabled: false,
isPoppedOut: false
});
r51 = true;
}
return r51;
}, false);
},
RTC_CONNECTION_CLIENT_DISCONNECT: function handleRTCConnectionClientDisconnect(a0) {
const userId = a0.userId;
let r12 = a0.context === MediaEngineContextTypes.DEFAULT;
if (r12) {
let r15 = c8835_12.delete(userId);
const r17 = c8835_13.delete(userId);
const r20 = c8835_14.delete(userId);
if (!r15) {
r15 = r17;
}
if (!r15) {
r15 = r20;
}
r12 = r15;
}
return r12;
}
});
export default rTCConnectionDesyncStore;
+560
View File
@@ -0,0 +1,560 @@
// Metro module 4261 (f4262).
import GameConsoleStore from "../modules/game_console/GameConsoleStore";
import AuthenticationStore from "./AuthenticationStore";
import SortedVoiceStateStore from "./views/SortedVoiceStateStore";
import { AppStates, RTCConnectionQuality, RTCConnectionStates } from "../Constants";
import { MediaEngineContextTypes } from "../_bundle/Module4250";
import Logger from "../modules/debug/Logger";
import * as _RTCConnection from "../lib/RTCConnection";
import { RTCConnectionEvent } from "../lib/RTCConnectionEvent";
import Dispatcher from "../Dispatcher";
import VoiceStateAnalytics from "../lib/VoiceStateAnalytics";
import { Timeout } from "../_bundle/Timeout";
import { now } from "../_bundle/sleep";
import * as _SelectedChannelActionCreators from "../actions/SelectedChannelActionCreators";
import { isSpatialAudioAvailable } from "../modules/spatial_audio/useIsSpatialAudioAvailable";
import Module589 from "../_bundle/Module589";
import { setVideoToggleAnalyticsParams } from "../modules/media_engine/trackVideoToggle";
let rTCConnection, sessionId, c2499_12, c2499_13, channelId, c2499_15, c2499_16, voiceStateAnalytics, wasEverMultiParticipant, wasEverRtcConnected, c2499_20, c2499_21, c2499_22, joinVoiceId, c2499_24, destroyRTCConnection, c2499_27;
const createRTCConnection = function createRTCConnection(a0, a1) {
if (sessionId == null) {
throw new Error("Creating RTCConnection without session.");
}
const default2 = new _RTCConnection.default({
userId: AuthenticationStore.getId(),
sessionId,
guildId: a0,
channelId: a1,
joinVoiceId
});
let c14036_0 = default2;
default2.on(RTCConnectionEvent.State, (state, c24994_1, c24994_2) => {
Dispatcher.wait(() => Dispatcher.dispatch({
type: "RTC_CONNECTION_STATE",
state,
...c24994_1,
...c24994_2
}));
});
default2.on(RTCConnectionEvent.Video, (guildId, channelId2, userId, streamId, rtcServerId) => {
Dispatcher.wait(() => Dispatcher.dispatch({
type: "RTC_CONNECTION_VIDEO",
guildId,
channelId: channelId2,
userId,
streamId,
rtcServerId,
context: MediaEngineContextTypes.DEFAULT,
mediaEngineConnectionId: c14036_0.getMediaEngineConnectionId()
}));
});
default2.on(RTCConnectionEvent.Ping, (pings, quality) => {
Dispatcher.wait(() => Dispatcher.dispatch({
type: "RTC_CONNECTION_PING",
pings,
quality
}));
});
default2.on(RTCConnectionEvent.OutboundLossRate, (lossRate) => {
Dispatcher.wait(() => Dispatcher.dispatch({
type: "RTC_CONNECTION_LOSS_RATE",
lossRate
}));
});
default2.on(RTCConnectionEvent.Speaking, (a0, a1) => {
if (voiceStateAnalytics != null) {
voiceStateAnalytics.setSpeaking(a0, a1);
}
});
default2.on(RTCConnectionEvent.Flags, (userId2, flags) => {
Dispatcher.wait(() => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_FLAGS",
flags,
userId: userId2,
guildId: c14036_0.guildId,
channelId: c14036_0.channelId,
context: c14036_0.context
});
});
});
default2.on(RTCConnectionEvent.UsersMerged, (a0, a1) => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_USERS_MERGED",
userIds: a0,
context: a1
});
});
default2.on(RTCConnectionEvent.ClientConnect, (userIds) => {
Dispatcher.wait(() => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_CLIENT_CONNECT",
userIds,
guildId: c14036_0.guildId,
channelId: c14036_0.channelId,
context: c14036_0.context
});
});
});
default2.on(RTCConnectionEvent.ClientDisconnect, (userId3) => {
Dispatcher.wait(() => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_CLIENT_DISCONNECT",
userId: userId3,
guildId: c14036_0.guildId,
channelId: c14036_0.channelId,
context: c14036_0.context
});
});
});
default2.on(RTCConnectionEvent.Platform, (userId4, platform2, channelId3) => {
Dispatcher.wait(() => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_PLATFORM",
platform: platform2,
userId: userId4,
channelId: channelId3
});
});
});
default2.on(RTCConnectionEvent.SecureFramesUpdate, () => {
Dispatcher.wait(() => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_SECURE_FRAMES_UPDATE"
});
});
});
default2.on(RTCConnectionEvent.RosterMapUpdate, (userIds2) => {
Dispatcher.wait(() => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_ROSTER_MAP_UPDATE",
userIds: userIds2
});
});
});
voiceStateAnalytics = new VoiceStateAnalytics(AuthenticationStore.getId(), a1);
c2499_15 = null;
wasEverMultiParticipant = false;
wasEverRtcConnected = false;
return default2;
};
destroyRTCConnection = function destroyRTCConnection(r0 = true) {
if (rTCConnection == null) {
return false;
}
const r11 = {
duration: rTCConnection.getDuration(),
mediaSessionId: null,
rtcConnectionId: null,
wasEverMultiParticipant: null,
wasEverRtcConnected: null,
voiceStateAnalytics: null,
channelId: null
};
let mediaSessionId = rTCConnection.getMediaSessionId();
if (mediaSessionId == null) {
mediaSessionId = null;
}
r11.mediaSessionId = mediaSessionId;
r11.rtcConnectionId = rTCConnection.getRTCConnectionId();
r11.wasEverMultiParticipant = wasEverMultiParticipant;
r11.wasEverRtcConnected = wasEverRtcConnected;
r11.voiceStateAnalytics = voiceStateAnalytics;
r11.channelId = rTCConnection.channelId;
c2499_15 = r11;
Dispatcher.dispatch({
type: "MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET",
mediaEngineConnectionId: rTCConnection.getMediaEngineConnectionId()
});
rTCConnection.destroy();
rTCConnection = null;
voiceStateAnalytics = null;
c2499_22 = false;
if (r0) {
c2499_20 = null;
}
};
const handleClearRemoteDisconnectVoiceChannelId = function handleClearRemoteDisconnectVoiceChannelId() {
channelId = null;
};
const handleChannelDelete = function handleChannelDelete({ channel }) {
if (rTCConnection != null && rTCConnection.channelId === channel.id) {
destroyRTCConnection();
return void 0;
}
return false;
};
const handleRtcAction = function handleRtcAction() {
return true;
};
c2499_12 = new Logger("RTCConnectionStore");
c2499_13 = [];
channelId = null;
c2499_15 = null;
c2499_16 = null;
voiceStateAnalytics = null;
wasEverMultiParticipant = false;
wasEverRtcConnected = false;
c2499_20 = null;
c2499_21 = null;
c2499_22 = false;
joinVoiceId = null;
c2499_24 = null;
class RTCConnectionStore extends Module589.Store {
static displayName = "RTCConnectionStore";
initialize() {
this.waitFor(AuthenticationStore, GameConsoleStore, SortedVoiceStateStore);
setVideoToggleAnalyticsParams(this.getRTCConnectionId, this.getMediaSessionId);
}
getRTCConnection() {
return rTCConnection;
}
getState() {
return rTCConnection != null ? rTCConnection.state : RTCConnectionStates.DISCONNECTED;
}
isConnected() {
return this.getState() === RTCConnectionStates.RTC_CONNECTED;
}
isDisconnected() {
return this.getState() === RTCConnectionStates.DISCONNECTED;
}
getRemoteDisconnectVoiceChannelId() {
return channelId;
}
getLastSessionVoiceChannelId() {
return c2499_16;
}
setLastSessionVoiceChannelId(a0) {
c2499_16 = a0;
}
getGuildId() {
return rTCConnection?.guildId;
}
getChannelId() {
return rTCConnection?.channelId;
}
getHostname() {
return rTCConnection != null ? rTCConnection.hostname : "";
}
getQuality() {
return rTCConnection != null ? rTCConnection.quality : RTCConnectionQuality.UNKNOWN;
}
getPings() {
return rTCConnection != null ? rTCConnection.getPings() : c2499_13;
}
getAveragePing() {
const r1 = rTCConnection != null;
let r6 = 0;
if (r1) {
r6 = rTCConnection == null ? void 0 : rTCConnection.getAveragePing();
}
return r6;
}
getLastPing() {
return rTCConnection == null ? void 0 : rTCConnection.getLastPing();
}
getOutboundLossRate() {
return rTCConnection == null ? void 0 : rTCConnection.getOutboundLossRate();
}
getMediaSessionId() {
return rTCConnection == null ? void 0 : rTCConnection.getMediaSessionId();
}
getRTCConnectionId() {
return rTCConnection == null ? void 0 : rTCConnection.getRTCConnectionId();
}
getDuration() {
let r2 = rTCConnection == null ? void 0 : rTCConnection.getDuration();
if (r2 == null) {
r2 = c2499_15?.duration;
}
return r2;
}
getLastRTCConnectionState() {
return c2499_15;
}
getPacketStats() {
return rTCConnection == null ? void 0 : rTCConnection.getPacketStats();
}
getVoiceStateStats() {
return voiceStateAnalytics == null ? void 0 : voiceStateAnalytics.getStats();
}
getUserVoiceSettingsStats(a0) {
return voiceStateAnalytics == null ? void 0 : voiceStateAnalytics.getUserVoiceSettingsStats(a0);
}
getWasEverMultiParticipant() {
return wasEverMultiParticipant;
}
getWasEverRtcConnected() {
return wasEverRtcConnected;
}
getUserIds() {
return rTCConnection == null ? void 0 : rTCConnection.getUserIds();
}
getJoinVoiceId() {
return joinVoiceId;
}
isUserConnected(a0) {
return rTCConnection == null ? void 0 : rTCConnection.getIsUserConnected(a0);
}
getSecureFramesState() {
return rTCConnection == null ? void 0 : rTCConnection.getSecureFramesState();
}
getSecureFramesRosterMapEntry(a0) {
const r5 = rTCConnection == null ? void 0 : rTCConnection.getSecureFramesRosterMap();
return r5 == null ? void 0 : r5.get(a0);
}
getLastNonZeroRemoteVideoSinkWantsTime() {
return c2499_21;
}
getWasMoved() {
return c2499_22;
}
}
c2499_27 = new RTCConnectionStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
sessionId = a0.sessionId;
channelId = null;
c2499_16 = null;
destroyRTCConnection(false);
if (c2499_24 != null) {
c2499_24.timeout.stop();
c2499_24 = null;
}
return false;
},
CONNECTION_CLOSED: function handleConnectionClosed() {
sessionId = null;
channelId = null;
c2499_16 = null;
destroyRTCConnection(false);
if (c2499_24 != null) {
c2499_24.timeout.stop();
c2499_24 = null;
}
},
LOGOUT: function handleLogout() {
c2499_20 = null;
return false;
},
RTC_CONNECTION_STATE: function handleRTCConnectionState(a0) {
if (a0.state === RTCConnectionStates.RTC_CONNECTED) {
wasEverRtcConnected = true;
if (rTCConnection != null) {
c2499_20 = now();
}
}
return true;
},
RTC_CONNECTION_PING: function handleRtcConnectionPing() {
if (rTCConnection != null) {
c2499_20 = now();
}
return true;
},
RTC_CONNECTION_LOSS_RATE: handleRtcAction,
RTC_CONNECTION_UPDATE_ID: function handleRtcConnectionUpdateId(a0) {
return a0.connection === rTCConnection;
},
RTC_CONNECTION_SECURE_FRAMES_UPDATE: handleRtcAction,
RTC_CONNECTION_CLIENT_CONNECT: handleRtcAction,
RTC_CONNECTION_CLIENT_DISCONNECT: handleRtcAction,
RTC_CONNECTION_REMOTE_VIDEO_SINK_WANTS: function handleRtcConnectionRemoteVideoSinkWants({ context, wants }) {
let r1 = context === MediaEngineContextTypes.DEFAULT;
if (r1) {
let r17 = !!Object.entries(wants).some((item) => {
const [r14, r15] = item;
return r14 !== "any" && r15 !== 0;
});
if (r17) {
c2499_21 = performance.now();
r17 = void 0;
}
r1 = r17;
}
return r1;
},
VIDEO_SIZE_UPDATE: function handleVideoSizeUpdate({ streamId: streamId2, dimensions, zoom }) {
if (rTCConnection != null) {
rTCConnection.setVideoSize(streamId2, dimensions, zoom);
}
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((acc, voiceState) => {
if (voiceStateAnalytics != null) {
voiceStateAnalytics.updateVoiceStates(voiceState.userId, voiceState.channelId);
}
let r1 = wasEverMultiParticipant;
if (!r1) {
let r12 = voiceStateAnalytics == null ? void 0 : voiceStateAnalytics.getStats().max_voice_state_count;
if (r12 == null) {
r12 = 0;
}
r1 = r12 > 1;
}
wasEverMultiParticipant = r1;
if (AuthenticationStore.getId() !== voiceState.userId) {
return acc;
}
const r21 = c2499_24 != null && voiceState.channelId === c2499_24.channelId;
if (r21 && c2499_24 != null) {
c2499_24.timeout.stop();
c2499_24 = null;
}
L51: {
if (rTCConnection == null) {
if (voiceState.sessionId === sessionId && voiceState.channelId != null) {
if (!r21 && c2499_20 != null && now() - c2499_20 >= 300000) {
Dispatcher.wait(() => _SelectedChannelActionCreators.default.disconnect());
return acc;
}
channelId = null;
c2499_16 = null;
rTCConnection = createRTCConnection(voiceState.guildId, voiceState.channelId);
let r58 = voiceStateAnalytics == null ? void 0 : voiceStateAnalytics.getStats().max_voice_state_count;
if (r58 == null) {
r58 = 0;
}
wasEverMultiParticipant = r58 > 1;
break L51;
}
return acc;
}
if (voiceState.sessionId === sessionId) {
if (!(voiceState.guildId != null && voiceState.guildId === rTCConnection.guildId) && !(voiceState.guildId == null && voiceState.channelId === rTCConnection.channelId)) {
if (!(voiceState.guildId !== rTCConnection.guildId && voiceState.channelId == null)) {
destroyRTCConnection();
}
if (voiceState.channelId == null) {
break L51;
}
channelId = null;
c2499_16 = null;
rTCConnection = createRTCConnection(voiceState.guildId, voiceState.channelId);
let r103 = voiceStateAnalytics == null ? void 0 : voiceStateAnalytics.getStats().max_voice_state_count;
if (r103 == null) {
r103 = 0;
}
wasEverMultiParticipant = r103 > 1;
break L51;
}
if (voiceState.channelId == null) {
destroyRTCConnection();
} else {
rTCConnection.setNextChannelId(voiceState.channelId);
c2499_22 = true;
joinVoiceId = null;
rTCConnection.clearJoinVoiceId();
}
} else if (voiceState.guildId === rTCConnection.guildId) {
if (!(GameConsoleStore.getAwaitingRemoteSessionInfo() != null && GameConsoleStore.getRemoteSessionId() != null)) {
channelId = rTCConnection.channelId;
}
destroyRTCConnection();
}
}
return true;
}, false);
},
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect(a0) {
if (!(rTCConnection == null || a0.channelId != null && rTCConnection.channelId === a0.channelId)) {
destroyRTCConnection();
}
joinVoiceId = a0.joinVoiceId;
let c14037_0 = a0;
if (c2499_24 != null) {
c2499_24.timeout.stop();
c2499_24 = null;
}
if (a0.channelId != null) {
const timeout = new Timeout();
timeout.start(30000, () => {
c2499_12.warn("No VOICE_STATE_UPDATE received within 30000ms of VOICE_CHANNEL_SELECT", {
joinVoiceId: c14037_0.joinVoiceId,
channelId: c14037_0.channelId,
guildId: c14037_0.guildId
});
c2499_24 = null;
});
c2499_24 = {
joinVoiceId: a0.joinVoiceId,
channelId: a0.channelId,
guildId: a0.guildId,
timeout
};
}
},
AUDIO_SET_NOISE_CANCELLATION: function handleAudioSetNoiseCancellation(a0) {
if (rTCConnection != null) {
rTCConnection.setNoiseCancellationEnabled(a0.enabled);
}
},
AUDIO_SET_AUDIO_MIXER_SETTINGS: function handleAudioSetAudioMixerSettings(a0) {
if (a0.context !== MediaEngineContextTypes.DEFAULT) {
return false;
}
let enabled = a0.settings.enabled;
if (enabled == null) {
enabled = false;
}
if (enabled) {
enabled = isSpatialAudioAvailable("RTCConnectionStore");
}
if (rTCConnection != null) {
rTCConnection.setSpatialAudioEnabled(enabled);
}
},
VOICE_SERVER_UPDATE: function handleVoiceServerUpdate(a0) {
let r2 = rTCConnection != null;
if (r2) {
let r1 = a0.guildId == null || a0.guildId === rTCConnection.guildId;
if (r1) {
let r13 = a0.channelId == null || a0.channelId === rTCConnection.getNextChannelId();
if (r13) {
rTCConnection.connect(a0.endpoint, a0.token);
r13 = void 0;
}
r1 = r13;
}
r2 = r1;
}
return r2;
},
CLEAR_REMOTE_DISCONNECT_VOICE_CHANNEL_ID: handleClearRemoteDisconnectVoiceChannelId,
REMOTE_SESSION_CONNECT: handleClearRemoteDisconnectVoiceChannelId,
CLEAR_LAST_SESSION_VOICE_CHANNEL_ID: function handleClearLastSessionVoiceChannelId() {
c2499_16 = null;
},
GUILD_DELETE: function handleGuildDelete({ guild }) {
if (rTCConnection != null && rTCConnection.guildId === guild.id) {
destroyRTCConnection();
return void 0;
}
return false;
},
CHANNEL_DELETE: handleChannelDelete,
THREAD_DELETE: handleChannelDelete,
CALL_DELETE: function handleCallDelete({ channelId: channelId4 }) {
if (rTCConnection != null && rTCConnection.channelId === channelId4) {
destroyRTCConnection();
return void 0;
}
return false;
},
APP_STATE_UPDATE: function handleFocus(a0) {
if (a0.state === AppStates.ACTIVE && rTCConnection != null) {
rTCConnection.resetBackoff("App state is active");
}
return false;
},
RTC_DEBUG_SET_SIMULCAST_OVERRIDE: function handleSimulcastDebugOverrideChanged({ userId: userId5, context, quality: quality2 }) {
if (rTCConnection != null) {
rTCConnection.setSimulcastDebugOverride(userId5, context, quality2);
}
}
});
import("../utils/AnalyticsUtils").then((result) => {
(0, result.addExtraAnalyticsDecorator)((a0) => {
a0.client_rtc_state = c2499_27.getState();
});
});
export default c2499_27;
+459
View File
@@ -0,0 +1,459 @@
// Metro module 10830 (f10831).
import _slicedToArray from "../_bundle/_slicedToArray";
import MediaEngineStore from "./MediaEngineStore";
import UserStore from "./UserStore";
import { RTCDebugSections } from "../Constants";
import { MediaEngineContextTypes, SimulcastOverrideQuality, Features } from "../_bundle/Module4250";
import { chooseReplayPath, open } from "../actions/RTCDebugActionCreators";
import { BaseConnectionEvent } from "../_bundle/Module4286";
import Dispatcher from "../Dispatcher";
import Module589 from "../_bundle/Module589";
import { HermesBuiltin } from "../_hermes/prelude";
function $mk85596($env) {
return (a0) => {
c7277_12[a0] = {};
};
}
let c7277_10, c7277_12, c7277_13, c7277_14, c7277_20, c7277_18, c7277_21;
let env7277;
const r3 = env7277 = {};
const updateStats = function updateStats(a0, r18 = {}, time = Date.now()) {
const r41 = {};
loop5: for (const r21 of Object.entries(a0)) {
const [r51, value] = r21;
const r54 = r18[r51];
const isArray = Array.isArray(value);
if (isArray) {
if (typeof value[0] === "object") {
const r94 = Array.isArray(r54) ? r54 : [];
const r96 = [];
r41[r51] = r96;
let r98 = 0;
if (0 < value.length) {
while (true) {
const r103 = r94[r98];
const r26 = typeof r103 === "object" ? r103 : {};
const r108 = r98;
r96.push(updateStats(value[r108], r26, time));
const r112 = r108 + 1;
r98 = r112;
if (!(r112 < value.length)) {
continue loop5;
}
}
}
} else {
r41[r51] = value;
}
} else {
if (typeof value === "object" && value !== null) {
r41[r51] = updateStats(value, typeof r54 === "object" && r54 !== null ? r54 : {}, time);
continue;
}
if (r51 in c7277_14 && typeof value === "number") {
const r69 = Array.isArray(r54) ? r54 : [];
r41[r51] = r69;
r69.push({
value,
time
});
if (!(r69.length > 600)) {
continue;
}
r69.shift();
continue;
}
r41[r51] = value;
}
}
return r41;
};
const MediaEngineContextTypes2 = MediaEngineContextTypes;
c7277_10 = `${MediaEngineContextTypes2.DEFAULT}:${RTCDebugSections.TRANSPORT}:${0}`;
env7277[11] = c7277_10;
c7277_12 = {};
c7277_13 = new Map();
c7277_14 = {
availableOutgoingBitrate: true,
bitrate: true,
bitrateTarget: true,
bytesReceived: true,
bytesSent: true,
encoderQualityPsnr: true,
encoderQualityVmaf: true,
encodeUsage: true,
frameRateDecode: true,
frameRateEncode: true,
frameRateInput: true,
frameRateNetwork: true,
frameRateRender: true,
keyFramesEncoded: true,
keyFramesDecoded: true,
inboundBitrateEstimate: true,
packetsLost: true,
packetsReceived: true,
packetsSent: true,
ping: true,
qpSum: true,
videoEntropy: true,
audioLevel: true,
screenshareCapturedFps: true,
screenshareCapturedFpsUnique: true
};
c7277_20 = void 0;
export class RTCDebugVideoOutputMap {
constructor(a0) {
this.state = a0;
}
static empty() {
const state = {};
const r7 = {
__proto__: c7277_20.prototype
};
r7.state = state;
return r7;
}
put(a0, a1, a2, a3) {
if (a3 === "") {
const state2 = {
...this.state
};
delete state2[`${a0}:${a1}:${a2}`];
const r49 = {
__proto__: c7277_20.prototype
};
r49.state = state2;
return r49;
}
const state = {};
state[`${a0}:${a1}:${a2}`] = a3;
HermesBuiltin.copyDataProperties(state, this.state);
const r28 = {
__proto__: c7277_20.prototype
};
r28.state = state;
return r28;
}
get(a0, a1, a2) {
const r17 = this.state[`${a0}:${a1}:${a2}`];
return r17 ?? null;
}
}
c7277_20 = RTCDebugVideoOutputMap;
env7277[15] = RTCDebugVideoOutputMap.empty();
env7277[16] = false;
env7277[17] = null;
c7277_18 = new Map();
Object.values(MediaEngineContextTypes2).forEach($mk85596(r3));
class RTCDebugStore extends Module589.Store {
static displayName = "RTCDebugStore";
constructor() {
super(...arguments);
}
initialize() {
this.waitFor(MediaEngineStore, UserStore);
}
getSection() {
return env7277[11];
}
getInboundStats(a0, a1) {
const r9 = this.getAllStats(a1)[0];
const r2 = r9 == null;
let r7 = void 0;
if (!r2) {
const rtp = r9.rtp;
r7 = rtp == null ? void 0 : rtp.inbound[a0];
}
const r6 = r7 == null ? void 0 : r7.find((item) => item.type === "video");
const codec = r6 == null ? void 0 : r6.codec.name;
const resolution = r6?.resolution;
const frameRateRender = r6?.frameRateRender;
const isArray = Array.isArray(frameRateRender);
return {
codec,
resolution,
bitrateEstimate: void 0,
fps: isArray ? frameRateRender.at(-1)?.value : frameRateRender
};
}
getOutboundStats(a0) {
const allStats = this.getAllStats(a0);
const transport = allStats[0]?.transport;
const r13 = allStats[0];
const r8 = r13 == null ? void 0 : r13.rtp?.outbound;
const r7 = r8 == null ? void 0 : r8.find((item) => item.type === "video");
const codec = r7 == null ? void 0 : r7.codec.name;
const resolution = r7?.resolution;
const availableOutgoingBitrate = transport?.availableOutgoingBitrate;
const isArray = Array.isArray(availableOutgoingBitrate);
const bitrateEstimate = isArray ? availableOutgoingBitrate.at(-1)?.value : availableOutgoingBitrate;
const frameRateEncode = r7?.frameRateEncode;
const isArray2 = Array.isArray(frameRateEncode);
return {
codec,
resolution,
bitrateEstimate,
fps: isArray2 ? frameRateEncode.at(-1)?.value : frameRateEncode
};
}
getAllStats(r4 = MediaEngineContextTypes.DEFAULT) {
return Object.values(c7277_12[r4]);
}
getVideoStreams() {
return env7277[15];
}
shouldRecordNextConnection() {
return env7277[16];
}
getSimulcastDebugOverride(a0, a1) {
const r8 = `${a0}:${a1}`;
return c7277_13.has(r8) ? c7277_13.get(r8) : SimulcastOverrideQuality.NO_OVERRIDE;
}
}
c7277_21 = RTCDebugStore;
const r109 = new RTCDebugStore(Dispatcher, {
RTC_DEBUG_MODAL_OPEN: function handleOpen({ section }) {
if (section == null) {
section = c7277_10;
}
env7277[11] = section;
},
RTC_DEBUG_MODAL_CLOSE: function handleFormClose() {
if (env7277[17] != null) {
env7277[17].destroy();
env7277[17] = null;
}
},
RTC_DEBUG_MODAL_SET_SECTION: function handleSetSection(a0) {
env7277[11] = a0.section;
},
RTC_DEBUG_MODAL_OPEN_REPLAY: function handleOpenReplay() {
chooseReplayPath();
},
RTC_DEBUG_MODAL_OPEN_REPLAY_AT_PATH: function handleOpenReplayAtPath({ path }) {
let replayConnection;
replayConnection = void 0;
const mediaEngine = MediaEngineStore.getMediaEngine();
if (env7277[17] != null) {
env7277[17].destroy();
env7277[17] = null;
}
if (mediaEngine.supports(Features.CONNECTION_REPLAY) && path.length !== 0) {
replayConnection = mediaEngine.createReplayConnection(MediaEngineContextTypes.DEFAULT, path);
if (replayConnection != null) {
env7277[17] = replayConnection;
replayConnection.on(BaseConnectionEvent.Video, (a0, a1, a2, a3) => {
Dispatcher.dispatch({
type: "RTC_DEBUG_MODAL_UPDATE_VIDEO_OUTPUT",
mediaEngineConnectionId: replayConnection.mediaEngineConnectionId,
userId: a0,
videoSsrc: a3 == null ? 0 : a3,
streamId: a1 == null ? "" : a1
});
});
Dispatcher.wait(() => open());
}
}
},
RTC_DEBUG_MODAL_UPDATE_VIDEO_OUTPUT: function handleUpdateVideoOutput(a0) {
env7277[15] = env7277[15].put(a0.mediaEngineConnectionId, a0.userId, a0.videoSsrc, a0.streamId);
},
RTC_DEBUG_SET_RECORDING_FLAG: function handleSetRecordingFlag(a0) {
env7277[16] = a0.value;
},
RTC_DEBUG_SET_SIMULCAST_OVERRIDE: function handleSetSimulcastDebugOverride(a0) {
c7277_13.set(`${a0.userId}:${a0.context}`, a0.quality);
},
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect(a0) {
if (a0.channelId != null) {
const r6 = env7277;
Object.values(MediaEngineContextTypes).forEach($mk85596(r6));
c7277_13.clear();
c7277_18.clear();
}
},
RTC_CONNECTION_VIDEO: function handleVideo(a0) {
if (a0.streamId === null) {
c7277_13.set(`${a0.userId}:${a0.context}`, SimulcastOverrideQuality.NO_OVERRIDE);
}
},
MEDIA_ENGINE_CONNECTION_STATS: function handleMediaEngineConnectionStats({ connectionStats }) {
Object.values(MediaEngineContextTypes).forEach((c26813_0) => {
connectionStats.filter((connectionStat) => connectionStat.context === c26813_0).forEach(({ stats }, index) => {
const r26 = c7277_12[c26813_0];
if (stats != null) {
const [r30, r11, r12] = env7277[11].split(":");
if (r30 === c26813_0 && parseInt(r12) === index && UserStore.getUser(r11) != null && !Object.keys(stats.rtp.inbound).includes(r11)) {
env7277[11] = c7277_10;
}
const r47 = Date.now();
const screenshare = stats.screenshare;
let r49 = stats;
if (screenshare != null) {
const r17 = `${c26813_0}:${index}`;
const r55 = c7277_18.get(r17);
const screenshare2 = r26[index]?.screenshare;
c7277_18.set(r17, r47);
r49 = stats;
if (r55 != null) {
r49 = stats;
if (screenshare2 != null) {
const r63 = (r47 - r55) / 1000;
r49 = stats;
if (0 < r63) {
const screenshare4 = {
...stats.screenshare
};
const screenshare3 = stats.screenshare;
let videohookFrames = screenshare3.videohookFrames;
if (videohookFrames == null) {
videohookFrames = 0;
}
let hybridDxgiFrames = screenshare3.hybridDxgiFrames;
if (hybridDxgiFrames == null) {
hybridDxgiFrames = 0;
}
const r73 = videohookFrames + hybridDxgiFrames;
let hybridGdiFrames = screenshare3.hybridGdiFrames;
if (hybridGdiFrames == null) {
hybridGdiFrames = 0;
}
const r75 = r73 + hybridGdiFrames;
let hybridVideohookFrames = screenshare3.hybridVideohookFrames;
if (hybridVideohookFrames == null) {
hybridVideohookFrames = 0;
}
const r77 = r75 + hybridVideohookFrames;
let hybridGraphicsCaptureFrames = screenshare3.hybridGraphicsCaptureFrames;
if (hybridGraphicsCaptureFrames == null) {
hybridGraphicsCaptureFrames = 0;
}
const r79 = r77 + hybridGraphicsCaptureFrames;
let quartzFrames = screenshare3.quartzFrames;
if (quartzFrames == null) {
quartzFrames = 0;
}
const r81 = r79 + quartzFrames;
let screenCaptureKitFrames = screenshare3.screenCaptureKitFrames;
if (screenCaptureKitFrames == null) {
screenCaptureKitFrames = 0;
}
const r20 = r81 + screenCaptureKitFrames;
let videohookFrames2 = screenshare2.videohookFrames;
if (videohookFrames2 == null) {
videohookFrames2 = 0;
}
let hybridDxgiFrames2 = screenshare2.hybridDxgiFrames;
if (hybridDxgiFrames2 == null) {
hybridDxgiFrames2 = 0;
}
const r85 = videohookFrames2 + hybridDxgiFrames2;
let hybridGdiFrames2 = screenshare2.hybridGdiFrames;
if (hybridGdiFrames2 == null) {
hybridGdiFrames2 = 0;
}
const r87 = r85 + hybridGdiFrames2;
let hybridVideohookFrames2 = screenshare2.hybridVideohookFrames;
if (hybridVideohookFrames2 == null) {
hybridVideohookFrames2 = 0;
}
const r89 = r87 + hybridVideohookFrames2;
let hybridGraphicsCaptureFrames2 = screenshare2.hybridGraphicsCaptureFrames;
if (hybridGraphicsCaptureFrames2 == null) {
hybridGraphicsCaptureFrames2 = 0;
}
const r91 = r89 + hybridGraphicsCaptureFrames2;
let quartzFrames2 = screenshare2.quartzFrames;
if (quartzFrames2 == null) {
quartzFrames2 = 0;
}
const r93 = r91 + quartzFrames2;
let screenCaptureKitFrames2 = screenshare2.screenCaptureKitFrames;
if (screenCaptureKitFrames2 == null) {
screenCaptureKitFrames2 = 0;
}
const r19 = r93 + screenCaptureKitFrames2;
let hybridDxgiFramesUnique = screenshare3.hybridDxgiFramesUnique;
if (hybridDxgiFramesUnique == null) {
hybridDxgiFramesUnique = 0;
}
let hybridGdiBitBltFramesUnique = screenshare3.hybridGdiBitBltFramesUnique;
if (hybridGdiBitBltFramesUnique == null) {
hybridGdiBitBltFramesUnique = 0;
}
const r97 = hybridDxgiFramesUnique + hybridGdiBitBltFramesUnique;
let hybridGdiPrintWindowFramesUnique = screenshare3.hybridGdiPrintWindowFramesUnique;
if (hybridGdiPrintWindowFramesUnique == null) {
hybridGdiPrintWindowFramesUnique = 0;
}
const r99 = r97 + hybridGdiPrintWindowFramesUnique;
let hybridVideohookFramesUnique = screenshare3.hybridVideohookFramesUnique;
if (hybridVideohookFramesUnique == null) {
hybridVideohookFramesUnique = 0;
}
const r101 = r99 + hybridVideohookFramesUnique;
let hybridGraphicsCaptureFramesUnique = screenshare3.hybridGraphicsCaptureFramesUnique;
if (hybridGraphicsCaptureFramesUnique == null) {
hybridGraphicsCaptureFramesUnique = 0;
}
const r103 = r101 + hybridGraphicsCaptureFramesUnique;
let hybridDxgiFramesUnique2 = screenshare2.hybridDxgiFramesUnique;
if (hybridDxgiFramesUnique2 == null) {
hybridDxgiFramesUnique2 = 0;
}
let hybridGdiBitBltFramesUnique2 = screenshare2.hybridGdiBitBltFramesUnique;
if (hybridGdiBitBltFramesUnique2 == null) {
hybridGdiBitBltFramesUnique2 = 0;
}
const r106 = hybridDxgiFramesUnique2 + hybridGdiBitBltFramesUnique2;
let hybridGdiPrintWindowFramesUnique2 = screenshare2.hybridGdiPrintWindowFramesUnique;
if (hybridGdiPrintWindowFramesUnique2 == null) {
hybridGdiPrintWindowFramesUnique2 = 0;
}
const r108 = r106 + hybridGdiPrintWindowFramesUnique2;
let hybridVideohookFramesUnique2 = screenshare2.hybridVideohookFramesUnique;
if (hybridVideohookFramesUnique2 == null) {
hybridVideohookFramesUnique2 = 0;
}
const r110 = r108 + hybridVideohookFramesUnique2;
let hybridGraphicsCaptureFramesUnique2 = screenshare2.hybridGraphicsCaptureFramesUnique;
if (hybridGraphicsCaptureFramesUnique2 == null) {
hybridGraphicsCaptureFramesUnique2 = 0;
}
const r112 = r110 + hybridGraphicsCaptureFramesUnique2;
HermesBuiltin.copyDataProperties(screenshare4, {
screenshareCapturedFps: Math.max(0, (r20 - r19) / r63),
screenshareCapturedFpsUnique: Math.max(0, (r103 - r112) / r63)
});
r49 = {
...stats,
screenshare: screenshare4
};
}
}
}
}
r26[index] = updateStats(r49, r26[index], r47);
} else {
delete r26[index];
}
});
});
}
});
export default r109;
export { c7277_10 as DEFAULT_SECTION };
export { c7277_14 as graphs };
export function keySection(a0, a1, a2) {
return `${a0}:${a1}:${a2}`;
}
export function parseSection(a0) {
const r8 = _slicedToArray(a0.split(":"), 2);
return {
context: r8[0],
section: r8[1]
};
}
export function getLastGraphValue(a0) {
return Array.isArray(a0) ? a0.at(-1)?.value : a0;
}
+79
View File
@@ -0,0 +1,79 @@
// Metro module 4282 (f4283).
import Durations from "../utils/Durations";
import Module589 from "../_bundle/Module589";
import Module12 from "../_bundle/Module12";
import Dispatcher from "../Dispatcher";
let c2521_2 = {
preferredRegions: null,
lastTestTimestamp: null,
lastGeoRankedOrder: null
};
let c2521_3 = c2521_2;
let c2521_4 = 1 * Durations.Millis.HOUR;
class RTCRegionStore extends Module589.DeviceSettingsStore {
static displayName = "RTCRegionStore";
static persistKey = "RTCRegionStore";
static migrations = [(a0) => {
if (a0.preferredRegion) {
a0.preferredRegions = [a0.preferredRegion];
} else {
a0.preferredRegions = null;
}
delete a0["preferredRegion"];
return a0;
}];
initialize(a0) {
c2521_3 = a0 == null ? c2521_2 : a0;
}
shouldIncludePreferredRegion() {
return c2521_3.preferredRegions != null;
}
getPreferredRegion() {
const preferredRegions = c2521_3.preferredRegions;
let r5 = preferredRegions == null ? void 0 : preferredRegions[0];
if (r5 == null) {
r5 = null;
}
return r5;
}
getPreferredRegions() {
return c2521_3.preferredRegions;
}
getRegion(a0) {
if (a0 != null) {
return a0.substr(0, a0.search(/\d/));
}
}
getUserAgnosticState() {
return c2521_3;
}
shouldPerformLatencyTest(a0) {
let r1 = c2521_3.preferredRegions === null;
if (!r1) {
let lastGeoRankedOrder = c2521_3.lastGeoRankedOrder;
if (lastGeoRankedOrder == null) {
lastGeoRankedOrder = [];
}
r1 = !Module12.isEqual(a0, lastGeoRankedOrder);
}
if (!r1) {
const r19 = Date.now();
let lastTestTimestamp = c2521_3.lastTestTimestamp;
if (lastTestTimestamp == null) {
lastTestTimestamp = 0;
}
r1 = r19 - lastTestTimestamp >= c2521_4;
}
return r1;
}
}
const rTCRegionStore = new RTCRegionStore(Dispatcher, {
RTC_LATENCY_TEST_COMPLETE: function handleCompletedRTCLatencyTest(a0) {
if (a0.latencyRankedRegions.length > 0) {
c2521_3.lastGeoRankedOrder = a0.geoRankedRegions;
c2521_3.preferredRegions = a0.latencyRankedRegions;
}
c2521_3.lastTestTimestamp = Date.now();
}
});
export default rTCRegionStore;
File diff suppressed because it is too large. Load diff
+55
View File
@@ -0,0 +1,55 @@
// Metro module 15640 (f15641).
import GuildStore from "./GuildStore";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c11163_3 = null;
let c11163_4 = {};
class RegionStore extends Module589.Store {
static displayName = "RegionStore";
initialize() {
this.waitFor(GuildStore);
}
getOptimalRegion(r5 = null) {
const regions = this.getRegions(r5);
const r2 = regions != null;
let r8 = null;
if (r2) {
let r11 = regions.find((region) => region.optimal);
if (r11 == null) {
r11 = Module12.sample(regions);
}
r8 = r11;
}
return r8;
}
getOptimalRegionId(r3 = null) {
const optimalRegion = this.getOptimalRegion(r3);
return optimalRegion != null ? optimalRegion.id : null;
}
getRandomRegion(r4 = null) {
const regions = this.getRegions(r4);
return regions != null ? Module12.sample(regions) : null;
}
getRandomRegionId(r3 = null) {
const randomRegion = this.getRandomRegion(r3);
return randomRegion != null ? randomRegion.id : null;
}
getRegions(a0) {
return a0 != null ? c11163_4[a0] : c11163_3;
}
}
const regionStore = new RegionStore(Dispatcher, {
LOAD_REGIONS: function handleLoadRegions(a0) {
const r11 = Module12.sortBy(a0.regions, (a0) => a0.name);
if (a0.guildId != null) {
c11163_4[a0.guildId] = r11;
} else {
c11163_3 = r11;
}
},
GUILD_DELETE: function handleDeleteGuild(a0) {
delete c11163_4[a0.guild.id];
}
});
export default regionStore;
+551
View File
@@ -0,0 +1,551 @@
// Metro module 3826 (f3827).
import _slicedToArray from "../_bundle/_slicedToArray";
import MessageRecord from "../records/MessageRecord";
import UserStore from "./UserStore";
import { RelationshipTypes } from "../Constants";
import Dispatcher from "../Dispatcher";
import Module589 from "../_bundle/Module589";
let c2163_6, c2163_7, c2163_8, c2163_9, c2163_10, c2163_11, c2163_12, c2163_13, c2163_14, c2163_15, c2163_16, size, size2, c2163_19, c2163_20, removeRelationship, recountPending;
const upsertRelationship = function upsertRelationship(a0, a1) {
const r6 = c2163_6.get(a0);
if (r6 !== a1) {
if (r6 != null) {
const r14 = c2163_20.get(r6);
if (r14 != null) {
r14.delete(a0);
}
}
c2163_6.set(a0, a1);
const r21 = c2163_20.get(a1);
if (r21 != null) {
r21.add(a0);
} else {
c2163_20.set(a1, new Set([a0]));
}
c2163_19.friends = void 0;
c2163_19.blocked = void 0;
c2163_19.ignored = void 0;
c2163_19.blockedOrIgnored = void 0;
}
};
removeRelationship = function removeRelationship(item) {
const r5 = c2163_6.get(item);
if (r5 != null) {
c2163_6.delete(item);
const r10 = c2163_20.get(r5);
if (r10 != null) {
r10.delete(item);
}
c2163_19.friends = void 0;
c2163_19.blocked = void 0;
c2163_19.ignored = void 0;
c2163_19.blockedOrIgnored = void 0;
}
};
recountPending = function recountPending() {
size = c2163_10.size;
size2 = c2163_12.size;
const r7 = Math;
let r17 = c2163_20.get(RelationshipTypes.PENDING_INCOMING)?.size;
if (r17 == null) {
r17 = 0;
}
c2163_16 = r7.max(r17 - size - size2, 0);
c2163_14 = c2163_14 + 1;
};
c2163_6 = new Map();
c2163_7 = {};
c2163_8 = {};
c2163_9 = {};
c2163_10 = new Set();
c2163_11 = new Set();
c2163_12 = new Set();
c2163_13 = {};
c2163_14 = 0;
c2163_15 = {};
c2163_16 = 0;
size = 0;
size2 = 0;
c2163_19 = {
friends: void 0,
blocked: void 0,
ignored: void 0,
blockedOrIgnored: void 0
};
c2163_20 = new Map();
class RelationshipStore extends Module589.Store {
static displayName = "RelationshipStore";
initialize() {
this.waitFor(UserStore);
}
isFriend(a0) {
return a0 != null && c2163_6.get(a0) === RelationshipTypes.FRIEND;
}
isBlockedOrIgnored(a0) {
return this.isBlocked(a0) || this.isIgnored(a0);
}
isBlockedOrIgnoredForMessage(a0) {
return this.isBlockedForMessage(a0) || this.isIgnoredForMessage(a0);
}
isBlocked(a0) {
return a0 != null && c2163_6.get(a0) === RelationshipTypes.BLOCKED;
}
isBlockedForMessage(a0) {
if (a0.author != null && c2163_6.get(a0.author.id) === RelationshipTypes.BLOCKED) {
return true;
}
const r1 = a0 instanceof MessageRecord;
const isBlocked2 = this.isBlocked;
if (r1) {
const interactionMetadata = a0.interactionMetadata;
if (isBlocked2.call(this, interactionMetadata == null ? void 0 : interactionMetadata.user?.id)) {
return true;
}
} else {
const interaction_metadata = a0.interaction_metadata;
if (isBlocked2.call(this, interaction_metadata == null ? void 0 : interaction_metadata.user?.id)) {
return true;
}
}
return false;
}
isIgnored(a0) {
return a0 != null && (c2163_6.get(a0) !== RelationshipTypes.BLOCKED && c2163_11.has(a0));
}
isIgnoredForMessage(a0) {
if (a0.author != null && this.isIgnored(a0.author.id)) {
return true;
}
const r1 = a0 instanceof MessageRecord;
const isIgnored2 = this.isIgnored;
if (r1) {
const interactionMetadata = a0.interactionMetadata;
if (isIgnored2.call(this, interactionMetadata == null ? void 0 : interactionMetadata.user?.id)) {
return true;
}
} else {
const interaction_metadata = a0.interaction_metadata;
if (isIgnored2.call(this, interaction_metadata == null ? void 0 : interaction_metadata.user?.id)) {
return true;
}
}
return false;
}
isUnfilteredPendingIncoming(a0) {
return c2163_6.get(a0) === RelationshipTypes.PENDING_INCOMING && !this.isSpam(a0) && !this.isIgnored(a0);
}
getPendingCount() {
return c2163_16;
}
getSpamCount() {
return size;
}
getPendingIgnoredCount() {
return size2;
}
getOutgoingCount() {
let r9 = c2163_20.get(RelationshipTypes.PENDING_OUTGOING)?.size;
if (r9 == null) {
r9 = 0;
}
return r9;
}
getFriendCount() {
let r9 = c2163_20.get(RelationshipTypes.FRIEND)?.size;
if (r9 == null) {
r9 = 0;
}
return r9;
}
getRelationshipCount() {
return c2163_6.size;
}
getMutableRelationships() {
return c2163_6;
}
getVersion() {
return c2163_14;
}
isSpam(a0) {
return c2163_10.has(a0);
}
getRelationshipType(a0) {
let r5 = c2163_6.get(a0);
if (r5 == null) {
r5 = RelationshipTypes.NONE;
}
return r5;
}
getNickname(a0) {
return c2163_7[a0];
}
getSince(a0) {
return c2163_8[a0];
}
getSinces() {
return c2163_8;
}
getNote(a0) {
return c2163_9[a0];
}
getFriendIDs() {
if (c2163_19.friends == null) {
const r4 = Array;
let r11 = c2163_20.get(RelationshipTypes.FRIEND);
if (r11 == null) {
r11 = [];
}
c2163_19.friends = r4.from(r11);
}
return c2163_19.friends;
}
getBlockedIDs() {
if (c2163_19.blocked == null) {
const r4 = Array;
let r11 = c2163_20.get(RelationshipTypes.BLOCKED);
if (r11 == null) {
r11 = [];
}
c2163_19.blocked = r4.from(r11);
}
return c2163_19.blocked;
}
getIgnoredIDs() {
if (c2163_19.ignored == null) {
c2163_19.ignored = Array.from(c2163_11.values()).filter((item) => this.isIgnored(item));
}
return c2163_19.ignored;
}
getBlockedOrIgnoredIDs() {
if (c2163_19.blockedOrIgnored == null) {
const set = new Set(c2163_11);
const r25 = c2163_20.get(RelationshipTypes.BLOCKED);
if (r25 != null) {
for (const item of r25) {
set.add(item);
}
}
c2163_19.blockedOrIgnored = Array.from(set.values());
}
return c2163_19.blockedOrIgnored;
}
getOriginApplicationId(a0) {
return c2163_13[a0];
}
isStranger(a0) {
if (c2163_15[a0] != null) {
if (!(c2163_15[a0].expiry < Date.now())) {
return c2163_15[a0].isStranger;
}
delete c2163_15[a0];
}
}
}
const relationshipStore = new RelationshipStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
c2163_6.clear();
c2163_20.clear();
c2163_7 = {};
c2163_8 = {};
c2163_9 = {};
c2163_11.clear();
c2163_10.clear();
c2163_12.clear();
c2163_19.friends = void 0;
c2163_19.blocked = void 0;
c2163_19.ignored = void 0;
c2163_19.blockedOrIgnored = void 0;
c2163_13 = {};
c2163_15 = {};
a0.relationships.forEach((relationship) => {
const { id, type } = relationship;
const r7 = c2163_6.get(id);
if (r7 !== type) {
if (r7 != null) {
const r15 = c2163_20.get(r7);
if (r15 != null) {
r15.delete(id);
}
}
c2163_6.set(id, type);
const r22 = c2163_20.get(type);
if (r22 != null) {
r22.add(id);
} else {
c2163_20.set(type, new Set([id]));
}
c2163_19.friends = void 0;
c2163_19.blocked = void 0;
c2163_19.ignored = void 0;
c2163_19.blockedOrIgnored = void 0;
}
if (relationship.nickname != null) {
c2163_7[relationship.id] = relationship.nickname;
}
if (relationship.since != null) {
c2163_8[relationship.id] = relationship.since;
}
if (relationship.note != null) {
c2163_9[relationship.id] = relationship.note;
}
if (relationship.is_spam_request) {
c2163_10.add(relationship.id);
}
if (relationship.origin_application_id != null) {
c2163_13[relationship.id] = relationship.origin_application_id;
}
if (relationship.user_ignored) {
c2163_11.add(relationship.id);
if (relationship.type === RelationshipTypes.PENDING_INCOMING) {
c2163_12.add(relationship.id);
}
}
});
size = c2163_10.size;
size2 = c2163_12.size;
const r34 = Math;
let r40 = c2163_20.get(RelationshipTypes.PENDING_INCOMING)?.size;
if (r40 == null) {
r40 = 0;
}
c2163_16 = r34.max(r40 - size - size2, 0);
c2163_14 = c2163_14 + 1;
},
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
c2163_6.clear();
c2163_20.clear();
for (const relationship of a0.relationships) {
const r32 = _slicedToArray(relationship, 2);
upsertRelationship(r32[0], r32[1]);
}
recountPending();
},
RELATIONSHIP_ADD: function handleRelationshipAdd(a0) {
const r19 = c2163_6.get(a0.relationship.id);
const id = a0.relationship.id;
const type = a0.relationship.type;
const r11 = c2163_6.get(id);
if (r11 !== type) {
if (r11 != null) {
const r24 = c2163_20.get(r11);
if (r24 != null) {
r24.delete(id);
}
}
c2163_6.set(id, type);
const r31 = c2163_20.get(type);
if (r31 != null) {
r31.add(id);
} else {
c2163_20.set(type, new Set([id]));
}
c2163_19.friends = void 0;
c2163_19.blocked = void 0;
c2163_19.ignored = void 0;
c2163_19.blockedOrIgnored = void 0;
}
if (a0.relationship.nickname != null) {
const r44 = {
...c2163_7
};
r44[a0.relationship.id] = a0.relationship.nickname;
c2163_7 = r44;
}
if (a0.relationship.since != null) {
const r53 = {
...c2163_8
};
r53[a0.relationship.id] = a0.relationship.since;
c2163_8 = r53;
}
if (a0.relationship.note != null) {
const r63 = {
...c2163_9
};
r63[a0.relationship.id] = a0.relationship.note;
c2163_9 = r63;
}
if (a0.relationship.originApplicationId != null) {
const r73 = {
...c2163_13
};
r73[a0.relationship.id] = a0.relationship.originApplicationId;
c2163_13 = r73;
}
if (a0.relationship.isSpamRequest) {
c2163_10.add(a0.relationship.id);
} else {
c2163_10.delete(a0.relationship.id);
}
if (a0.relationship.userIgnored) {
c2163_11.add(a0.relationship.id);
if (a0.relationship.type === RelationshipTypes.PENDING_INCOMING) {
c2163_12.add(a0.relationship.id);
} else if (a0.relationship.type === RelationshipTypes.FRIEND) {
c2163_12.delete(a0.relationship.id);
}
} else {
c2163_11.delete(a0.relationship.id);
c2163_12.delete(a0.relationship.id);
}
size = c2163_10.size;
size2 = c2163_12.size;
const r131 = Math;
let r139 = c2163_20.get(RelationshipTypes.PENDING_INCOMING)?.size;
if (r139 == null) {
r139 = 0;
}
c2163_16 = r131.max(r139 - size - size2, 0);
c2163_14 = c2163_14 + 1;
if (a0.relationship.type === RelationshipTypes.FRIEND && r19 === RelationshipTypes.PENDING_OUTGOING) {
Dispatcher.dispatch({
type: "FRIEND_REQUEST_ACCEPTED",
user: a0.relationship.user
});
}
},
RELATIONSHIP_REMOVE: function handleRelationshipRemove(a0) {
const id = a0.relationship.id;
const r9 = c2163_6.get(id);
if (r9 != null) {
c2163_6.delete(id);
const r17 = c2163_20.get(r9);
if (r17 != null) {
r17.delete(id);
}
c2163_19.friends = void 0;
c2163_19.blocked = void 0;
c2163_19.ignored = void 0;
c2163_19.blockedOrIgnored = void 0;
}
if (c2163_7[a0.relationship.id] != null) {
const r25 = {
...c2163_7
};
c2163_7 = r25;
delete r25[a0.relationship.id];
}
if (c2163_8[a0.relationship.id] != null) {
const r34 = {
...c2163_8
};
c2163_8 = r34;
delete r34[a0.relationship.id];
}
if (c2163_9[a0.relationship.id] != null) {
const r45 = {
...c2163_9
};
c2163_9 = r45;
delete r45[a0.relationship.id];
}
if (c2163_13[a0.relationship.id] != null) {
const r56 = {
...c2163_13
};
c2163_13 = r56;
delete r56[a0.relationship.id];
}
if (!a0.relationship.userIgnored) {
c2163_11.delete(a0.relationship.id);
}
c2163_12.delete(a0.relationship.id);
c2163_10.delete(a0.relationship.id);
size = c2163_10.size;
size2 = c2163_12.size;
const r83 = Math;
let r91 = c2163_20.get(RelationshipTypes.PENDING_INCOMING)?.size;
if (r91 == null) {
r91 = 0;
}
c2163_16 = r83.max(r91 - size - size2, 0);
c2163_14 = c2163_14 + 1;
},
RELATIONSHIP_UPDATE: function handleRelationshipUpdate({ relationship }) {
const { id, type } = relationship;
const r10 = c2163_6.get(id);
if (r10 !== type) {
if (r10 != null) {
const r19 = c2163_20.get(r10);
if (r19 != null) {
r19.delete(id);
}
}
c2163_6.set(id, type);
const r26 = c2163_20.get(type);
if (r26 != null) {
r26.add(id);
} else {
c2163_20.set(type, new Set([id]));
}
c2163_19.friends = void 0;
c2163_19.blocked = void 0;
c2163_19.ignored = void 0;
c2163_19.blockedOrIgnored = void 0;
}
if (relationship.since == null) {
delete c2163_8[relationship.id];
} else {
c2163_8[relationship.id] = relationship.since;
}
if (relationship.nickname == null) {
delete c2163_7[relationship.id];
} else {
c2163_7[relationship.id] = relationship.nickname;
}
if (relationship.note == null) {
delete c2163_9[relationship.id];
} else {
c2163_9[relationship.id] = relationship.note;
}
if (relationship.isSpamRequest) {
c2163_10.add(relationship.id);
} else {
c2163_10.delete(relationship.id);
}
if (c2163_15[relationship.id] != null) {
delete c2163_15[relationship.id];
}
if (relationship.originApplicationId == null) {
delete c2163_13[relationship.id];
} else {
c2163_13[relationship.id] = relationship.originApplicationId;
}
if (relationship.userIgnored) {
c2163_11.add(relationship.id);
if (relationship.type === RelationshipTypes.PENDING_INCOMING) {
c2163_12.add(relationship.id);
}
} else {
c2163_11.delete(relationship.id);
c2163_12.delete(relationship.id);
}
size = c2163_10.size;
size2 = c2163_12.size;
const r104 = Math;
let r112 = c2163_20.get(RelationshipTypes.PENDING_INCOMING)?.size;
if (r112 == null) {
r112 = 0;
}
c2163_16 = r104.max(r112 - size - size2, 0);
c2163_14 = c2163_14 + 1;
},
RELATIONSHIP_PENDING_INCOMING_REMOVED: function handlePendingIncomingRemoved() {
for (const item of c2163_6.keys()) {
if (c2163_6.get(item) === RelationshipTypes.PENDING_INCOMING) {
removeRelationship(item);
c2163_10.delete(item);
c2163_12.delete(item);
delete c2163_15[item];
}
}
recountPending();
},
UPDATE_STRANGER_STATUS: function handleUpdateStrangerStatus(a0) {
c2163_15[a0.userId] = {
expiry: Date.now() + 300000,
isStranger: a0.isStranger
};
}
});
export default relationshipStore;
+508
View File
@@ -0,0 +1,508 @@
// Metro module 1931 (f1932).
import { THREAD_CHANNEL_TYPES, isGuildTextChannelType } from "../records/ChannelRecord";
import AuthenticationStore from "./AuthenticationStore";
import ChannelStore from "./ChannelStore";
import GuildChannelStore from "./GuildChannelStore";
import GuildStore from "./GuildStore";
import MediaEngineStore from "./MediaEngineStore";
import PermissionStore from "./PermissionStore";
import SelectedGuildStore from "./SelectedGuildStore";
import { Permissions, Routes, ME, ChannelTypes } from "../Constants";
import "../modules/channel/ChannelConstants";
import { Storage } from "../_bundle/Module595";
import Module12 from "../_bundle/Module12";
import { isNotNullish } from "../utils/GlobalUtils";
import { combine } from "../_bundle/HighLow";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
function $mk70646($env) {
return (a0, a1) => {
let r1 = a0 != null;
if (r1) {
const r3 = $env.$parent;
r1 = r3[14].hasChannel(a0) || a0 === r3[6] || r3[28].has(a0) || (0, r3[23])(a0);
}
if (!r1) {
const r12 = $env;
const r14 = $env.$parent;
delete r14[25][a1];
delete r14[26][a1];
r12[0] = true;
}
};
}
function $mk70647($env) {
return (a0, a1) => {
let r1 = a0 != null;
if (r1) {
const r3 = $env.$parent;
r1 = r3[14].hasChannel(a0) || r3[28].has(a0);
}
if (!r1) {
const r9 = $env;
delete $env.$parent[27][a1];
r9[0] = true;
}
};
}
let navigateAwayFromChannel, c1617_24, c1617_30;
let $mk70645 = function() {
return (a0) => {
const basicChannel = ChannelStore.getBasicChannel(a0);
return env1617[28].has(a0) || basicChannel != null && THREAD_CHANNEL_TYPES.has(basicChannel.type);
};
}, $mk70648 = function() {
return (a0) => {
const r9 = env1617[25][a0.id];
if (env1617[27][a0.id] == null) {
const id = a0.id;
if (id != null && r9 != null && env1617[27][id] !== r9) {
const channel = ChannelStore.getChannel(r9);
const r17 = channel != null && (0, isGuildTextChannelType)(channel.type);
const r20 = channel == null ? void 0 : channel.getGuildId();
if (!(r17 ? !(r20 === id) : !r17)) {
env1617[27][id] = r9;
}
}
}
};
};
let env1617 = {};
export function handleConnectionOpen(a0) {
env1617[4] = a0.sessionId;
if (env1617[8] != null) {
const channel = ChannelStore.getChannel(env1617[8]);
if (!(channel != null && (channel.isPrivate() || PermissionStore.can(combine(Permissions.VIEW_CHANNEL, Permissions.CONNECT), channel)))) {
env1617[8] = null;
}
}
let env13348;
const r29 = env13348 = {
$parent: env1617
};
env13348[0] = false;
const guildsArray = GuildStore.getGuildsArray();
Module12.each(env1617[25], $mk70646(r29));
Module12.each(env1617[27], $mk70647(r29));
guildsArray.forEach($mk70648());
if (env1617[9] != null && Date.now() - env1617[9] >= 300000) {
env1617[8] = null;
env13348[0] = true;
}
if (env13348[0]) {
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
}
}
navigateAwayFromChannel = function navigateAwayFromChannel(a0, a1) {
env1617[28].delete(a0);
let r5 = a1;
if (a1 == null) {
const guildId = SelectedGuildStore.getGuildId();
r5 = env1617[25][String(guildId)] === a0 ? guildId : a1;
}
GuildStore.getGuild(r5);
const r25 = env1617[8];
let r26 = false;
if (r25 === a0) {
env1617[8] = null;
r26 = true;
}
if (r26) {
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
}
};
const handleChannelDelete = function handleChannelDelete(a0) {
a0.type;
const channel = a0.channel;
navigateAwayFromChannel(channel.id, channel.guild_id, channel.parent_id);
};
Routes;
c1617_24 = "SelectedChannelStore";
env1617[25] = {};
env1617[26] = {};
env1617[27] = {};
env1617[28] = new Set();
class SelectedChannelStore extends Module589.Store {
static displayName = "SelectedChannelStore";
constructor() {
super(...arguments);
}
initialize() {
let r23 = Storage.get(c1617_24);
if (r23 == null) {
r23 = {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27]
};
}
if (r23.knownThreadIds != null) {
env1617[28] = new Set(r23.knownThreadIds);
}
env1617[8] = r23.selectedVoiceChannelId;
env1617[7] = r23.lastChannelFollowingDestination;
env1617[9] = r23.lastConnectedTime;
let mostRecentSelectedTextChannelIds = r23.mostRecentSelectedTextChannelIds;
if (mostRecentSelectedTextChannelIds == null) {
mostRecentSelectedTextChannelIds = {};
}
env1617[27] = mostRecentSelectedTextChannelIds;
if (r23.selectedChannelIds != null) {
env1617[25] = r23.selectedChannelIds;
}
this.mustEmitChanges((a0) => a0.type !== "CONNECTION_OPEN" && a0.type !== "VOICE_STATE_UPDATES");
this.waitFor(AuthenticationStore, ChannelStore, GuildChannelStore, GuildStore, MediaEngineStore, PermissionStore, SelectedGuildStore);
}
getChannelId(a0, r3 = true) {
let r15;
let r4 = a0;
let r5 = null;
if (a0 !== ME) {
if (a0 == null) {
r4 = SelectedGuildStore.getGuildId();
}
if (r4 == null) {
r4 = null;
}
r5 = r4;
}
const r12 = String(r5);
const r14 = env1617[25][r12];
if (r3) {
let r16 = r14;
if (r14 == null) {
const r2 = r12 != null;
let r17 = void 0;
if (r2) {
const defaultChannel = GuildChannelStore.getDefaultChannel(r12);
r17 = defaultChannel != null ? defaultChannel.id : void 0;
}
r16 = r17;
}
r15 = r16;
} else {
r15 = r14;
}
return r15;
}
getVoiceChannelId() {
return MediaEngineStore.isSupported() ? env1617[8] : null;
}
getMostRecentSelectedTextChannelId(a0) {
const r1 = a0 == null;
let r2 = null;
if (!r1) {
let r6 = env1617[27][a0];
if (r6 == null) {
r6 = null;
}
r2 = r6;
}
return r2;
}
getCurrentlySelectedChannelId(a0) {
return a0 != null ? env1617[25][a0] : env1617[6];
}
getLastSelectedChannelId(a0) {
return a0 != null ? env1617[26][a0] : env1617[5];
}
getLastSelectedChannels(a0) {
return env1617[26][a0];
}
getLastChannelFollowingDestination() {
return env1617[7];
}
}
c1617_30 = SelectedChannelStore;
const r91 = new SelectedChannelStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
env1617[4] = a0.sessionId;
env1617[8] = a0.selectedVoiceChannelId;
env1617[25] = {};
env1617[26] = {};
env1617[6] = a0.selectedChannelId;
env1617[25][a0.selectedGuildId] = a0.selectedChannelId;
const selectedGuildId = a0.selectedGuildId;
const r20 = env1617[6];
if (selectedGuildId != null && r20 != null && env1617[27][selectedGuildId] !== r20) {
const channel = ChannelStore.getChannel(r20);
const r25 = channel != null && (0, isGuildTextChannelType)(channel.type);
const r28 = channel == null ? void 0 : channel.getGuildId();
if (!(r25 ? !(r28 === selectedGuildId) : !r25)) {
env1617[27][selectedGuildId] = r20;
}
}
let env13349;
const r32 = env13349 = {
$parent: env1617
};
env13349[0] = false;
const guildsArray = GuildStore.getGuildsArray();
Module12.each(env1617[25], $mk70646(r32));
Module12.each(env1617[27], $mk70647(r32));
guildsArray.forEach($mk70648());
if (env1617[9] != null && Date.now() - env1617[9] >= 300000) {
env1617[8] = null;
env13349[0] = true;
}
},
CONNECTION_CLOSED: function handleConnectionClosed() {
env1617[4] = null;
},
CHANNEL_SELECT: function handleChannelSelect(a0) {
const guildId = a0.guildId;
let channelId = a0.channelId;
if (guildId === void 0) {
return false;
}
if (channelId == null) {
const r2 = guildId != null;
let r16 = void 0;
if (r2) {
const defaultChannel = GuildChannelStore.getDefaultChannel(guildId);
r16 = defaultChannel != null ? defaultChannel.id : void 0;
}
channelId = r16;
}
if (env1617[6] != null && channelId !== env1617[6]) {
env1617[5] = env1617[6];
}
env1617[6] = channelId;
if (guildId != null && channelId != null && env1617[27][guildId] !== channelId) {
const channel = ChannelStore.getChannel(channelId);
const r27 = channel != null && (0, isGuildTextChannelType)(channel.type);
const r31 = channel == null ? void 0 : channel.getGuildId();
if (!(r27 ? !(r31 === guildId) : !r27)) {
env1617[27][guildId] = channelId;
}
}
if (env1617[25][String(guildId)] !== channelId) {
env1617[26][String(guildId)] = env1617[25][String(guildId)];
env1617[25][String(guildId)] = env1617[6];
}
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
},
CHANNEL_CREATE: function handleChannelCreate({ channel }) {
const type = channel.type;
if (!(ChannelTypes.GUILD_ANNOUNCEMENT !== type && ChannelTypes.GUILD_TEXT !== type)) {
const guild_id = channel.guild_id;
if (guild_id != null && env1617[27][guild_id] == null) {
env1617[27][guild_id] = channel.id;
}
if (guild_id != null && env1617[25][guild_id] == null) {
const r18 = env1617[25];
const r2 = guild_id != null;
let r19 = void 0;
if (r2) {
const defaultChannel = GuildChannelStore.getDefaultChannel(guild_id);
r19 = defaultChannel != null ? defaultChannel.id : void 0;
}
r18[guild_id] = r19;
return true;
}
}
return false;
},
CHANNEL_DELETE: handleChannelDelete,
CHANNEL_UPDATES: function handleChannelUpdates(a0) {
for (const channel of a0.channels) {
if (channel.isScheduledForDeletion()) {
THREAD_CHANNEL_TYPES.has(channel.type);
navigateAwayFromChannel(channel.id, channel.guild_id, channel.parent_id);
}
}
},
THREAD_DELETE: handleChannelDelete,
GUILD_CREATE: function handleGuildCreate({ guild }) {
if (env1617[25][guild.id] == null) {
const id = guild.id;
const r2 = id != null;
let r17 = void 0;
if (r2) {
const defaultChannel = GuildChannelStore.getDefaultChannel(id);
r17 = defaultChannel != null ? defaultChannel.id : void 0;
}
env1617[25][guild.id] = r17;
const id2 = guild.id;
if (id2 != null && r17 != null && env1617[27][id2] !== r17) {
const channel = ChannelStore.getChannel(r17);
const r28 = channel != null && (0, isGuildTextChannelType)(channel.type);
const r32 = channel == null ? void 0 : channel.getGuildId();
if (!(r28 ? !(r32 === id2) : !r28)) {
env1617[27][id2] = r17;
}
}
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
}
},
GUILD_DELETE: function handleGuildDelete({ guild }) {
const { id, unavailable } = guild;
if (env1617[8] === env1617[25][id]) {
env1617[8] = null;
}
if (unavailable) {
return false;
}
delete env1617[27][id];
delete env1617[25][id];
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
},
VOICE_CHANNEL_SELECT: function handleVoiceChannelSelect({ channelId }) {
if (channelId == null) {
const guild_id = ChannelStore.getChannel(env1617[8])?.guild_id;
if (guild_id != null && guild_id !== SelectedGuildStore.getGuildId() && env1617[25][guild_id] === env1617[8]) {
const r26 = env1617[25];
const r27 = guild_id != null;
let r28 = void 0;
if (r27) {
const defaultChannel = GuildChannelStore.getDefaultChannel(guild_id);
r28 = defaultChannel != null ? defaultChannel.id : void 0;
}
r26[guild_id] = r28;
}
}
env1617[8] = channelId;
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((acc, voiceState) => {
if (voiceState.sessionId === env1617[4]) {
clearInterval(env1617[10]);
const channel3 = ChannelStore.getChannel(env1617[8]);
if (!(voiceState.guildId !== (channel3 == null ? void 0 : channel3.getGuildId()) && voiceState.channelId == null)) {
env1617[8] = voiceState.channelId;
}
env1617[9] = Date.now();
if (env1617[8] != null) {
env1617[10] = setInterval(() => {
env1617[9] = Date.now();
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
}, 60000);
}
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
} else {
if (voiceState.userId !== AuthenticationStore.getId()) {
return acc;
}
clearInterval(env1617[10]);
env1617[10] = void 0;
env1617[9] = 0;
const channel = ChannelStore.getChannel(env1617[8]);
const r28 = channel == null ? void 0 : channel.getGuildId();
const channel2 = ChannelStore.getChannel(voiceState.channelId);
const r34 = channel2 == null ? void 0 : channel2.getGuildId();
if (r28 != null && r34 === r28 || env1617[8] === voiceState.channelId) {
env1617[8] = null;
}
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
}
return true;
}, false);
},
CHANNEL_FOLLOWER_CREATED: function handleChannelFollowingDestinationUpdate({ channelId, guildId }) {
if (!(env1617[7] != null && channelId === env1617[7].channelId)) {
env1617[7] = {
channelId,
guildId
};
Storage.set(c1617_24, {
selectedChannelId: env1617[6],
selectedVoiceChannelId: env1617[8],
lastChannelFollowingDestination: env1617[7],
lastConnectedTime: env1617[9],
selectedChannelIds: env1617[25],
mostRecentSelectedTextChannelIds: env1617[27],
knownThreadIds: Module12(env1617[25]).values().concat(Module12.values(env1617[27])).filter(isNotNullish).uniq().filter($mk70645()).value()
});
}
},
LOGOUT: function handleLogout() {
env1617[25] = {};
env1617[6] = null;
env1617[5] = void 0;
env1617[27] = {};
env1617[7] = {};
env1617[8] = null;
Storage.remove(c1617_24);
}
});
export default r91;
export function findFirstVoiceChannelId(a0) {
return Module12.find(ChannelStore.getMutableBasicGuildChannelsForGuild(a0), (a0) => a0.type === ChannelTypes.GUILD_VOICE)?.id;
}
+185
View File
@@ -0,0 +1,185 @@
// Metro module 4006 (f4007).
import UserGuildJoinRequestStore from "../modules/guild_member_verification/UserGuildJoinRequestStore";
import AuthenticationStore from "./AuthenticationStore";
import DefaultRouteStore from "./DefaultRouteStore";
import GuildStore from "./GuildStore";
import { ME, Routes } from "../Constants";
import { replaceWith } from "../modules/routing/router_utils";
import Module589 from "../_bundle/Module589";
import { matchPath } from "../modules/routing/matchPathCompat";
import { RouteParam } from "../modules/routing/RouteUtils";
import Dispatcher from "../Dispatcher";
let selectedGuildId, guildId, selectedGuildTimestampMillis, $mk73416 = function() {
return function pickFallbackGuildId(a0) {
if (guildId != null && GuildStore.getGuild(guildId) != null) {
return guildId;
}
let r28 = null;
let r29 = 0;
for (const item of Object.keys(selectedGuildTimestampMillis)) {
if (item !== a0) {
const r43 = selectedGuildTimestampMillis[item];
if (r43 > r29 && GuildStore.getGuild(item) != null) {
r28 = item;
r29 = r43;
}
}
}
if (r28 != null) {
return r28;
}
let r58 = GuildStore.getGuildsArray().find((item) => item.id !== a0)?.id;
if (r58 == null) {
r58 = null;
}
return r58;
};
};
const handleConnectionOpen = function handleConnectionOpen() {
if (selectedGuildId != null && GuildStore.getGuild(selectedGuildId) == null && UserGuildJoinRequestStore.getRequest(selectedGuildId) == null) {
selectedGuildId = null;
}
if (guildId != null && GuildStore.getGuild(guildId) == null && UserGuildJoinRequestStore.getRequest(guildId) == null) {
guildId = null;
}
if (selectedGuildId != null) {
selectedGuildTimestampMillis[selectedGuildId] = Date.now();
}
};
selectedGuildId = null;
guildId = null;
selectedGuildTimestampMillis = {};
class SelectedGuildStore extends Module589.PersistedStore {
static displayName = "SelectedGuildStore";
static persistKey = "SelectedGuildStore";
initialize(a0) {
this.mustEmitChanges((a0) => a0.type !== "CONNECTION_OPEN");
this.waitFor(AuthenticationStore, DefaultRouteStore, GuildStore, UserGuildJoinRequestStore);
let r20 = a0?.selectedGuildTimestampMillis;
if (r20 == null) {
r20 = {};
}
selectedGuildTimestampMillis = r20;
let r22 = a0?.selectedGuildId;
if (r22 == null) {
r22 = null;
}
selectedGuildId = r22;
let r24 = a0?.lastSelectedGuildId;
if (r24 == null) {
r24 = null;
}
guildId = r24;
const r37 = matchPath(DefaultRouteStore.lastNonVoiceRoute, {
path: Routes.CHANNEL(RouteParam.guildId())
});
let r39 = r37 == null ? void 0 : r37.params?.guildId;
let r43 = null;
if (r39 !== ME) {
if (r39 == null) {
r39 = null;
}
r43 = r39;
}
if (r43 != null && r43 !== selectedGuildId) {
selectedGuildId = r43;
}
}
getState() {
return {
selectedGuildTimestampMillis,
selectedGuildId,
lastSelectedGuildId: guildId
};
}
getGuildId() {
return selectedGuildId;
}
getLastSelectedGuildId() {
return guildId;
}
getLastSelectedTimestamp(a0) {
return selectedGuildId !== a0 ? selectedGuildTimestampMillis[a0] : -1;
}
}
const selectedGuildStore = new SelectedGuildStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: function handleOverlayInitialize(a0) {
selectedGuildId = a0.selectedGuildId;
guildId = void 0;
handleConnectionOpen();
},
CHANNEL_SELECT: function handleChannelSelect({ guildId: guildId2 }) {
if (selectedGuildId === guildId2) {
return false;
}
if (selectedGuildId != null) {
selectedGuildTimestampMillis[selectedGuildId] = Date.now();
}
if (guildId2 != null) {
selectedGuildTimestampMillis[guildId2] = Date.now();
}
if (guildId2 != null) {
guildId = guildId2;
}
selectedGuildId = guildId2;
},
GUILD_MEMBER_REMOVE: function handleGuildMemberRemove(a0) {
const guildId2 = a0.guildId;
let r2 = a0.user.id === AuthenticationStore.getId();
if (r2) {
delete selectedGuildTimestampMillis[guildId2];
let r14 = false;
if (guildId === guildId2) {
guildId = null;
r14 = true;
}
if (selectedGuildId === guildId2) {
const r17 = $mk73416()(guildId2);
if (r17 != null) {
selectedGuildId = r17;
replaceWith(Routes.CHANNEL(r17));
r14 = true;
} else {
selectedGuildId = null;
replaceWith(Routes.ME);
r14 = true;
}
}
r2 = r14;
}
return r2;
},
GUILD_DELETE: function handleGuildDelete({ guild }) {
const id = guild.id;
let r2 = guild.unavailable !== true;
if (r2) {
delete selectedGuildTimestampMillis[id];
let r14 = false;
if (guildId === id) {
guildId = null;
r14 = true;
}
if (selectedGuildId === id) {
const r9 = $mk73416()(id);
if (r9 != null) {
selectedGuildId = r9;
replaceWith(Routes.CHANNEL(r9));
r14 = true;
} else {
selectedGuildId = null;
replaceWith(Routes.ME);
r14 = true;
}
}
r2 = r14;
}
return r2;
},
LOGOUT: function handleLogout() {
selectedGuildId = null;
guildId = null;
}
});
export default selectedGuildStore;
export const SELECTED_GUILD_TIMESTAMP_NOW = -1;
+216
View File
@@ -0,0 +1,216 @@
// Metro module 4867 (f4868).
import SpotifyStore from "../modules/spotify/SpotifyStore";
import UserSettingsProtoStore from "../modules/user_settings/UserSettingsProtoStore";
import DetectableGameStore from "./DetectableGameStore";
import IdleStore from "./IdleStore";
import LibraryApplicationStore from "./LibraryApplicationStore";
import LocalActivityStore from "./LocalActivityStore";
import PresenceStore, { sortActivity } from "./PresenceStore";
import SessionsStore from "./SessionsStore";
import { ActivityFlags, ActivityTypes, AppStates, StatusTypes } from "../Constants";
import { shouldShareApplicationActivity } from "../utils/LibraryApplicationUtils";
import { ShowCurrentGame, StatusSetting } from "../modules/user_settings/UserSettings";
import { hasFlag } from "../_bundle/Module1384";
import isListeningOnSpotify from "../modules/activities/utils/isListeningOnSpotify";
import isUndefinedOrNull from "../_bundle/isUndefinedOrNull";
import Module12 from "../_bundle/Module12";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let invisible, ONLINE, UNKNOWN, since, c2998_20, activities, isAFK, c2998_23, remoteActivities, hiddenActivities, c2998_26, c2998_27, shouldShowActivity, handleUpdate;
const filterPlayingActivities = function filterPlayingActivities(a0) {
if (a0.length === 0) {
return a0;
}
const r24 = [];
const r2 = [];
for (const item of a0) {
if (item.type === ActivityTypes.PLAYING) {
r2.push(item);
} else {
r24.push(item);
}
}
if (r2.length === 0) {
return a0;
}
if (r2.length === 1) {
return a0;
}
return [...r24, [...r2].sort(sortActivity)[0]].sort(sortActivity);
};
shouldShowActivity = function shouldShowActivity(a0) {
let r37;
let flags = a0.flags;
if (flags == null) {
flags = 0;
}
if (hasFlag(flags, ActivityFlags.CONTEXTLESS)) {
return true;
}
const type = a0.type;
if (ActivityTypes.LISTENING === type) {
return isListeningOnSpotify(a0) ? SpotifyStore.shouldShowActivity() : a0.application_id != null && shouldShareApplicationActivity(a0.application_id, LibraryApplicationStore);
}
if (ActivityTypes.PLAYING === type) {
if (a0.application_id != null) {
r37 = shouldShareApplicationActivity(a0.application_id, LibraryApplicationStore);
} else {
const r31 = DetectableGameStore.searchGamesByName(a0.name);
r37 = r31.length === 1 ? shouldShareApplicationActivity(r31[0], LibraryApplicationStore) : ShowCurrentGame.getSetting();
}
return r37;
}
if (ActivityTypes.STREAMING !== type) {
ActivityTypes.WATCHING;
}
return a0.application_id == null || shouldShareApplicationActivity(a0.application_id, LibraryApplicationStore);
};
handleUpdate = function handleUpdate() {
let r8;
let r14 = IdleStore.getIdleSince();
if (r14 == null) {
r14 = 0;
}
since = r14;
isAFK = IdleStore.isAFK();
if (c2998_23) {
ONLINE = UNKNOWN;
r8 = UNKNOWN;
} else if (invisible) {
const INVISIBLE = StatusTypes.INVISIBLE;
ONLINE = INVISIBLE;
r8 = INVISIBLE;
} else {
r8 = StatusSetting.getSetting();
if (r8 === StatusTypes.UNKNOWN) {
r8 = StatusTypes.ONLINE;
}
ONLINE = r8;
}
if (r8 === StatusTypes.ONLINE && since > 0) {
ONLINE = StatusTypes.IDLE;
}
const r9 = !c2998_23 && ONLINE !== StatusTypes.INVISIBLE ? LocalActivityStore.getActivities().filter(shouldShowActivity) : [];
const isUndefinedOrNull2 = isUndefinedOrNull(c2998_20, r9);
let r3 = false;
if (!isUndefinedOrNull2) {
c2998_20 = r9;
activities = filterPlayingActivities(r9);
r3 = true;
}
const remoteActivities2 = SessionsStore.getRemoteActivities();
if (remoteActivities !== remoteActivities2) {
remoteActivities = remoteActivities2;
r3 = true;
}
const hiddenActivities2 = SessionsStore.getHiddenActivities();
if (hiddenActivities !== hiddenActivities2) {
hiddenActivities = hiddenActivities2;
}
if (r3) {
const r78 = Module12([...c2998_20, ...remoteActivities.filter((remoteActivity) => remoteActivity.type !== ActivityTypes.CUSTOM_STATUS)].sort(sortActivity)).uniqBy((item) => `${item.type}:${item.application_id}:${item.name}`).value();
c2998_26 = r78;
c2998_27 = filterPlayingActivities(r78);
}
};
const handleConnectionOpen = function handleConnectionOpen() {
c2998_23 = false;
UNKNOWN = StatusTypes.UNKNOWN;
handleUpdate();
PresenceStore.setCurrentUserOnConnectionOpen(ONLINE, c2998_26);
};
invisible = false;
ONLINE = StatusTypes.ONLINE;
UNKNOWN = StatusTypes.UNKNOWN;
since = 0;
c2998_20 = [];
activities = [];
isAFK = false;
c2998_23 = true;
remoteActivities = Object.freeze([]);
hiddenActivities = Object.freeze([]);
c2998_26 = [];
c2998_27 = [];
class SelfPresenceStore extends Module589.Store {
static displayName = "SelfPresenceStore";
initialize() {
this.waitFor(DetectableGameStore, IdleStore, LibraryApplicationStore, LocalActivityStore, PresenceStore, SessionsStore, SpotifyStore, UserSettingsProtoStore);
this.syncWith([LocalActivityStore], handleUpdate);
}
getLocalPresence() {
return {
status: ONLINE,
since,
activities,
afk: isAFK
};
}
getStatus() {
return ONLINE;
}
getActivities(r1 = true) {
return r1 ? c2998_27 : activities;
}
getUnfilteredActivities(r1 = true) {
return r1 ? c2998_26 : c2998_20;
}
getHiddenActivities() {
return hiddenActivities;
}
getPrimaryActivity(r3 = true) {
return this.getActivities(r3)[0];
}
getApplicationActivity(c14478_0, r4 = true) {
return this.findActivity((a0) => a0.application_id === c14478_0, r4);
}
findActivity(a0, r4 = true) {
return this.getActivities(r4).find(a0);
}
}
const selfPresenceStore = new SelfPresenceStore(Dispatcher, {
START_SESSION: handleUpdate,
CONNECTION_OPEN: function handleConnectionOpenTracked() {
c2998_23 = false;
UNKNOWN = StatusTypes.UNKNOWN;
handleUpdate();
PresenceStore.setCurrentUserOnConnectionOpen(ONLINE, c2998_26);
},
CONNECTION_OPEN_SUPPLEMENTAL: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
CONNECTION_CLOSED: handleUpdate,
IDLE: handleUpdate,
AFK: handleUpdate,
RUNNING_GAMES_CHANGE: handleUpdate,
STREAMING_UPDATE: handleUpdate,
USER_SETTINGS_PROTO_UPDATE: handleUpdate,
LOCAL_ACTIVITY_UPDATE: handleUpdate,
SPOTIFY_PLAYER_STATE: handleUpdate,
SPOTIFY_PLAYER_PLAY: handleUpdate,
USER_CONNECTIONS_UPDATE: handleUpdate,
SESSIONS_REPLACE: handleUpdate,
RPC_APP_DISCONNECTED: handleUpdate,
LIBRARY_FETCH_SUCCESS: handleUpdate,
LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: handleUpdate,
LOGOUT: function handleLogout() {
c2998_23 = true;
UNKNOWN = ONLINE;
handleUpdate();
},
FORCE_INVISIBLE: function handleForceInvisible(a0) {
invisible = a0.invisible;
handleUpdate();
},
WINDOW_FOCUS: function handleWindowFocus() {
invisible = false;
handleUpdate();
},
APP_STATE_UPDATE: function handleAppStateUpdate(a0) {
if (a0.state === AppStates.ACTIVE && invisible) {
invisible = false;
handleUpdate();
return void 0;
}
return false;
}
});
export default selfPresenceStore;
+17
View File
@@ -0,0 +1,17 @@
// Metro module 16315 (f16316).
import SelfPresenceStore from "./SelfPresenceStore";
import AutomaticLifecycleManager from "../lib/AutomaticLifecycleManager";
import Dispatcher from "../Dispatcher";
const handleChange = function handleChange() {
Dispatcher.dispatch({
type: "SELF_PRESENCE_STORE_UPDATE",
status: SelfPresenceStore.getStatus(),
activities: SelfPresenceStore.getActivities(true),
hiddenActivities: SelfPresenceStore.getHiddenActivities()
});
};
class SelfPresenceStoreManager extends AutomaticLifecycleManager {
stores = new Map().set(SelfPresenceStore, handleChange);
}
const selfPresenceStoreManager = new SelfPresenceStoreManager();
export default selfPresenceStoreManager;
+65
View File
@@ -0,0 +1,65 @@
// Metro module 4204 (f4205).
import AuthenticationStore from "./AuthenticationStore";
import Module589 from "../_bundle/Module589";
import Module12 from "../_bundle/Module12";
import Dispatcher from "../Dispatcher";
let c2424_3, c2424_4;
const handleUpdate = function handleUpdate(a0) {
c2424_4 = {};
a0.sessions.forEach((session) => {
c2424_4[session.sessionId] = session;
});
};
c2424_3 = Object.freeze([]);
c2424_4 = {};
class SessionsStore extends Module589.Store {
static displayName = "SessionsStore";
initialize() {
this.waitFor(AuthenticationStore);
}
getSessions() {
return c2424_4;
}
getSession() {
const sessionId4 = AuthenticationStore.getSessionId();
return sessionId4 != null ? this.getSessionById(sessionId4) : null;
}
getRemoteActivities() {
const sessionId = AuthenticationStore.getSessionId();
const r13 = Module12.find(c2424_4, (a0) => a0.active && a0.sessionId !== sessionId);
return r13 != null ? r13.activities : c2424_3;
}
getHiddenActivities() {
const sessionId2 = AuthenticationStore.getSessionId();
const r13 = Module12.find(c2424_4, (a0) => a0.active && a0.sessionId !== sessionId2);
return r13 != null && r13.hiddenActivities != null ? r13.hiddenActivities : c2424_3;
}
getSessionById(a0) {
return c2424_4[a0];
}
getActiveSession() {
return Module12.find(c2424_4, (a0) => a0.active);
}
getRemoteApplicationActivity(a0) {
let c13975_0 = a0;
if (a0 == null) {
return null;
}
const sessionId3 = AuthenticationStore.getSessionId();
const r16 = Module12.find(c2424_4, (a0) => a0.active && a0.sessionId !== sessionId3);
if (r16 == null) {
return null;
}
let r20 = r16.activities.find((activity) => activity.application_id === c13975_0);
if (r20 == null) {
const hiddenActivities = r16.hiddenActivities;
r20 = hiddenActivities == null ? void 0 : hiddenActivities.find((hiddenActivity) => hiddenActivity.application_id === c13975_0);
}
return r20;
}
}
const sessionsStore = new SessionsStore(Dispatcher, {
CONNECTION_OPEN: handleUpdate,
SESSIONS_REPLACE: handleUpdate
});
export default sessionsStore;
+123
View File
@@ -0,0 +1,123 @@
// Metro module 5971 (f5972).
import ChannelStore from "./ChannelStore";
import PermissionStore from "./PermissionStore";
import { canBypassSlowmode } from "../modules/chat/SlowmodeUtils";
import { Timeout } from "../_bundle/Timeout";
import Dispatcher from "../Dispatcher";
import Durations from "../utils/Durations";
import Module589 from "../_bundle/Module589";
let c3767_5, c3767_6;
const setCooldown = function setCooldown(channel, slowmodeType2, a2) {
let c15336_2;
const slowmodeType = slowmodeType2;
if (c3767_6[slowmodeType2][channel.id] != null) {
c3767_6[slowmodeType2][channel.id].timer.stop();
delete c3767_6[slowmodeType2][channel.id];
}
if (!canBypassSlowmode(channel) && !(a2 <= 0)) {
const cooldownEndTimestamp = a2 + Date.now();
c15336_2 = cooldownEndTimestamp;
c3767_6[slowmodeType2][channel.id] = {
rateLimitPerUser: channel.rateLimitPerUser,
cooldownMs: a2,
cooldownEndTimestamp,
timer: new Timeout()
};
c3767_6[slowmodeType2][channel.id].timer.start(1000, () => {
Dispatcher.dispatch({
type: "SLOWMODE_SET_COOLDOWN",
channelId: channel.id,
slowmodeType,
cooldownMs: Math.max(c15336_2 - Date.now(), 0)
});
}, true);
}
};
const handleUploadCancel = function handleUploadCancel(a0) {
const channel = ChannelStore.getChannel(a0.channelId);
let r9 = channel != null;
if (r9) {
setCooldown(channel, c3767_5.SendMessage, 0);
r9 = void 0;
}
return r9;
};
c3767_5 = {
SendMessage: 0,
0: "SendMessage",
CreateThread: 1,
1: "CreateThread"
};
const r28 = {};
r28[c3767_5.SendMessage] = {};
r28[c3767_5.CreateThread] = {};
c3767_6 = r28;
class SlowmodeStore extends Module589.Store {
static displayName = "SlowmodeStore";
initialize() {
this.waitFor(ChannelStore, PermissionStore);
}
getSlowmodeCooldownGuess(a0, a1) {
const r7 = c3767_6[a1 == null ? c3767_5.SendMessage : a1][a0];
return r7 != null ? r7.cooldownMs : 0;
}
isChannelOnCooldown(a0, a1) {
return this.getSlowmodeCooldownGuess(a0.id, a1) > 0 && a0.rateLimitPerUser > 0;
}
}
const slowmodeStore = new SlowmodeStore(Dispatcher, {
SLOWMODE_RESET_COOLDOWN: function handleSlowmodeResetCooldown({ channelId, slowmodeType: slowmodeType2 }) {
const channel = ChannelStore.getChannel(channelId);
const r4 = channel == null;
let r13 = false;
if (!r4) {
setCooldown(channel, slowmodeType2, channel.rateLimitPerUser !== 0 ? channel.rateLimitPerUser * Durations.Millis.SECOND + 100 : 0);
r13 = void 0;
}
return r13;
},
SLOWMODE_SET_COOLDOWN: function handleSlowmodeSetCooldown({ channelId, slowmodeType: slowmodeType2, cooldownMs }) {
const channel = ChannelStore.getChannel(channelId);
if (channel == null) {
return false;
}
setCooldown(channel, slowmodeType2, cooldownMs !== 0 ? cooldownMs + 100 : 0);
},
UPLOAD_START: function handleUploadStart({ channelId }) {
const SendMessage = c3767_5.SendMessage;
const channel = ChannelStore.getChannel(channelId);
const r4 = channel == null;
let r14 = false;
if (!r4) {
setCooldown(channel, SendMessage, channel.rateLimitPerUser !== 0 ? channel.rateLimitPerUser * Durations.Millis.SECOND + 100 : 0);
r14 = void 0;
}
return r14;
},
UPLOAD_FAIL: handleUploadCancel,
UPLOAD_CANCEL_REQUEST: handleUploadCancel,
CHANNEL_UPDATES: function handleUpdateCooldown({ channels }) {
[c3767_5.SendMessage, c3767_5.CreateThread].forEach((item) => {
for (const channel of channels) {
const r39 = c3767_6[item][channel.id];
const rateLimitPerUser = channel.rateLimitPerUser;
if (r39 != null && r39.rateLimitPerUser !== rateLimitPerUser) {
const r16 = Math;
let r14 = r39?.cooldownMs;
if (r14 == null) {
r14 = 0;
}
setCooldown(channel, item, r16.min(r14, rateLimitPerUser * Durations.Millis.SECOND));
}
}
});
},
LOGOUT: function clear() {
[c3767_5.SendMessage, c3767_5.CreateThread].forEach((a0) => {
Object.keys(c3767_6[a0]).forEach((item) => c3767_6[a0][item].timer.stop());
c3767_6[a0] = {};
});
}
});
export default slowmodeStore;
export { c3767_5 as SlowmodeType };
+415
View File
@@ -0,0 +1,415 @@
// Metro module 5027 (f5028).
import UserGuildJoinRequestStore from "../modules/guild_member_verification/UserGuildJoinRequestStore";
import LurkingStore from "../modules/lurker_mode/LurkingStore";
import UserSettingsProtoStore from "../modules/user_settings/UserSettingsProtoStore";
import ExpandedGuildFolderStore from "./ExpandedGuildFolderStore";
import GuildAvailabilityStore from "./GuildAvailabilityStore";
import GuildMemberStore from "./GuildMemberStore";
import GuildStore from "./GuildStore";
import MobileCacheSnapshotStore from "./MobileCacheSnapshotStore";
import UserGuildSettingsStore from "./UserGuildSettingsStore";
import UserStore from "./UserStore";
import * as _GuildsTree from "../modules/guilds_bar/GuildsTree";
import { GuildsTree, createGuildNode, createFolderNode } from "../modules/guilds_bar/GuildsTree";
import isUndefinedOrNull from "../_bundle/isUndefinedOrNull";
import Module38 from "../_bundle/Module38";
import { isNotNullish } from "../utils/GlobalUtils";
import { cachedFunction } from "../utils/FunctionUtils";
import { $callWithNewTarget } from "../_hermes/prelude";
function $mk75260($env) {
return () => {
const r5 = $env[0];
const r3 = $env.$parent;
const tree = r5.readSnapshot(r3[32].LATEST_SNAPSHOT_VERSION)?.tree;
if (tree != null) {
const guildsTree = new ((0, r3[0])(r3[2][10]).GuildsTree)();
r3[13] = guildsTree;
guildsTree.loadSnapshot(tree);
for (const item of r3[13].allNodes()) {
if (item.type === (0, r3[0])(r3[2][10]).GuildsNodeType.FOLDER) {
item.expanded = r3[7].isFolderExpanded(item.id);
}
}
}
};
}
function $mk75261($env) {
return () => $env[0].loadCache();
}
let convertNodeToGuildFolder, rebuildTree, handleRebuild, handleSettingsUpdate, handleMoveById, handleGuildFolderCreateLocal, handleGuildFolderEditLocal, handleGuildFolderDeleteLocal, handleJoinedLurkingGuild, handleGuildFolderExpand, handleFolderExpanded, handleCollapseAll, setNodeExpanded, c3031_28, c3031_29, c3031_30, c3031_31, c3031_32, c3031_33, c3032_0, c3033_0;
let env3031;
let env3032;
let env3033;
const r7 = env3031 = {};
export function insertUnsortedGuilds(a0, a1) {
for (const item of GuildStore.getGuildIds()) {
const r28 = a0(item);
if (!((r28 ? LurkingStore.isLurking(item) : !r28) || GuildMemberStore.isCurrentUserGuest(item))) {
a1(item);
}
}
}
convertNodeToGuildFolder = function convertNodeToGuildFolder(a0) {
const type = a0.type;
if (_GuildsTree.GuildsNodeType.FOLDER === type) {
return {
folderId: a0.id,
folderName: a0.name,
folderColor: a0.color,
expanded: a0.expanded,
guildIds: a0.children.map((item) => item.id)
};
}
if (_GuildsTree.GuildsNodeType.GUILD === type) {
return {
folderId: void 0,
guildIds: [a0.id]
};
}
throw Error("[SortedGuildStore] Unexpected guilds tree node type.");
};
rebuildTree = function rebuildTree(a0, a1) {
const r1 = env3031[13];
env3031[13] = new GuildsTree();
if (a0.length === 0 && a1.length > 0) {
for (const item2 of a1) {
env3031[13].addNode(createGuildNode(item2));
}
} else {
for (const item of a0) {
if (item.guildIds.length !== 0) {
if (item.folderId != null) {
const folderNode = createFolderNode(item, void 0, ExpandedGuildFolderStore.isFolderExpanded(item.folderId));
env3031[13].addNode(folderNode);
for (const guildId of item.guildIds) {
env3031[13].addNode(createGuildNode(guildId), folderNode);
}
continue;
}
env3031[13].addNode(createGuildNode(item.guildIds[0]));
}
}
}
for (const item3 of env3031[13].allNodes()) {
if (item3.type === _GuildsTree.GuildsNodeType.GUILD && (LurkingStore.isLurking(item3.id) || GuildMemberStore.isCurrentUserGuest(item3.id) || GuildStore.getGuild(item3.id) == null && !GuildAvailabilityStore.isUnavailable(item3.id))) {
env3031[13].removeNode(item3);
}
}
for (const item4 of Object.values(env3031[13].nodes)) {
if (item4.type === _GuildsTree.GuildsNodeType.FOLDER && item4.children.length === 0) {
env3031[13].removeNode(item4);
}
}
insertUnsortedGuilds((a0) => env3031[13].nodes[a0] == null, (a0) => env3031[13].addNode(createGuildNode(a0), env3031[13].root, false));
env3031[13].version = r1.version;
const isUndefinedOrNull2 = isUndefinedOrNull(r1, env3031[13]);
if (isUndefinedOrNull2) {
env3031[13] = r1;
} else {
env3031[13].version = r1.version + 1;
}
return !isUndefinedOrNull2;
};
handleRebuild = function handleRebuild() {
let r8 = UserSettingsProtoStore.getGuildFolders();
if (r8 == null) {
r8 = [];
}
let r10 = UserSettingsProtoStore.settings.guildFolders?.guildPositions;
if (r10 == null) {
r10 = [];
}
return rebuildTree(r8, r10);
};
handleSettingsUpdate = function handleSettingsUpdate() {
let r9 = UserSettingsProtoStore.getGuildFolders();
let r1 = env3031[3] == null || !isUndefinedOrNull(env3031[3], r9);
if (r1) {
env3031[3] = r9;
if (r9 == null) {
r9 = [];
}
let r19 = UserSettingsProtoStore.settings.guildFolders?.guildPositions;
if (r19 == null) {
r19 = [];
}
r1 = rebuildTree(r9, r19);
}
return r1;
};
handleMoveById = function handleMoveById({ sourceId, targetId, moveToBelow, combine }) {
const node3 = env3031[13].getNode(sourceId);
const node4 = env3031[13].getNode(targetId);
if (node3 != null && node4 != null) {
Module38(!(combine ? node3.type === _GuildsTree.GuildsNodeType.FOLDER : combine), `[SORTED GUILDS] Can't combine a folder ${node3.id} with another guilds list item`);
Module38(!(combine && node4.parentId != null), `[SORTED GUILDS] Can't combine with a guild ${node4.id} that's already inside of a folder`);
Module38(!(node3.type === _GuildsTree.GuildsNodeType.FOLDER && node4.parentId != null), `[SORTED GUILDS] Can't move a folder ${node3.id} to inside of another folder ${node4.parentId}`);
if (combine) {
env3031[13].moveInto(node3, node4.type !== _GuildsTree.GuildsNodeType.FOLDER ? env3031[13].convertToFolder(node4) : node4, moveToBelow);
} else {
env3031[13].moveNextTo(node3, node4, moveToBelow);
}
return void 0;
}
return false;
};
handleGuildFolderCreateLocal = function handleGuildFolderCreateLocal({ sourceIds, name }) {
const r8 = sourceIds.shift();
if (r8 == null) {
return false;
}
const node3 = env3031[13].getNode(r8);
if (node3 == null) {
return false;
}
const r14 = env3031[13].convertToFolder(node3);
let c14555_0 = r14;
r14.name = name;
sourceIds.forEach((sourceId) => {
const node3 = env3031[13].getNode(sourceId);
if (node3 != null) {
env3031[13].moveInto(node3, c14555_0, true);
}
});
};
handleGuildFolderEditLocal = function handleGuildFolderEditLocal({ targetId, sourceIds, ...rest }) {
let c14556_1, c14556_2;
c14556_1 = void 0;
c14556_2 = void 0;
const node3 = env3031[13].getNode(targetId);
if (node3 == null) {
return false;
}
if (node3.type !== _GuildsTree.GuildsNodeType.FOLDER) {
return false;
}
const name = rest.name !== "" ? rest.name : void 0;
if (name !== node3.name) {
const r32 = env3031[13].cloneNode(node3);
Module38(r32.id === node3.id, "[SORTED GUILDS] Replacement folder node must have same id.");
r32.name = name;
env3031[13].replaceNode(node3, r32);
}
const node = env3031[13].getNode(targetId);
if (node == null) {
return false;
}
const r52 = node.children.map((item) => item.id).filter(isNotNullish);
c14556_1 = new Set(r52);
c14556_2 = new Set(sourceIds);
const set = new Set([...r52].filter((item) => !c14556_2.has(item)));
sourceIds.filter((sourceId) => !c14556_1.has(sourceId)).forEach((item) => {
const node3 = env3031[13].getNode(item);
if (node3 != null) {
env3031[13].moveInto(node3, node, true);
}
});
set.forEach((item) => {
const node3 = env3031[13].getNode(item);
if (node3 != null) {
env3031[13].moveNextTo(node3, node, true);
}
});
};
handleGuildFolderDeleteLocal = function handleGuildFolderDeleteLocal({ targetId }) {
const node2 = env3031[13].getNode(targetId);
let r11 = node2 != null;
if (r11) {
let r1 = node2.type === _GuildsTree.GuildsNodeType.FOLDER;
if (r1) {
node2.children.map((item) => item.id).filter(isNotNullish).forEach((item) => {
const node3 = env3031[13].getNode(item);
if (node3 != null) {
env3031[13].moveNextTo(node3, node2, true);
}
});
r1 = void 0;
}
r11 = r1;
}
return r11;
};
handleJoinedLurkingGuild = function handleJoinedLurkingGuild({ guildId, joinedAt, user }) {
const currentUser = UserStore.getCurrentUser();
const guild = GuildStore.getGuild(guildId);
if (currentUser?.id === user.id && guild != null) {
let r20 = joinedAt;
if (typeof r20 === "string") {
r20 = new Date(joinedAt);
}
let r26 = r20 !== guild.joinedAt && r20 != null;
if (r26) {
let r30 = UserSettingsProtoStore.getGuildFolders();
if (r30 == null) {
r30 = [];
}
let r33 = UserSettingsProtoStore.settings.guildFolders?.guildPositions;
if (r33 == null) {
r33 = [];
}
r26 = rebuildTree(r30, r33);
}
return r26;
}
return false;
};
handleGuildFolderExpand = function handleGuildFolderExpand({ folderId }) {
const node3 = env3031[13].getNode(folderId);
const isFolderExpanded = ExpandedGuildFolderStore.isFolderExpanded(folderId);
if (node3 != null) {
if (node3.type === _GuildsTree.GuildsNodeType.FOLDER && node3.expanded !== isFolderExpanded) {
const r23 = env3031[13].cloneNode(node3);
Module38(r23.id === node3.id, "[SORTED GUILDS] setNodeExpanded: Replacement folder node must have same id.");
r23.expanded = isFolderExpanded;
env3031[13].replaceNode(node3, r23);
return void 0;
}
}
return false;
};
handleFolderExpanded = function handleFolderExpanded({ folderId, expanded }) {
const node3 = env3031[13].getNode(folderId);
if (node3 != null) {
if (node3.type === _GuildsTree.GuildsNodeType.FOLDER && node3.expanded !== expanded) {
const r21 = env3031[13].cloneNode(node3);
Module38(r21.id === node3.id, "[SORTED GUILDS] setNodeExpanded: Replacement folder node must have same id.");
r21.expanded = expanded;
env3031[13].replaceNode(node3, r21);
return void 0;
}
}
return false;
};
handleCollapseAll = function handleCollapseAll() {
for (const item of env3031[13].allNodes()) {
if (item.type === _GuildsTree.GuildsNodeType.FOLDER && item.expanded) {
setNodeExpanded(item, false);
}
}
};
setNodeExpanded = function setNodeExpanded(a0, a1) {
const r9 = env3031[13].cloneNode(a0);
Module38(r9.id === a0.id, "[SORTED GUILDS] setNodeExpanded: Replacement folder node must have same id.");
r9.expanded = false;
env3031[13].replaceNode(a0, r9);
};
env3031[13] = new GuildsTree();
c3031_28 = cachedFunction((a0) => a0.sortedGuildNodes().map((item) => item.id));
c3031_29 = cachedFunction((a0) => a0.getRoots().map(convertNodeToGuildFolder));
c3031_30 = cachedFunction((a0) => {
const r2 = [];
let c14558_0 = r2;
const flattenNodes2 = function flattenNodes(a0) {
const type = a0.type;
if (!(_GuildsTree.GuildsNodeType.FOLDER !== type && _GuildsTree.GuildsNodeType.GUILD !== type)) {
c14558_0.push(a0);
}
for (const item of a0.children) {
flattenNodes2(item);
}
};
flattenNodes2(a0.root);
return r2;
});
c3031_31 = cachedFunction((a0) => a0.root.children.map(convertNodeToGuildFolder));
c3031_32 = void 0;
class SortedGuildStore extends MobileCacheSnapshotStore {
static displayName = "SortedGuildStore";
static LATEST_SNAPSHOT_VERSION = 2;
constructor() {
let env14559;
let env14560;
const r1 = env14559 = {};
env14559[0] = void 0;
const r10 = {
CONNECTION_OPEN: handleRebuild,
OVERLAY_INITIALIZE: handleRebuild,
CACHE_LOADED: $mk75261(r1),
GUILD_CREATE: handleRebuild,
GUILD_DELETE: handleRebuild,
GUILD_MEMBER_ADD: handleJoinedLurkingGuild,
USER_SETTINGS_PROTO_UPDATE: handleSettingsUpdate,
GUILD_MOVE_BY_ID: handleMoveById,
GUILD_FOLDER_CREATE_LOCAL: handleGuildFolderCreateLocal,
GUILD_FOLDER_EDIT_LOCAL: handleGuildFolderEditLocal,
GUILD_FOLDER_DELETE_LOCAL: handleGuildFolderDeleteLocal,
TOGGLE_GUILD_FOLDER_EXPAND: handleGuildFolderExpand,
SET_GUILD_FOLDER_EXPANDED: handleFolderExpanded,
GUILD_FOLDER_COLLAPSE: handleCollapseAll
};
super(r10);
env14559[0] = this;
const r23 = env14560 = {
$parent: env3031
};
env14560[0] = this;
this.loadCache = $mk75260(r23);
}
initialize() {
this.waitFor(GuildStore, UserGuildSettingsStore, UserSettingsProtoStore, GuildAvailabilityStore, LurkingStore, ExpandedGuildFolderStore, UserGuildJoinRequestStore);
}
getGuildsTree() {
return env3031[13];
}
getGuildFolders() {
const r2 = env3031[13];
return c3031_29(r2, r2.version);
}
getGuildFolderById(c14561_0) {
return this.getGuildFolders().find((item) => item.folderId === c14561_0);
}
getFlattenedGuildIds() {
const r2 = env3031[13];
return c3031_28(r2, r2.version);
}
getFlattenedGuildFolderList() {
const r2 = env3031[13];
return c3031_30(r2, r2.version);
}
getCompatibleGuildFolders() {
const r2 = env3031[13];
return c3031_31(r2, r2.version);
}
getFastListGuildFolders() {
return env3031[13].getRoots();
}
takeSnapshot() {
return {
version: c3031_32.LATEST_SNAPSHOT_VERSION,
data: {
tree: env3031[13].getSnapshot()
}
};
}
}
c3031_32 = SortedGuildStore;
c3031_33 = SortedGuildStore;
const r100 = env3032 = {};
c3032_0 = void 0;
const prototypeOf = Object.getPrototypeOf(SortedGuildStore);
const r103 = {
CONNECTION_OPEN: handleRebuild,
OVERLAY_INITIALIZE: handleRebuild,
CACHE_LOADED: $mk75261(r100),
GUILD_CREATE: handleRebuild,
GUILD_DELETE: handleRebuild,
GUILD_MEMBER_ADD: handleJoinedLurkingGuild,
USER_SETTINGS_PROTO_UPDATE: handleSettingsUpdate,
GUILD_MOVE_BY_ID: handleMoveById,
GUILD_FOLDER_CREATE_LOCAL: handleGuildFolderCreateLocal,
GUILD_FOLDER_EDIT_LOCAL: handleGuildFolderEditLocal,
GUILD_FOLDER_DELETE_LOCAL: handleGuildFolderDeleteLocal,
TOGGLE_GUILD_FOLDER_EXPAND: handleGuildFolderExpand,
SET_GUILD_FOLDER_EXPANDED: handleFolderExpanded,
GUILD_FOLDER_COLLAPSE: handleCollapseAll
};
const r104 = Object.create(SortedGuildStore.prototype);
const r106 = $callWithNewTarget(prototypeOf, r104, SortedGuildStore, r103);
c3032_0 = r106 instanceof Object ? r106 : r104;
const r108 = env3033 = {
$parent: r7
};
c3033_0 = c3032_0;
c3032_0.loadCache = $mk75260(r108);
export default c3032_0;
export const GuildsNodeType = _GuildsTree.GuildsNodeType;
+300
View File
@@ -0,0 +1,300 @@
// Metro module 5009 (f5010).
import _slicedToArray from "../_bundle/_slicedToArray";
import ChannelStore from "./ChannelStore";
import MediaEngineStore from "./MediaEngineStore";
import RTCConnectionStore from "./RTCConnectionStore";
import SelectedChannelStore from "./SelectedChannelStore";
import { Permissions } from "../Constants";
import { MediaEngineContextTypes, SpeakingFlags } from "../_bundle/Module4250";
import { can } from "../utils/PermissionUtils";
import Module589 from "../_bundle/Module589";
import ProportionalVadIndicatorExperiment from "../modules/calls/ProportionalVadIndicatorExperiment";
import Dispatcher from "../Dispatcher";
let c3017_11, id, sessionId, c3017_14, isActive;
const anyoneHasFlagInContext = function anyoneHasFlagInContext(a0, a1, r7 = false) {
const r23 = c3017_11.get(a0);
if (r23 == null) {
return false;
}
for (const item of r23) {
const r31 = _slicedToArray(item, 2);
const r32 = r31[0];
const flags = r31[1].flags;
if (r7 && r32 === id) {
continue;
}
if ((flags & a1) !== a1) {
continue;
}
return true;
}
return false;
};
const handleConnectionOpen = function handleConnectionOpen({ user, sessionId: sessionId2 }) {
id = user.id;
sessionId = sessionId2;
c3017_14 = null;
};
c3017_11 = new Map();
id = null;
sessionId = null;
c3017_14 = null;
isActive = false;
class SpeakingStore extends Module589.Store {
static displayName = "SpeakingStore";
initialize() {
this.mustEmitChanges((a0) => a0.type !== "CONNECTION_OPEN" && a0.type !== "VOICE_STATE_UPDATES");
this.waitFor(ChannelStore, MediaEngineStore, RTCConnectionStore, SelectedChannelStore);
}
getSpeakingDuration(a0, a1, r5 = MediaEngineContextTypes.DEFAULT) {
const r6 = c3017_11.get(r5);
const r9 = r6 == null ? void 0 : r6.get(a0)?.since;
return r9 != null ? a1 - r9 : 0;
}
getSpeakers(r8 = MediaEngineContextTypes.DEFAULT) {
const DEFAULT = r8;
const r4 = Array;
const r12 = c3017_11.get(DEFAULT);
let r13 = r12 == null ? void 0 : r12.keys();
if (r13 == null) {
r13 = [];
}
return r4.from(r13).filter((item) => {
const VOICE = SpeakingFlags.VOICE;
const r8 = c3017_11.get(DEFAULT);
let r11 = r8 == null ? void 0 : r8.get(item)?.flags;
if (r11 == null) {
r11 = SpeakingFlags.NONE;
}
return (r11 & VOICE) === VOICE;
});
}
isSpeaking(a0, r7 = MediaEngineContextTypes.DEFAULT) {
const VOICE = SpeakingFlags.VOICE;
const r8 = c3017_11.get(r7);
let r11 = r8 == null ? void 0 : r8.get(a0)?.flags;
if (r11 == null) {
r11 = SpeakingFlags.NONE;
}
return (r11 & VOICE) === VOICE;
}
isPrioritySpeaker(a0, r7 = MediaEngineContextTypes.DEFAULT) {
const PRIORITY = SpeakingFlags.PRIORITY;
const r8 = c3017_11.get(r7);
let r11 = r8 == null ? void 0 : r8.get(a0)?.flags;
if (r11 == null) {
r11 = SpeakingFlags.NONE;
}
return (r11 & PRIORITY) === PRIORITY;
}
isSoundSharing(a0, r7 = MediaEngineContextTypes.DEFAULT) {
const SOUNDSHARE = SpeakingFlags.SOUNDSHARE;
const r8 = c3017_11.get(r7);
let r11 = r8 == null ? void 0 : r8.get(a0)?.flags;
if (r11 == null) {
r11 = SpeakingFlags.NONE;
}
return (r11 & SOUNDSHARE) === SOUNDSHARE;
}
isAnyoneElseSpeaking(r4 = MediaEngineContextTypes.DEFAULT) {
return anyoneHasFlagInContext(r4, SpeakingFlags.VOICE, true);
}
isCurrentUserSpeaking(r5 = MediaEngineContextTypes.DEFAULT) {
return id != null && this.isSpeaking(id, r5);
}
isCurrentUserPTTActive() {
return isActive;
}
isAnyonePrioritySpeaking(r4 = MediaEngineContextTypes.DEFAULT) {
return anyoneHasFlagInContext(r4, SpeakingFlags.VOICE | SpeakingFlags.PRIORITY);
}
isCurrentUserPrioritySpeaker(r5 = MediaEngineContextTypes.DEFAULT) {
return id != null && this.isPrioritySpeaker(id, r5);
}
isCurrentUserPrioritySpeaking(r5 = MediaEngineContextTypes.DEFAULT) {
return id != null && this.isPrioritySpeaker(id, r5) && this.isSpeaking(id, r5);
}
getVoiceVolume(a0, r7 = MediaEngineContextTypes.DEFAULT) {
const config = ProportionalVadIndicatorExperiment.getConfig({
location: "SpeakingStore"
});
const enabled = config.enabled;
let r15 = -Infinity;
if (enabled) {
const disableUI = config.disableUI;
r15 = -Infinity;
if (!disableUI) {
const r19 = c3017_11.get(r7);
let r20 = r19 == null ? void 0 : r19.get(a0)?.voiceDb;
if (r20 == null) {
r20 = -Infinity;
}
r15 = r20;
}
}
return r15;
}
}
const speakingStore = new SpeakingStore(Dispatcher, {
CONNECTION_OPEN: handleConnectionOpen,
OVERLAY_INITIALIZE: handleConnectionOpen,
SPEAKING: function handleSpeaking(a0) {
let r66, context, flags, userId, voiceDb;
L5: {
context = a0.context;
userId = a0.userId;
const speakingFlags = a0.speakingFlags;
voiceDb = a0.voiceDb;
const r9 = speakingFlags & SpeakingFlags.PRIORITY;
const PRIORITY = SpeakingFlags.PRIORITY;
flags = speakingFlags;
if (r9 === PRIORITY) {
const channel = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId());
if (channel != null && can({
permission: Permissions.PRIORITY_SPEAKER,
user: userId,
context: channel
})) {
MediaEngineStore.setCanHavePriority(userId, true);
flags = speakingFlags;
break L5;
}
MediaEngineStore.setCanHavePriority(userId, false);
flags = speakingFlags & ~SpeakingFlags.PRIORITY;
}
}
if ((flags & SpeakingFlags.HIDDEN) === SpeakingFlags.HIDDEN) {
flags = 0;
}
if (voiceDb === void 0) {
voiceDb = -Infinity;
}
let r48 = context;
if (r48 === void 0) {
r48 = MediaEngineContextTypes.DEFAULT;
}
let r52 = c3017_11.get(r48);
const r54 = r48;
if (r52 == null) {
const map = new Map();
c3017_11.set(r54, map);
r52 = map;
}
const r63 = r52.get(userId);
let r65 = r63?.flags;
if (r65 == null) {
r65 = 0;
}
L31: {
if (r65 === 0) {
r66 = false;
if (flags === 0) {
break L31;
}
}
if (flags === 0) {
r52.delete(userId);
const size = r52.size;
r66 = true;
if (size === 0) {
c3017_11.delete(context);
r66 = true;
}
} else {
let since = r63?.since;
if (since == null) {
since = null;
}
const r69 = r65 & SpeakingFlags.VOICE;
const VOICE = SpeakingFlags.VOICE;
const r74 = (flags & SpeakingFlags.VOICE) === SpeakingFlags.VOICE;
if (r69 === VOICE !== r74) {
since = r74 ? Date.now() : null;
}
r52.set(userId, {
flags,
since,
voiceDb
});
r66 = true;
}
}
return r66;
},
VOICE_STATE_UPDATES: function handleVoiceStateUpdates(a0) {
return a0.voiceStates.reduce((acc, { userId, channelId, sessionId: sessionId2 }) => {
let r29, r53;
const r10 = c3017_14;
const r1 = userId === id && sessionId2 === sessionId;
let r17 = r10;
if (r1) {
let r5 = channelId;
if (r5 == null) {
r5 = null;
}
c3017_14 = r5;
r17 = r5;
}
const r7 = r10 !== r17 ? c3017_11.delete(MediaEngineContextTypes.DEFAULT) || false : false;
L37: {
if (channelId == null) {
if (userId === id && sessionId2 === sessionId) {
r53 = c3017_11.delete(MediaEngineContextTypes.DEFAULT) || r7;
} else {
const DEFAULT3 = MediaEngineContextTypes.DEFAULT;
const r51 = c3017_11.get(DEFAULT3);
const r52 = r51 == null;
r53 = false;
if (!r52) {
const r55 = r51.delete(userId);
const size2 = r51.size;
r53 = r55;
if (size2 === 0) {
c3017_11.delete(DEFAULT3);
r53 = r55;
}
}
if (!r53) {
r53 = r7;
}
}
r29 = r53;
} else {
if (userId === id && sessionId2 !== sessionId) {
r29 = c3017_11.delete(MediaEngineContextTypes.DEFAULT) || r7;
break L37;
}
const r2 = userId !== id && channelId !== RTCConnectionStore.getChannelId();
r29 = r7;
if (r2) {
const DEFAULT2 = MediaEngineContextTypes.DEFAULT;
const r32 = c3017_11.get(DEFAULT2);
const r33 = r32 == null;
let r34 = false;
if (!r33) {
const r36 = r32.delete(userId);
const size = r32.size;
r34 = r36;
if (size === 0) {
c3017_11.delete(DEFAULT2);
r34 = r36;
}
}
if (!r34) {
r34 = r7;
}
r29 = r34;
}
}
}
if (!r29) {
r29 = acc;
}
return r29;
}, false);
},
PUSH_TO_TALK_STATE_CHANGE: function handlePushToTalkStateChange(a0) {
isActive = a0.isActive;
}
});
export default speakingStore;
+62
View File
@@ -0,0 +1,62 @@
// Metro module 12810 (f12811).
import { Storage } from "../_bundle/Module595";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c8836_2 = "MaintenanceStore";
let incident = null;
let maintenance = null;
const id = null;
class MaintenanceStore extends Module589.Store {
static displayName = "MaintenanceStore";
initialize() {
id = Storage.get(c8836_2);
}
getIncident() {
return incident;
}
getScheduledMaintenance() {
let r14;
let r7 = maintenance?.scheduled_until;
if (r7 == null) {
r7 = maintenance?.scheduled_for;
}
L11: {
const r13 = maintenance != null;
r14 = null;
if (r13) {
const id2 = maintenance.id;
r14 = null;
if (id2 !== id) {
if (r7 != null) {
const r26 = Date.now() < new Date(r7).getTime();
r14 = null;
if (!r26) {
break L11;
}
}
r14 = maintenance;
}
}
}
return r14;
}
}
const maintenanceStore = new MaintenanceStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
incident = null;
},
STATUS_PAGE_INCIDENT: function handleIncident(a0) {
incident = a0.incident;
},
STATUS_PAGE_SCHEDULED_MAINTENANCE: function handleScheduledMaintenance(a0) {
maintenance = a0.maintenance;
},
STATUS_PAGE_SCHEDULED_MAINTENANCE_ACK: function handleScheduledMaintenanceAck() {
if (maintenance == null) {
return false;
}
id = maintenance.id;
Storage.set(c8836_2, id);
}
});
export default maintenanceStore;
+352
View File
@@ -0,0 +1,352 @@
// Metro module 4275 (f4276).
import RunningGameStore_native from "../modules/game_detection/RunningGameStore.native";
import AuthenticationStore from "./AuthenticationStore";
import MediaEngineStore from "./MediaEngineStore";
import PresenceStore from "./PresenceStore";
import RTCConnectionStore from "./RTCConnectionStore";
import { RTCConnectionQuality, StreamLayouts } from "../Constants";
import { StreamTypes } from "../modules/go_live/Constants";
import Module38 from "../_bundle/Module38";
import StreamRTCConnection, { StreamRTCAnalyticsContext } from "../modules/go_live/StreamRTCConnection";
import Module12 from "../_bundle/Module12";
import { encodeStreamKey, decodeStreamKey } from "../modules/go_live/utils/StreamKeyUtils";
import { getStreamerApplication } from "../modules/go_live/utils/StreamerApplicationSelectors";
import Dispatcher from "../Dispatcher";
import { MediaEngineContextTypes } from "../_bundle/Module4286";
import { isPlatformEmbedded } from "../utils/PlatformUtils";
import Module589 from "../_bundle/Module589";
import canSpectate from "../modules/go_live/utils/canSpectate";
let r86;
let sessionId, $mk74169 = function() {
return (a0, a1) => {
a0.destroy.call(a0, a0.isOwner ? "sender-disconnect" : "receiver-disconnect");
delete c2514_18[a1];
delete c2514_16[a1];
};
};
let c2514_11 = {};
let c2514_12 = {};
let c2514_13 = {};
let c2514_14 = {};
let c2514_15 = {};
let c2514_16 = {};
let PORTRAIT = StreamLayouts.PORTRAIT;
let c2514_18 = {};
class StreamRTCConnectionStore extends Module589.Store {
static displayName = "StreamRTCConnectionStore";
initialize() {
this.waitFor(AuthenticationStore, MediaEngineStore, RTCConnectionStore, RunningGameStore_native);
}
getRTCConnections() {
return c2514_18;
}
getAllActiveStreamKeys() {
return Object.keys(c2514_18);
}
getRTCConnection(a0) {
return c2514_18[a0];
}
getQuality(a0) {
let r12;
if (canSpectate(MediaEngineStore) && a0 != null) {
let r15 = c2514_18[a0]?.quality;
if (r15 == null) {
r15 = RTCConnectionQuality.UNKNOWN;
}
r12 = r15;
} else {
r12 = RTCConnectionQuality.UNKNOWN;
}
return r12;
}
getMediaSessionId(a0) {
if (a0 == null) {
return null;
}
const r5 = c2514_18[a0];
return r5 != null ? r5 != null ? r5.getMediaSessionId() : null : void 0;
}
getRtcConnectionId(a0) {
if (a0 == null) {
return null;
}
const r5 = c2514_18[a0];
return r5 != null ? r5 != null ? r5.getRTCConnectionId() : null : void 0;
}
getVideoStats(a0) {
if (a0 == null) {
return null;
}
const r4 = c2514_18[a0];
return r4 != null ? r4.getVideoStats() : null;
}
getHostname(a0) {
if (a0 == null) {
return "";
}
const r7 = c2514_18[a0];
return r7 != null ? r7.hostname != null ? r7.hostname : "" : "";
}
getRegion(a0) {
if (a0 == null) {
return null;
}
const r4 = c2514_18[a0];
return r4 != null ? r4.getRegion() : null;
}
getMaxViewers(a0) {
if (a0 == null) {
return null;
}
const r4 = c2514_18[a0];
return r4 != null ? r4.getMaxViewers() : null;
}
getStreamSourceId(a0) {
return c2514_14[a0];
}
getLastNonZeroRemoteVideoSinkWantsTime(a0) {
return c2514_16[a0];
}
getUserIds(a0) {
const r3 = c2514_18[a0];
return r3 == null ? void 0 : r3.getUserIds();
}
isUserConnected(a0, a1) {
const r4 = c2514_18[a0];
return r4 == null ? void 0 : r4.getIsUserConnected(a1);
}
getSecureFramesState(a0) {
const r3 = c2514_18[a0];
return r3 == null ? void 0 : r3.getSecureFramesState();
}
getSecureFramesRosterMapEntry(a0, a1) {
const r4 = c2514_18[a0];
const r5 = r4 == null ? void 0 : r4.getSecureFramesRosterMap();
return r5 == null ? void 0 : r5.get(a1);
}
}
if (MediaEngineStore.isSupported()) {
const handleRtcAction = function handleRtcAction() {
return true;
};
r86 = {
CONNECTION_OPEN: function handleConnectionOpen(a0) {
sessionId = a0.sessionId;
Module12.forEach(c2514_18, $mk74169());
},
CONNECTION_CLOSED: function handleConnectionClosed() {
sessionId = null;
Module12.forEach(c2514_18, $mk74169());
},
RTC_CONNECTION_STATE: handleRtcAction,
RTC_CONNECTION_PING: handleRtcAction,
RTC_CONNECTION_LOSS_RATE: handleRtcAction,
RTC_CONNECTION_UPDATE_ID: function handleRtcConnectionUpdateId(c14071_0) {
return Module12.some(c2514_18, (a0) => a0 === c14071_0.connection);
},
RTC_CONNECTION_SECURE_FRAMES_UPDATE: handleRtcAction,
RTC_CONNECTION_REMOTE_VIDEO_SINK_WANTS: function handleRtcConnectionRemoteVideoSinkWants(a0) {
const { context, wants, userId, guildId } = a0;
const r19 = encodeStreamKey({
streamType: guildId == null ? StreamTypes.CALL : StreamTypes.GUILD,
guildId,
channelId: a0.channelId,
ownerId: userId
});
let r0 = context === MediaEngineContextTypes.STREAM && c2514_18[r19] != null;
if (r0) {
let r34 = !!Object.entries(wants).some((item) => {
const [r14, r15] = item;
return r14 !== "any" && r15 !== 0;
});
if (r34) {
c2514_16[r19] = performance.now();
r34 = void 0;
}
r0 = r34;
}
return r0;
},
STREAM_START: function handleStreamStart(a0) {
const { streamType, guildId, channelId, appContext } = a0;
let pid = a0.pid;
const { sourceId, sourcePid, nativePickerStyleUsed, goLiveModalDurationMs, analyticsLocations } = a0;
const r24 = encodeStreamKey({
streamType,
guildId,
channelId,
ownerId: AuthenticationStore.getId()
});
c2514_11[r24] = {
appContext,
analyticsLocations
};
Module12.forEach(c2514_18, ({ analyticsContext, isOwner }) => {
analyticsContext.setActionContext(appContext);
analyticsContext.setNativePickerStyleUsed(nativePickerStyleUsed);
if (isOwner) {
analyticsContext.trackStart();
}
});
if (pid == null) {
pid = sourcePid;
}
c2514_14[r24] = sourceId;
c2514_13[r24] = pid;
if (pid != null) {
const gameForPID = RunningGameStore_native.getGameForPID(pid);
if (gameForPID != null) {
c2514_12[r24] = {
name: gameForPID.name,
id: gameForPID.id,
exe: gameForPID.exeName,
distributor: gameForPID.distributor,
sku: gameForPID.sku,
gameMetadata: gameForPID.gameMetadata
};
}
const r51 = c2514_18[r24];
if (r51 != null) {
r51.analyticsContext.updateStreamApplication(c2514_12[r24]);
}
} else {
const r36 = c2514_18[r24];
if (r36 != null) {
r36.analyticsContext.updateStreamApplication(null);
}
}
if (goLiveModalDurationMs != null) {
c2514_15[r24] = goLiveModalDurationMs;
} else {
delete c2514_15[r24];
}
},
STREAM_STOP: function handleStreamStop({ appContext: appContext2, streamKey }) {
c2514_11[streamKey] = {
appContext: appContext2,
analyticsLocations: void 0
};
Module12.forEach(c2514_18, ({ analyticsContext, isOwner }) => {
analyticsContext.setActionContext(appContext2);
if (isOwner) {
analyticsContext.trackEnd();
}
});
c2514_14[streamKey] = null;
c2514_13[streamKey] = null;
delete c2514_15[streamKey];
},
STREAM_CREATE: function handleStreamCreate({ streamKey, rtcServerId, rtcChannelId, region, viewerIds }) {
let r40, streamSourceType;
let r8 = c2514_18[streamKey];
const r18 = decodeStreamKey(streamKey);
if (r8 == null && rtcServerId != null) {
if (c2514_13[streamKey] == null) {
c2514_12[streamKey] = null;
}
if (c2514_12[streamKey] == null && c2514_14[streamKey] == null) {
c2514_12[streamKey] = getStreamerApplication(r18, PresenceStore);
}
L28: {
r40 = {
streamRegion: region,
streamApplication: c2514_12[streamKey],
streamSourceType: null,
actionContext: null,
numViewers: null,
goLiveModalDurationMs: null,
analyticsLocations: null
};
const r42 = c2514_14[streamKey];
const r43 = r42 == null;
streamSourceType = "unknown";
if (!r43) {
if (!isPlatformEmbedded) {
if (platform?.name !== "Chrome") {
if (platform?.name === "Firefox") {
streamSourceType = r42 !== "" ? "window" : "screen";
break L28;
}
const name = platform?.name;
streamSourceType = "unknown";
if (name !== "Safari") {
break L28;
}
streamSourceType = "window";
break L28;
}
}
streamSourceType = r42.startsWith("web-contents-media-stream:") ? "tab" : r42.startsWith("window:") ? "window" : r42.startsWith("screen:") ? "screen" : "unknown";
}
}
r40.streamSourceType = streamSourceType;
r40.actionContext = c2514_11[streamKey]?.appContext;
r40.numViewers = viewerIds != null ? viewerIds.length : 0;
r40.goLiveModalDurationMs = c2514_15[streamKey];
r40.analyticsLocations = c2514_11[streamKey]?.analyticsLocations;
const streamRTCAnalyticsContext = new StreamRTCAnalyticsContext(r40);
Module38(sessionId != null, "Creating RTCConnection without session.");
const streamRTCConnection = new StreamRTCConnection({
sessionId,
streamKey,
serverId: rtcServerId,
channelId: rtcChannelId,
initialLayout: PORTRAIT,
analyticsContext: streamRTCAnalyticsContext,
parentMediaSessionId: RTCConnectionStore.getMediaSessionId()
});
c2514_18[streamKey] = streamRTCConnection;
r8 = streamRTCConnection;
}
delete c2514_16[streamKey];
Dispatcher.dispatch({
type: "MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET",
mediaEngineConnectionId: r8.getMediaEngineConnectionId()
});
},
STREAM_SERVER_UPDATE: function handleStreamServerUpdate(a0) {
const r4 = c2514_18[a0.streamKey];
if (r4 == null) {
return false;
}
r4.connect(a0.endpoint, a0.token);
},
STREAM_UPDATE: function handleStreamUpdate({ streamKey, viewerIds, paused }) {
const r8 = c2514_18[streamKey];
if (r8 == null) {
return false;
}
if (viewerIds != null) {
r8.analyticsContext.trackViewerCount(viewerIds.length);
}
r8.streamUpdate(paused);
},
STREAM_DELETE: function handleStreamDelete({ streamKey }) {
const r6 = c2514_18[streamKey];
if (r6 == null) {
return false;
}
Dispatcher.dispatch({
type: "MEDIA_ENGINE_CONNECTION_STATS_HISTORY_RESET",
mediaEngineConnectionId: r6.getMediaEngineConnectionId()
});
r6.destroy("stream-end");
delete c2514_18[streamKey];
},
STREAM_LAYOUT_UPDATE: function handleLayoutUpdate({ layout }) {
PORTRAIT = layout;
Object.values(c2514_18).forEach((item) => item.layoutChange(layout));
},
VIDEO_SIZE_UPDATE: function handleVideoSizeUpdate({ streamId, dimensions, zoom }) {
Module12.forEach(c2514_18, (a0) => {
if (a0 != null) {
a0.setVideoSize(streamId, dimensions, zoom);
}
});
}
};
} else {
r86 = {};
}
const streamRTCConnectionStore = new StreamRTCConnectionStore(Dispatcher, r86);
export default streamRTCConnectionStore;
+171
View File
@@ -0,0 +1,171 @@
// Metro module 4029 (f4030).
import AuthenticationStore from "./AuthenticationStore";
import { AnalyticEvents } from "../Constants";
import AnalyticsUtils from "../utils/AnalyticsUtils";
import Module589 from "../_bundle/Module589";
import { getOverlayStreamerModeConfig } from "../modules/overlay/OverlayV3Experiment";
import Dispatcher from "../Dispatcher";
let c2307_5 = {
enabled: false,
autoToggle: true,
hideInstantInvites: true,
hidePersonalInformation: true,
disableSounds: true,
disableNotifications: true,
disabledOverlayWidgets: [],
enableContentProtection: false
};
let c2307_6 = {};
let c2307_7 = {
...c2307_5
};
class StreamerModeStore extends Module589.PersistedStore {
static displayName = "StreamerModeStore";
static persistKey = "StreamerModeStore";
static migrations = [(a0) => {
let r8;
const id = AuthenticationStore.getId();
if (a0 != null && id != null) {
r8 = {};
r8[id] = {
...a0
};
} else {
r8 = {};
}
return r8;
}];
initialize(a0) {
Object.assign(c2307_6, a0);
this.syncWith([AuthenticationStore], () => {
let r10;
const id = AuthenticationStore.getId();
if (id != null) {
let r13 = c2307_6[id];
if (r13 == null) {
const r4 = {
...c2307_5
};
c2307_6[id] = r4;
r13 = r4;
}
r10 = r13;
} else {
r10 = {
...c2307_5
};
}
c2307_7 = r10;
});
}
getState() {
return c2307_6;
}
getSettings() {
return c2307_7;
}
get enabled() {
return c2307_7.enabled;
}
get autoToggle() {
return c2307_7.autoToggle;
}
get hideInstantInvites() {
return this.enabled && c2307_7.hideInstantInvites;
}
get hidePersonalInformation() {
return this.enabled && c2307_7.hidePersonalInformation;
}
get disableSounds() {
return this.enabled && c2307_7.disableSounds;
}
get disableNotifications() {
return this.enabled && c2307_7.disableNotifications;
}
get enableContentProtection() {
return this.enabled && c2307_7.enableContentProtection;
}
isOverlayWidgetDisabled(a0) {
let r13 = !!getOverlayStreamerModeConfig("StreamerModeStore").enabled;
if (r13) {
let enabled2 = this.enabled;
if (enabled2) {
const disabledOverlayWidgets = c2307_7.disabledOverlayWidgets;
enabled2 = (disabledOverlayWidgets == null ? void 0 : disabledOverlayWidgets.includes(a0)) === true;
}
r13 = enabled2;
}
return r13;
}
}
const streamerModeStore = new StreamerModeStore(Dispatcher, {
LOGOUT: function handleLogout(a0) {
if (!a0.isSwitchingAccount) {
c2307_6 = {};
}
},
MULTI_ACCOUNT_REMOVE_ACCOUNT: function handleMultiAccountRemove(a0) {
if (a0.userId in c2307_6) {
delete c2307_6[a0.userId];
}
},
STREAMER_MODE_UPDATE: function handleStreamerModeUpdate(a0) {
const r9 = {
...c2307_7
};
const r8 = Object;
const r17 = {};
r17[a0.key] = a0.value;
r8.assign(c2307_7, r17);
if (a0.key === "enabled" && typeof a0.value === "boolean") {
AnalyticsUtils.track(AnalyticEvents.STREAMER_MODE_TOGGLE, {
enabled: a0.value,
automatic: false
});
} else {
const UPDATE_STREAMER_MODE_SETTINGS = AnalyticEvents.UPDATE_STREAMER_MODE_SETTINGS;
const disabledOverlayWidgets = c2307_7.disabledOverlayWidgets;
let disabled_overlay_widgets = disabledOverlayWidgets == null ? void 0 : disabledOverlayWidgets.join(",");
if (disabled_overlay_widgets == null) {
disabled_overlay_widgets = "";
}
const disabledOverlayWidgets2 = r9.disabledOverlayWidgets;
let old_disabled_overlay_widgets = disabledOverlayWidgets2 == null ? void 0 : disabledOverlayWidgets2.join(",");
if (old_disabled_overlay_widgets == null) {
old_disabled_overlay_widgets = "";
}
AnalyticsUtils.track(UPDATE_STREAMER_MODE_SETTINGS, {
enabled: c2307_7.enabled,
automatic: c2307_7.autoToggle,
disable_notifications: c2307_7.disableNotifications,
disable_sounds: c2307_7.disableSounds,
hide_instant_invites: c2307_7.hideInstantInvites,
hide_personal_info: c2307_7.hidePersonalInformation,
enable_content_protection: c2307_7.enableContentProtection,
disabled_overlay_widgets,
old_enabled: r9.enabled,
old_automatic: r9.autoToggle,
old_disable_notifications: r9.disableNotifications,
old_disable_sounds: r9.disableSounds,
old_hide_instant_invites: r9.hideInstantInvites,
old_hide_personal_info: r9.hidePersonalInformation,
old_enable_content_protection: r9.enableContentProtection,
old_disabled_overlay_widgets
});
}
return true;
},
RUNNING_STREAMER_TOOLS_CHANGE: function handleRunningStreamerToolsChange(a0) {
if (c2307_7.autoToggle) {
const enabled2 = a0.count > 0;
c2307_7.enabled = enabled2;
AnalyticsUtils.track(AnalyticEvents.STREAMER_MODE_TOGGLE, {
enabled: enabled2,
automatic: true
});
return true;
}
return false;
}
});
export default streamerModeStore;
+307
View File
@@ -0,0 +1,307 @@
// Metro module 9274 (f9275).
import GuildMemberCountStore from "./GuildMemberCountStore";
import GuildStore from "./GuildStore";
import PermissionStore from "./PermissionStore";
import SelectedGuildStore from "./SelectedGuildStore";
import UserStore from "./UserStore";
import { FIRST_RUN_DATE_KEY, GuildFeatures, Permissions } from "../Constants";
import Durations from "../utils/Durations";
import { surveyFetch } from "../actions/SurveyActionCreators";
import { deserialize } from "../_bundle/HighLow";
import { Storage } from "../_bundle/Module595";
import Module3771 from "../_bundle/Module3771";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c6104_12, c6104_13, c6104_14, c6104_15, c6104_16, survey, c6104_18, DAY, c6104_20, c6104_21, c6104_22, setSurvey, handleSelectedGuildChange, $mk82199 = function() {
return function meetsGuildRequirements(a0) {
let r42;
const { guild_requirements = [], guild_size = [null, null], guild_permissions = [] } = a0;
if (guild_requirements.length === 0) {
return true;
}
for (const item of guild_requirements) {
if (c6104_22.has(item)) {
continue;
}
return false;
}
const r54 = guild_requirements.includes(c6104_21.GUILD_SIZE_ALL);
let r56 = true;
loop14: for (const r64 of GuildStore.getGuildsArray()) {
const r65 = r64;
if (!(!r54 && !guild_requirements.includes(c6104_21.GUILD_SIZE))) {
const memberCount = GuildMemberCountStore.getMemberCount(r65.id);
if (memberCount == null) {
r56 = false;
continue;
}
if (guild_size[0] != null && memberCount < guild_size[0]) {
r56 = false;
continue;
}
if (guild_size[1] != null && memberCount > guild_size[1]) {
r56 = false;
continue;
}
}
if (guild_requirements.includes(c6104_21.IS_COMMUNITY) && !r65.features.has(GuildFeatures.COMMUNITY)) {
continue;
}
if (guild_requirements.includes(c6104_21.IS_HUB) && !r65.features.has(GuildFeatures.HUB)) {
continue;
}
if (guild_requirements.includes(c6104_21.GUILD_PERMISSIONS)) {
if (guild_permissions.length === 0) {
continue;
}
let r108 = false;
let r110 = guild_permissions[Symbol.iterator]();
const next = r110.next;
while (true) {
const r113 = r110 === void 0 ? void 0 : (r42 = next.call(r110)).done ? r110 = void 0 : r42.value;
if (r110 !== void 0) {
L34: {
try {
try {
if (PermissionStore.can(deserialize(r113), r65)) {
r108 = true;
break L34;
}
continue;
} catch ($e) {
continue;
}
} catch (r126) {
if (r110 !== void 0 && typeof r110.return === "function") {
try {
r110.return();
} catch {}
}
throw r126;
}
}
const r124 = r110;
if (r124 !== void 0 && typeof r124.return === "function") {
r124.return();
}
}
if (r108) {
break;
}
continue loop14;
}
}
const id = UserStore.getCurrentUser()?.id;
const r135 = id === r65.ownerId;
const r140 = PermissionStore.can(Permissions.ADMINISTRATOR, r65);
if (guild_requirements.includes(c6104_21.IS_OWNER) && !r135) {
continue;
}
if (guild_requirements.includes(c6104_21.IS_ADMIN) && !r140) {
continue;
}
let r152 = c6104_16;
if (r152 == null) {
r152 = {};
}
c6104_16 = r152;
if (r152[a0.key] == null) {
c6104_16[a0.key] = a0;
}
const guildId = SelectedGuildStore.getGuildId();
const r161 = guildId != null && guildId === r65.id;
if (guild_requirements.includes(c6104_21.IS_VIEWING) && !r161) {
continue;
}
if (r54) {
continue;
}
return true;
}
if (r54 && r56) {
return true;
}
return false;
};
};
const fetchSurveyIfNeeded = function fetchSurveyIfNeeded() {
let r0 = c6104_18;
if (!r0) {
const r1 = c6104_13.lastFetched == null || Date.now() - c6104_13.lastFetched >= DAY;
r0 = r1 ? !r1 : c6104_13.surveyOverride == null;
}
if (!r0) {
c6104_18 = true;
surveyFetch(c6104_13.surveyOverride, true);
}
};
setSurvey = function setSurvey({ survey: survey2, isActionTriggered }) {
c6104_18 = false;
c6104_13.lastFetched = Date.now();
if (isActionTriggered) {
c6104_13.lastActionTriggered = Date.now();
}
if (c6104_13.hiddenSurveys == null) {
c6104_13.hiddenSurveys = {};
}
let r1 = survey2 != null;
const r5 = r1 ? c6104_13.hiddenSurveys[survey2.key] == null : r1;
if (r1) {
r1 = $mk82199()(survey2);
}
const r2 = c6104_14 || c6104_15;
const r38 = Storage.get(FIRST_RUN_DATE_KEY);
const r3 = r38 == null || Module3771().diff(r38, "day") < 7;
survey = r5 ? r1 ? r2 ? null : r3 ? null : survey2 : null : null;
};
handleSelectedGuildChange = function handleSelectedGuildChange() {
if (survey != null) {
let r10 = !!$mk82199()(survey);
if (!r10) {
survey = null;
r10 = false;
}
if (r10) {
return false;
}
}
let r11 = c6104_16;
if (r11 == null) {
r11 = {};
}
c6104_16 = r11;
const survey2 = Object.values(c6104_16)[0];
if (survey2 != null && $mk82199()(survey2)) {
setSurvey({
type: "SURVEY_FETCHED",
survey: survey2
});
} else if (survey != null) {
survey = null;
}
};
c6104_12 = {
hiddenSurveys: {},
surveyOverride: null,
lastFetched: null,
lastSeen: null,
lastActionTriggered: null
};
c6104_13 = c6104_12;
c6104_14 = false;
c6104_15 = false;
c6104_16 = {};
survey = null;
c6104_18 = false;
DAY = Durations.Millis.DAY;
c6104_20 = 10 * Durations.Millis.HOUR;
c6104_21 = {
IS_OWNER: "is_owner",
IS_ADMIN: "is_admin",
IS_COMMUNITY: "is_community",
GUILD_SIZE: "guild_size",
IS_HUB: "is_hub",
IS_VIEWING: "is_viewing",
GUILD_PERMISSIONS: "guild_permissions",
GUILD_SIZE_ALL: "guild_size_all"
};
c6104_22 = new Set(Object.values(c6104_21));
class SurveyStore extends Module589.PersistedStore {
static displayName = "SurveyStore";
static persistKey = "SurveyStore";
static migrations = [(a0) => {
const r1 = {
...a0
};
delete r1["validSurveys"];
delete r1["currentSurvey"];
delete r1["iosIsPushNotificationClicked"];
delete r1["iosIsInviteShown"];
delete r1["iosFirstRunDate"];
return r1;
}, (a0) => {
let lastSeen = a0.lastSeen;
if (lastSeen == null) {
lastSeen = null;
}
return {
...a0,
lastSeen
};
}, (a0) => {
let hiddenSurveys = a0.hiddenSurveys;
if (hiddenSurveys == null) {
hiddenSurveys = {};
}
return {
...a0,
hiddenSurveys
};
}];
initialize(a0) {
let r2 = a0;
this.waitFor(GuildMemberCountStore, GuildStore, PermissionStore, SelectedGuildStore, UserStore);
if (a0 == null) {
r2 = c6104_12;
}
c6104_13 = r2;
this.syncWith([SelectedGuildStore], handleSelectedGuildChange);
}
getState() {
return c6104_13;
}
getCurrentSurvey() {
return c6104_13.lastFetched == null || Date.now() - c6104_13.lastFetched >= DAY ? null : survey;
}
getSurveyOverride() {
return c6104_13.surveyOverride;
}
getLastSeenTimestamp() {
return c6104_13.lastSeen;
}
shouldAllowSurveyAction() {
const r6 = Date.now();
let lastActionTriggered = c6104_13.lastActionTriggered;
if (lastActionTriggered == null) {
lastActionTriggered = 0;
}
return r6 - lastActionTriggered >= c6104_20;
}
}
const surveyStore = new SurveyStore(Dispatcher, {
CONNECTION_OPEN: fetchSurveyIfNeeded,
CONNECTION_RESUMED: fetchSurveyIfNeeded,
SURVEY_FETCHED: setSurvey,
SURVEY_HIDE: function handleSurveyHide({ key }) {
c6104_13.hiddenSurveys[key] = true;
survey = null;
let r7 = c6104_16;
if (r7 == null) {
r7 = {};
}
c6104_16 = r7;
delete r7[key];
},
SURVEY_OVERRIDE: function handleSurveyOverride({ id }) {
c6104_13.surveyOverride = id;
if (id != null) {
delete c6104_13.hiddenSurveys[id];
}
surveyFetch(c6104_13.surveyOverride, true);
},
PUSH_NOTIFICATION_CLICK: function handlePushNotificationClick() {
c6104_14 = true;
},
DISPLAYED_INVITE_SHOW: function handleInviteShow() {
c6104_15 = true;
},
LOGOUT: function handleLogout() {
c6104_13.hiddenSurveys = {};
},
SURVEY_SEEN: function handleSurveySeen() {
c6104_13.lastSeen = Date.now();
}
});
export default surveyStore;
export { DAY as SURVEY_REFETCH_INTERVAL };
export { c6104_20 as SURVEY_ACTION_INTERVAL };
Loaded 100 of 33051 files, more files were not shown because too many files have changed in this diff. Show more