Files
discord-decomp/stores/ConnectedAppsStore.tsx
T
2026-11-01 12:12:55 +02:00

65 lines
1.8 KiB
TypeScript

// 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;