Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}> = ({ members, onRemoveMember }) => {
const { goBack, reset } = useNativeNavigation()
const [groupName, setGroupName] = useState('New group')
const { call, error, done, reply } = (messengerMethodsHooks as any).useConversationCreate()
const createGroup = React.useCallback(
() => call({ displayName: groupName, contactsToInvite: members.map((m) => m.publicKey) }),
[groupName, members, call],
)
const [layout, setLayout] = useState(0)
const [{ flex, background, padding }] = useStyles()
const ctx = useMsgrContext()
const insets = useSafeAreaInsets()
const { t }: { t: any } = useTranslation()
React.useEffect(() => {
// TODO: better handle error
if (done) {
if (error) {
console.error('Failed to create group:', error)
} else if (reply?.publicKey) {
reset({
index: 0,
routes: [
{
name: Routes.Main.Home,
},
{
name: Routes.Chat.Group,
export const ChatHeader: React.FC<{ convPk: any; stickyDate: any; showStickyDate: any }> = ({
convPk,
stickyDate,
showStickyDate,
}) => {
const insets = useSafeAreaInsets()
const { navigate, goBack } = useNavigation()
const conv = useConversation(convPk)
const contact = useContact(conv?.contactPublicKey || null)
const [{ flex, padding, text, opacity, color, row }, { scaleSize }] = useStyles()
const [layoutHeader, onLayoutHeader] = useLayout() // to position date under blur
if (!conv || !contact) {
goBack()
console.warn('OneToOne: no conv', conv, contact)
return
}
const title = (conv as any).fake ? `FAKE - ${contact.displayName}` : contact?.displayName || ''
return (
}> = ({ id, stickyDate, showStickyDate }) => {
const { navigate, goBack } = useNavigation()
const insets = useSafeAreaInsets()
const [{ row, padding, flex, text, color }, { scaleSize }] = useStyles()
const conversation = useConversation(id)
const [layoutHeader, onLayoutHeader] = useLayout() // to position date under blur
return (
export const OneToOne: React.FC = ({ route: { params } }) => {
useNotificationsInhibitor((_ctx, notif) => {
if (
(notif.type === NT.TypeContactRequestSent &&
(notif.payload as any)?.payload?.contact?.conversationPublicKey === params?.convId) ||
(notif.type === NT.TypeMessageReceived &&
(notif.payload as any)?.payload?.interaction?.conversationPublicKey === params?.convId)
) {
return 'sound-only'
}
return false
})
const insets = useSafeAreaInsets()
const [{ flex, background }] = useStyles()
useReadEffect(params?.convId, 1000)
const { dispatch } = useNavigation()
const { t } = useTranslation()
const conv = useConversation(params?.convId)
const contact = useContact(conv?.contactPublicKey)
const ctx = useMsgrContext()
const isIncoming = contact?.state === beapi.messenger.Contact.State.IncomingRequest
const isFooterDisable = isIncoming
const placeholder = isFooterDisable
? t('chat.one-to-one.incoming-input-placeholder')
: t('chat.one-to-one.input-placeholder')
const [stickyDate, setStickyDate] = useState(conv?.lastUpdate || null)
const [showStickyDate, setShowStickyDate] = useState(false)
const NotificationBody: React.FC = (props) => {
const [{ border, flex, column, background }] = useStyles()
const insets = useSafeAreaInsets()
return (
{
if (gestureName === 'SWIPE_UP' && typeof props.onClose === 'function') {
props.onClose()
}
}}
style={[
border.shadow.big,
flex.tiny,
flex.justify.center,
column.item.center,
background.white,
{
position: 'absolute',
export const ChoosePreset = () => {
const { t }: { t: any } = useTranslation()
const { dispatch, setPersistentOption } = useMsgrContext()
const insets = useSafeAreaInsets()
const [{ text, padding, border, margin, flex, color }] = useStyles()
const performanceCheckList = [
{ title: t('onboarding.select-mode.performance.push-notif') },
{ title: t('onboarding.select-mode.performance.offline-message') },
{ title: t('onboarding.select-mode.performance.add-contact') },
{ title: t('onboarding.select-mode.performance.fast-message') },
]
const anonymityCheckList = [
{ title: t('onboarding.select-mode.high-level.disable-push-notif') },
{
title: t('onboarding.select-mode.high-level.disable-local-peer-discovery'),
subTitle: t('onboarding.select-mode.high-level.disable-local-peer-discovery-desc'),
},
{ title: t('onboarding.select-mode.high-level.on-same-network') },
useNotificationsInhibitor((_ctx, notif) => {
if (
notif.type === NT.TypeMessageReceived &&
(notif.payload as any)?.payload?.interaction?.conversationPublicKey === params?.convId
) {
return 'sound-only'
}
return false
})
const [{ background, flex }] = useStyles()
const { dispatch } = useNavigation()
useReadEffect(params.convId, 1000)
const conv = useConversation(params?.convId)
const { t } = useTranslation()
const ctx = useMsgrContext()
const insets = useSafeAreaInsets()
const lastInte = useLastConvInteraction(params?.convId || '')
const lastUpdate = conv?.lastUpdate || lastInte?.sentDate || conv?.createdDate || null
const [stickyDate, setStickyDate] = useState(lastUpdate || null)
const [showStickyDate, setShowStickyDate] = useState(false)
const [isSwipe, setSwipe] = useState(true)
useFocusEffect(
React.useCallback(() => {
AndroidKeyboardAdjust?.setAdjustResize()
return () => AndroidKeyboardAdjust?.setAdjustPan()
}, []),
)
return (