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

58 lines
2.5 KiB
TypeScript

// Metro module 11447 (f11448).
import { MAX_STAGE_VOICE_USER_LIMIT } from "../../Constants";
import useChannelVideoLimit from "../video_calls/useChannelVideoLimit";
export default function useShowConnectedUserLimit({ channel, locked, video, selected }) {
const r5 = {
channel,
video
};
const channel2 = r5.channel;
let video2 = r5.video;
let considerMaxStageVoiceUserLimit = r5.considerMaxStageVoiceUserLimit;
if (considerMaxStageVoiceUserLimit === void 0) {
considerMaxStageVoiceUserLimit = true;
}
const limit = useChannelVideoLimit(channel2).limit;
const r11 = channel2.userLimit > 0 ? channel2.userLimit : -1;
if (video2) {
video2 = limit > 0;
}
const r22 = video2 ? r11 > 0 ? Math.min(r11, limit) : limit : r11;
return (considerMaxStageVoiceUserLimit ? r22 !== MAX_STAGE_VOICE_USER_LIMIT ? r22 : 0 : r22) > 0 && !locked && !selected;
};
export function useConnectedUserLimit(a0) {
const channel = a0.channel;
let video = a0.video;
let considerMaxStageVoiceUserLimit = a0.considerMaxStageVoiceUserLimit;
if (considerMaxStageVoiceUserLimit === void 0) {
considerMaxStageVoiceUserLimit = true;
}
const limit = useChannelVideoLimit(channel).limit;
const r9 = channel.userLimit > 0 ? channel.userLimit : -1;
if (video) {
video = limit > 0;
}
const r18 = video ? r9 > 0 ? Math.min(r9, limit) : limit : r9;
return considerMaxStageVoiceUserLimit ? r18 !== MAX_STAGE_VOICE_USER_LIMIT ? r18 : 0 : r18;
}
export function useConnectedUserLimitFormatted({ channel, video, userCount }) {
const r14 = {
channel,
video
};
const channel2 = r14.channel;
let video2 = r14.video;
let considerMaxStageVoiceUserLimit = r14.considerMaxStageVoiceUserLimit;
if (considerMaxStageVoiceUserLimit === void 0) {
considerMaxStageVoiceUserLimit = true;
}
const limit = useChannelVideoLimit(channel2).limit;
const r12 = channel2.userLimit > 0 ? channel2.userLimit : -1;
if (video2) {
video2 = limit > 0;
}
const r23 = video2 ? r12 > 0 ? Math.min(r12, limit) : limit : r12;
const r29 = considerMaxStageVoiceUserLimit ? r23 !== MAX_STAGE_VOICE_USER_LIMIT ? r23 : 0 : r23;
return r29 <= 0 ? null : userCount != null ? `${userCount >= 1000 ? `${Math.floor(userCount / 1000)}k${userCount % 1000 !== 0 ? "+" : ""}` : userCount.toFixed(0).padStart(2, "0")}/${r29 >= 1000 ? `${Math.floor(r29 / 1000)}k${r29 % 1000 !== 0 ? "+" : ""}` : r29.toFixed(0).padStart(2, "0")}` : r29 >= 1000 ? `${Math.floor(r29 / 1000)}k${r29 % 1000 !== 0 ? "+" : ""}` : r29.toFixed(0).padStart(2, "0");
}