91 lines
3.2 KiB
TypeScript
91 lines
3.2 KiB
TypeScript
// Metro module 12219 (f12220).
|
|
import { useState, useCallback } from "react";
|
|
import { Pressable, View } from "react-native";
|
|
import RelationshipStore from "../../../stores/RelationshipStore";
|
|
import { RelationshipTypes } from "../../../Constants";
|
|
import { createStyles } from "../../../design/components/Styles/native/createStyles";
|
|
import Module712 from "../../../_bundle/Module712";
|
|
import { HideFriendRequestNotes } from "../../user_settings/UserSettings";
|
|
import { useStateFromStoresObject } from "../../../_bundle/Module589";
|
|
import { trackViewFriendRequestNote } from "../PeopleListTracking";
|
|
import { Text } from "../../../design/components/Text/native/Text";
|
|
import { Button } from "../../../design/components/Button/native/Button.native";
|
|
import { EyeIcon } from "../../../design/components/Icon/native/redesign/generated/EyeIcon";
|
|
import { intl, t } from "../../../intl/index.native";
|
|
const useStyles = createStyles({
|
|
container: {
|
|
width: "100%",
|
|
position: "relative",
|
|
padding: Module712.space.PX_12,
|
|
borderRadius: Module712.radii.md,
|
|
minHeight: 56,
|
|
flexDirection: "row",
|
|
alignItems: "center"
|
|
},
|
|
spoiler: {
|
|
position: "absolute",
|
|
top: 0,
|
|
left: 0,
|
|
right: 0,
|
|
bottom: 0,
|
|
justifyContent: "center",
|
|
alignItems: "center",
|
|
borderRadius: Module712.radii.md
|
|
},
|
|
hidden: {
|
|
opacity: 0
|
|
}
|
|
});
|
|
export default function FriendRequestNote(props) {
|
|
let note, setState;
|
|
const { userId, styles: styles2, backgroundColor, analyticsLocation } = props;
|
|
note = void 0;
|
|
setState = void 0;
|
|
const styles = useStyles();
|
|
const setting = HideFriendRequestNotes.useSetting();
|
|
const stateFromStoresObject = useStateFromStoresObject([RelationshipStore], () => ({
|
|
note: RelationshipStore.getNote(userId),
|
|
type: RelationshipStore.getRelationshipType(userId)
|
|
}));
|
|
note = stateFromStoresObject.note;
|
|
let accessible;
|
|
[accessible, setState] = useState(stateFromStoresObject.type === RelationshipTypes.PENDING_OUTGOING);
|
|
const callback = useCallback(() => {
|
|
setState(true);
|
|
let noteLength = note?.length;
|
|
if (noteLength == null) {
|
|
noteLength = 0;
|
|
}
|
|
trackViewFriendRequestNote({
|
|
analyticsLocation,
|
|
noteLength
|
|
});
|
|
}, [analyticsLocation, note]);
|
|
let r45 = null;
|
|
if (!setting) {
|
|
const r3 = note == null;
|
|
r45 = null;
|
|
if (!r3) {
|
|
let accessibilityLabel = "";
|
|
r45 = null;
|
|
if (note !== "") {
|
|
const style = accessible ? void 0 : styles.hidden;
|
|
if (accessible) {
|
|
accessibilityLabel = void 0;
|
|
}
|
|
r45 = <Pressable style={[styles.container, styles2]} onPress={callback}>
|
|
<View style={style}>
|
|
<Text accessible={accessible} accessibilityElementsHidden={!accessible} accessibilityLabel={accessibilityLabel} variant="redesign/message-preview/normal">{note}</Text>
|
|
</View>
|
|
{accessible ? null : <View style={[styles.spoiler, backgroundColor != null ? {
|
|
backgroundColor
|
|
} : void 0]}>
|
|
<Button icon={<EyeIcon size="sm" />} variant="secondary" size="sm" onPress={callback} text={intl.string(t.sB0q4C)} />
|
|
</View>}
|
|
</Pressable>;
|
|
}
|
|
}
|
|
}
|
|
return r45;
|
|
};
|