144 lines
5.2 KiB
TypeScript
144 lines
5.2 KiB
TypeScript
// Metro module 8316 (f8317).
|
|
import { THREAD_CHANNEL_TYPES } from "../../records/ChannelRecord";
|
|
import RelationshipStore from "../../stores/RelationshipStore";
|
|
import UserStore from "../../stores/UserStore";
|
|
import { ChannelTypes, StatusTypes } from "../../Constants";
|
|
import { intl, t } from "../../intl/index.native";
|
|
import { computeChannelName } from "./useChannelName";
|
|
import isRoleRequired from "./isRoleRequired";
|
|
import { getName, humanizeStatus } from "../../utils/UserUtils";
|
|
import { formatActiveA11yTimestamp } from "../content_inventory/utils";
|
|
export default function getChannelA11yLabel({ channel, unread = false, mentionCount = 0, voiceStates, embeddedActivitiesCount, activityNames, isSubscriptionGated, needSubscriptionToAccess, isIncomingCall = false, isOngoingCall = false, voiceChannelStartTime }) {
|
|
let r20, r74;
|
|
const channelName = computeChannelName(channel, UserStore, RelationshipStore);
|
|
const r39 = isRoleRequired(channel) ? intl.string(t["4qvAtn"]) : void 0;
|
|
const type = channel.type;
|
|
if (ChannelTypes.DM === type) {
|
|
r20 = mentionCount > 0 ? t.TO8LYt : unread ? t.F2MZsu : t.fYqXVY;
|
|
r74 = void 0;
|
|
} else if (ChannelTypes.GROUP_DM === type) {
|
|
r74 = [intl.formatToPlainString(mentionCount > 0 ? t.Lo0dCa : unread ? t["fxxUo/"] : t.lts3Ld, {
|
|
channelName,
|
|
mentionCount
|
|
}), intl.formatToPlainString(t.CxSA5N, {
|
|
members: channel.recipients.length + 1
|
|
})].join(", ");
|
|
r20 = void 0;
|
|
} else if (ChannelTypes.GUILD_STORE === type) {
|
|
r20 = t.Bo4msg;
|
|
r74 = void 0;
|
|
} else if (ChannelTypes.GUILD_DIRECTORY === type) {
|
|
r20 = t["92EAF2"];
|
|
r74 = void 0;
|
|
} else if (ChannelTypes.GUILD_ANNOUNCEMENT === type) {
|
|
r20 = mentionCount > 0 ? t.sDKIpm : unread ? t.VM7z8f : t.WJ3MPt;
|
|
r74 = void 0;
|
|
} else if (ChannelTypes.GUILD_VOICE === type) {
|
|
const r86 = [intl.formatToPlainString(t.bkpadO, {
|
|
channelName
|
|
})];
|
|
if (mentionCount > 0) {
|
|
r86.push(intl.formatToPlainString(t["3l1GOx"], {
|
|
mentionCount
|
|
}));
|
|
}
|
|
if (unread) {
|
|
r86.push(intl.string(t.x5zAGZ));
|
|
}
|
|
const userLimit = channel.userLimit;
|
|
if (voiceStates != null && voiceStates.length > 0) {
|
|
const overflow = voiceStates.length - 3;
|
|
r86.push(voiceStates.slice(0, 3).map((item) => {
|
|
let nick = item.nick;
|
|
const user = item.user;
|
|
if (nick == null) {
|
|
nick = getName(user);
|
|
}
|
|
return nick;
|
|
}).join(", "));
|
|
if (0 < overflow) {
|
|
r86.push(intl.formatToPlainString(t.sfgpgr, {
|
|
overflow
|
|
}));
|
|
}
|
|
if (userLimit != null && userLimit > 0) {
|
|
r86.push(intl.formatToPlainString(t["6qgTOF"], {
|
|
userCount: voiceStates.length,
|
|
limit: userLimit
|
|
}));
|
|
}
|
|
}
|
|
if (voiceChannelStartTime != null) {
|
|
r86.push(intl.formatToPlainString(t.JQtsGh, {
|
|
duration: formatActiveA11yTimestamp({
|
|
start: voiceChannelStartTime
|
|
}, Date.now())
|
|
}));
|
|
}
|
|
if (activityNames != null && activityNames.length > 0) {
|
|
r86.push(intl.formatToPlainString(t.LmYuHT, {
|
|
activeActivities: activityNames.join(", ")
|
|
}));
|
|
}
|
|
r74 = r86.join(", ");
|
|
r20 = void 0;
|
|
} else if (ChannelTypes.GUILD_STAGE_VOICE === type) {
|
|
r20 = t.TPPk2T;
|
|
r74 = void 0;
|
|
} else {
|
|
r20 = THREAD_CHANNEL_TYPES.has(channel.type) ? mentionCount > 0 ? t["ZL7+I6"] : unread ? t.YlVvmc : t["0nZpiF"] : mentionCount > 0 ? t.g8ONM0 : unread ? t.smf1CZ : t.s0JADj;
|
|
r74 = void 0;
|
|
}
|
|
const r239 = r74 != null ? [r74] : r20 != null ? [intl.formatToPlainString(r20, {
|
|
channelName,
|
|
mentionCount
|
|
})] : [];
|
|
if (isIncomingCall) {
|
|
r239.push(intl.string(t["fk1/bX"]));
|
|
} else if (isOngoingCall) {
|
|
r239.push(intl.string(t["NGg/fm"]));
|
|
}
|
|
if (embeddedActivitiesCount != null && embeddedActivitiesCount > 0) {
|
|
r239.push(intl.formatToPlainString(t.O6PLYd, {
|
|
activitiesCount: embeddedActivitiesCount
|
|
}));
|
|
}
|
|
const r284 = isSubscriptionGated ? needSubscriptionToAccess ? intl.string(t["oj+HOs"]) : intl.string(t.xI3TQQ) : void 0;
|
|
if (r284 != null) {
|
|
r239.push(r284);
|
|
}
|
|
if (r39 != null) {
|
|
r239.push(r39);
|
|
}
|
|
return r239.join(", ");
|
|
};
|
|
export function getStatusLabel(a0) {
|
|
if (StatusTypes.ONLINE === a0) {
|
|
return humanizeStatus(StatusTypes.ONLINE);
|
|
}
|
|
if (StatusTypes.IDLE === a0) {
|
|
return humanizeStatus(StatusTypes.IDLE);
|
|
}
|
|
if (StatusTypes.DND === a0) {
|
|
return humanizeStatus(StatusTypes.DND);
|
|
}
|
|
if (StatusTypes.INVISIBLE === a0) {
|
|
return humanizeStatus(StatusTypes.INVISIBLE);
|
|
}
|
|
return "";
|
|
}
|
|
export function getChannelA11yHint({ channel, muted, userStatus, isFavorite }) {
|
|
const r12 = [];
|
|
if (isFavorite) {
|
|
r12.push(intl.string(t.cCPjSK));
|
|
}
|
|
if (muted === true) {
|
|
r12.push(intl.string(t.C4zCMb));
|
|
return r12.join(", ");
|
|
}
|
|
if (channel.type === ChannelTypes.DM && userStatus != null) {
|
|
r12.push(StatusTypes.ONLINE === userStatus ? humanizeStatus(StatusTypes.ONLINE) : StatusTypes.IDLE === userStatus ? humanizeStatus(StatusTypes.IDLE) : StatusTypes.DND === userStatus ? humanizeStatus(StatusTypes.DND) : StatusTypes.INVISIBLE === userStatus ? humanizeStatus(StatusTypes.INVISIBLE) : "");
|
|
}
|
|
return r12.length > 0 ? r12.join(", ") : void 0;
|
|
}
|