99 lines
3.6 KiB
TypeScript
99 lines
3.6 KiB
TypeScript
// Metro module 14954 (f14955).
|
|
import { useState, useMemo } from "react";
|
|
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
|
|
import LurkerPreviewCooldownBadge, { useHasExpired } from "../../../lurker_mode/native/LurkerPreviewCooldownBadge";
|
|
import { BADGE_MASK_SIZE, BADGE_MASK_UNREAD_SIZE, BADGE_PADDING, MaskedBadge } from "../../../../design/void/native";
|
|
import { useToken } from "../../../../design/tokens/native/useToken";
|
|
import Module712 from "../../../../_bundle/Module712";
|
|
import computeGuildsBarCutout from "../utils/computeGuildsBarCutout";
|
|
import GuildsBarGuildJoinRequestBadge from "../GuildsBarGuildJoinRequestBadge";
|
|
import InvitesDisabledBadge from "../../../guild/native/InvitesDisabledBadge";
|
|
const useStyles = createStyles({
|
|
bottomRightBadge: {
|
|
position: "absolute",
|
|
right: 9,
|
|
backgroundColor: "transparent",
|
|
borderColor: "transparent"
|
|
}
|
|
});
|
|
export default function useGuildsBarBottomRightBadge(a0) {
|
|
let state, setState, token, token2, memo;
|
|
const { mentionCount, isMentionLowImportance, joinRequestState, shouldShowInvitesDisabled = false } = a0;
|
|
let c21487_3 = shouldShowInvitesDisabled;
|
|
let lurkerPreviewExpiresAt = a0.lurkerPreviewExpiresAt;
|
|
if (lurkerPreviewExpiresAt === void 0) {
|
|
lurkerPreviewExpiresAt = null;
|
|
}
|
|
const expiresAt = lurkerPreviewExpiresAt;
|
|
state = void 0;
|
|
setState = void 0;
|
|
token = void 0;
|
|
token2 = void 0;
|
|
memo = void 0;
|
|
const styles = useStyles();
|
|
const hasExpired = useHasExpired(expiresAt);
|
|
[state, setState] = useState(() => mentionCount > 0 ? BADGE_MASK_SIZE : BADGE_MASK_UNREAD_SIZE);
|
|
token = useToken(Module712.modules.mobile.GUILD_BAR_ITEM_SIZE);
|
|
token2 = useToken(Module712.modules.mobile.GUILD_BAR_ITEM_MARGIN);
|
|
memo = useMemo(() => [styles.bottomRightBadge, {
|
|
bottom: token2 - BADGE_PADDING
|
|
}], [styles.bottomRightBadge, token2]);
|
|
return useMemo(() => {
|
|
if (mentionCount > 0) {
|
|
const cutout4 = computeGuildsBarCutout({
|
|
position: "bottom-right",
|
|
containerSize: token,
|
|
width: state - 2 * BADGE_PADDING
|
|
});
|
|
return {
|
|
badge: <MaskedBadge maskStyle={memo} value={mentionCount} isMentionLowImportance={isMentionLowImportance} accessibilityElementsHidden importantForAccessibility="no-hide-descendants" onLayout={(event) => {
|
|
const layout = event.nativeEvent.layout;
|
|
if (state !== layout.width) {
|
|
setState(layout.width);
|
|
}
|
|
}} />,
|
|
cutout: cutout4,
|
|
cutouts: [cutout4]
|
|
};
|
|
}
|
|
if (joinRequestState != null) {
|
|
const cutout3 = computeGuildsBarCutout({
|
|
position: "bottom-right",
|
|
containerSize: token
|
|
});
|
|
return {
|
|
badge: <GuildsBarGuildJoinRequestBadge style={memo} joinRequestState={joinRequestState} />,
|
|
cutout: cutout3,
|
|
cutouts: [cutout3]
|
|
};
|
|
}
|
|
if (c21487_3) {
|
|
const cutout2 = computeGuildsBarCutout({
|
|
position: "bottom-right",
|
|
containerSize: token
|
|
});
|
|
return {
|
|
badge: <InvitesDisabledBadge style={memo} />,
|
|
cutout: cutout2,
|
|
cutouts: [cutout2]
|
|
};
|
|
}
|
|
if (expiresAt != null && !hasExpired) {
|
|
const cutout = computeGuildsBarCutout({
|
|
position: "bottom-right",
|
|
containerSize: token
|
|
});
|
|
return {
|
|
badge: <LurkerPreviewCooldownBadge style={memo} expiresAt={expiresAt} />,
|
|
cutout,
|
|
cutouts: [cutout]
|
|
};
|
|
}
|
|
return {
|
|
badge: null,
|
|
cutout: void 0,
|
|
cutouts: void 0
|
|
};
|
|
}, [state, shouldShowInvitesDisabled, joinRequestState, mentionCount, isMentionLowImportance, memo, token, expiresAt, hasExpired]);
|
|
};
|