Files
discord-decomp/modules/guild_rooms/GuildRoomStore.tsx
T
2026-11-01 12:12:55 +02:00

243 lines
7.0 KiB
TypeScript

// Metro module 16193 (f16194).
import _objectWithoutProperties from "../../_bundle/_objectWithoutProperties";
import AuthenticationStore from "../../stores/AuthenticationStore";
import RTCConnectionStore from "../../stores/RTCConnectionStore";
import SelectedChannelStore from "../../stores/SelectedChannelStore";
import Module589 from "../../_bundle/Module589";
import { GuildRoomObjectTypes } from "./GuildRoomTypes";
import Dispatcher from "../../Dispatcher";
let _excluded, _excluded2, _excluded3, c11611_9, c11611_10, c11611_11, c11611_12, c11611_13, c11611_14, c11611_15, position, c11611_17, c11611_18, c11611_19, c11611_20;
const handleSelectedChannelStoreChange = function handleSelectedChannelStoreChange() {
const voiceChannelId = SelectedChannelStore.getVoiceChannelId();
if (voiceChannelId != null) {
c11611_18.delete(voiceChannelId);
let r9 = c11611_17[voiceChannelId];
if (r9 == null) {
r9 = true;
}
c11611_17[voiceChannelId] = r9;
}
};
const handleNoteCreateComplete = function handleNoteCreateComplete(a0) {
delete c11611_20[a0.roomId];
};
_excluded = ["users", "objects"];
_excluded2 = ["users", "objects"];
_excluded3 = ["users"];
c11611_9 = new Map();
c11611_10 = {};
c11611_11 = [];
c11611_12 = new Map();
c11611_13 = {};
c11611_14 = {};
c11611_15 = {};
position = null;
c11611_17 = {};
c11611_18 = new Map();
c11611_19 = false;
c11611_20 = {};
class GuildRoomStore extends Module589.Store {
initialize() {
this.waitFor(AuthenticationStore, RTCConnectionStore, SelectedChannelStore);
this.syncWith([SelectedChannelStore], handleSelectedChannelStoreChange);
}
getRoom(a0) {
let r4 = c11611_13[a0];
if (r4 == null) {
r4 = c11611_10;
}
return r4;
}
getRoomUsers(a0) {
let r4 = c11611_14[a0];
if (r4 == null) {
r4 = c11611_9;
}
return r4;
}
getRoomObjects(a0) {
let r4 = c11611_15[a0];
if (r4 == null) {
r4 = c11611_12;
}
return r4;
}
getPendingPosition() {
return position;
}
getMediaSessionId(a0) {
return c11611_18.get(a0);
}
isVisible(a0) {
let r4 = c11611_17[a0];
if (r4 == null) {
r4 = true;
}
return r4;
}
getPendingNote(a0) {
let r4 = c11611_20[a0];
if (r4 == null) {
r4 = null;
}
return r4;
}
getNotes(a0) {
let r13 = this.getRoomObjects(a0).get(GuildRoomObjectTypes.NOTE);
if (r13 == null) {
r13 = c11611_11;
}
return r13;
}
}
const guildRoomStore = new GuildRoomStore(Dispatcher, {
GUILD_ROOM_CONNECT: function handleConnect({ room, guildId }) {
const { users, objects } = room;
c11611_13[room.roomId] = _objectWithoutProperties(room, _excluded);
c11611_14[room.roomId] = users;
c11611_15[room.roomId] = objects;
if (guildId != null && position != null) {
position = null;
}
},
GUILD_ROOM_CONNECT_FAILURE: function handleConnectFailure({ roomId }) {
if (c11611_13[roomId] == null) {
return false;
}
const id = AuthenticationStore.getId();
const map = new Map(c11611_14[roomId]);
map.delete(id);
c11611_14[roomId] = map;
},
GUILD_ROOM_DISCONNECT: function handleDisconnect({ userId, roomId }) {
if (c11611_13[roomId] == null) {
return false;
}
const map = new Map(c11611_14[roomId]);
map.delete(userId);
c11611_14[roomId] = map;
if (c11611_19 && userId === AuthenticationStore.getId()) {
c11611_17[roomId] = true;
c11611_19 = false;
}
if (userId === AuthenticationStore.getId()) {
delete c11611_20[roomId];
}
},
GUILD_ROOM_UPDATE: function handleUpdate({ room }) {
const { users, objects } = room;
c11611_13[room.roomId] = _objectWithoutProperties(room, _excluded2);
c11611_15[room.roomId] = objects;
const id = AuthenticationStore.getId();
const r20 = c11611_14[room.roomId];
const r21 = r20 == null ? void 0 : r20.get(id);
c11611_14[room.roomId] = users;
if (r21 != null) {
const r25 = c11611_14[room.roomId];
if (r25 != null) {
r25.set(id, r21);
}
}
},
GUILD_ROOM_UPDATE_FAILURE: function handleUpdateFailure({ originalRoom, originalRoomUsers }) {
const r7 = c11611_13[originalRoom.roomId];
if (r7 == null) {
return false;
}
c11611_13[originalRoom.roomId] = {
...r7,
background: originalRoom.background
};
const id = AuthenticationStore.getId();
const r19 = originalRoomUsers.get(id);
if (r19 == null) {
const map = new Map(c11611_14[originalRoom.roomId]);
map.delete(id);
c11611_14[originalRoom.roomId] = map;
} else {
const r22 = c11611_14[originalRoom.roomId];
if (r22 != null) {
r22.set(id, r19);
}
}
},
GUILD_ROOM_FETCH_SUCCESS: function handleFetchSuccess({ room }) {
const users = room.users;
c11611_13[room.roomId] = _objectWithoutProperties(room, _excluded3);
c11611_14[room.roomId] = users;
},
GUILD_ROOM_LOCAL_POSITION_REQUESTED: function handleLocalPositionRequested(a0) {
position = a0.position;
},
GUILD_ROOM_TOGGLE_LAYOUT: function handleToggleLayout({ roomId, clearLayout }) {
c11611_17[roomId] = !c11611_17[roomId];
if (clearLayout) {
c11611_19 = true;
}
},
GUILD_ROOM_LOCAL_UPDATE: function handleLocalUpdate(a0) {
const { roomId, background } = a0;
let position2 = a0.position;
let statusId = a0.statusId;
let statusText = a0.statusText;
if (c11611_13[roomId] == null) {
return false;
}
const id = AuthenticationStore.getId();
if (background != null) {
c11611_13[roomId] = {
...c11611_13[roomId],
background
};
}
if (!(position2 == null && statusId == null)) {
const r22 = c11611_14[roomId].get(id);
if (r22 != null) {
const map = new Map(c11611_14[roomId]);
if (position2 == null) {
position2 = r22.position;
}
if (statusId == null) {
statusId = r22.statusId;
}
if (statusText == null) {
statusText = r22.statusText;
}
map.set(id, {
...r22,
position: position2,
statusId,
statusText
});
c11611_14[roomId] = map;
}
}
},
MEDIA_SESSION_JOINED: function handleMediaSessionJoined() {
const channelId = RTCConnectionStore.getChannelId();
const mediaSessionId = RTCConnectionStore.getMediaSessionId();
if (channelId != null && mediaSessionId != null) {
c11611_18.set(channelId, mediaSessionId);
}
},
GUILD_ROOM_PENDING_NOTE_START: function handlePendingNoteStart(a0) {
c11611_20[a0.roomId] = {
position: null
};
},
GUILD_ROOM_PENDING_NOTE_PLACE: function handlePendingNotePlace({ roomId, position: position2 }) {
const r5 = c11611_20[roomId];
if (r5 == null) {
return false;
}
c11611_20[roomId] = {
...r5,
position: position2
};
},
GUILD_ROOM_PENDING_NOTE_DELETE: handleNoteCreateComplete,
GUILD_ROOM_NOTE_CREATE_COMPLETE: handleNoteCreateComplete
});
export default guildRoomStore;
export { c11611_10 as DEFAULT_ROOM };