Files
discord-decomp/modules/applications/message_embed/utils/getPlayInContext.tsx
T
2026-11-01 12:12:55 +02:00

52 lines
2.7 KiB
TypeScript

// Metro module 11136 (f11137).
import EmbeddedActivitiesStore from "../../../activities/EmbeddedActivitiesStore";
import SelectedChannelStore from "../../../../stores/SelectedChannelStore";
import { useStateFromStores } from "../../../../_bundle/Module589";
import { useEmbeddedActivityLaunchability, EmbeddedActivityLaunchability, getEmbeddedActivityLaunchabilityForChannel } from "../../../activities/utils/getEmbeddedActivityLaunchability";
export function usePlayInContext(c18554_0) {
const stateFromStores = useStateFromStores([SelectedChannelStore], () => SelectedChannelStore.getChannelId());
const stateFromStores2 = useStateFromStores([EmbeddedActivitiesStore], () => {
if (stateFromStores == null) {
return null;
}
const r11 = EmbeddedActivitiesStore.getEmbeddedActivitiesForChannel(stateFromStores).filter((item) => item.applicationId === c18554_0);
return r11.length > 0 ? r11[0] : void 0;
});
const compositeInstanceId = stateFromStores2?.compositeInstanceId;
const location2 = stateFromStores2?.location;
const stateFromStores3 = useStateFromStores([EmbeddedActivitiesStore], () => EmbeddedActivitiesStore.getCurrentEmbeddedActivity());
return {
currentChannelId: stateFromStores,
instanceId: compositeInstanceId,
instanceLocation: location2,
isCurrentlyInInstance: compositeInstanceId != null && stateFromStores3?.compositeInstanceId === compositeInstanceId,
canLaunchInChannel: useEmbeddedActivityLaunchability(stateFromStores) === EmbeddedActivityLaunchability.CAN_LAUNCH
};
}
export function getPlayInContext(c18555_0, a1) {
const currentChannelId = a1 == null ? SelectedChannelStore.getChannelId() : a1;
if (currentChannelId == null) {
return {
currentChannelId: null,
instanceId: null,
instanceLocation: null,
isCurrentlyInInstance: false,
canLaunchInChannel: false
};
}
const r19 = currentChannelId != null ? getEmbeddedActivityLaunchabilityForChannel(currentChannelId) : EmbeddedActivityLaunchability.NO_CHANNEL;
const CAN_LAUNCH = EmbeddedActivityLaunchability.CAN_LAUNCH;
const r33 = EmbeddedActivitiesStore.getEmbeddedActivitiesForChannel(currentChannelId).filter((item) => item.applicationId === c18555_0);
const r36 = r33.length > 0 ? r33[0] : void 0;
const compositeInstanceId = r36?.compositeInstanceId;
const location2 = r36?.location;
const currentEmbeddedActivity = EmbeddedActivitiesStore.getCurrentEmbeddedActivity();
return {
currentChannelId,
instanceId: compositeInstanceId,
instanceLocation: location2,
isCurrentlyInInstance: compositeInstanceId != null && currentEmbeddedActivity?.compositeInstanceId === compositeInstanceId,
canLaunchInChannel: r19 === CAN_LAUNCH
};
}