diff --git a/app/components/post_draft/typing/index.tsx b/app/components/post_draft/typing/index.tsx index c65e0dce7..dfa90b820 100644 --- a/app/components/post_draft/typing/index.tsx +++ b/app/components/post_draft/typing/index.tsx @@ -34,6 +34,7 @@ function Typing({ const typingHeight = useSharedValue(0); const typing = useRef>([]); const timeoutToDisappear = useRef(); + const mounted = useRef(false); const [refresh, setRefresh] = useState(0); const theme = useTheme(); @@ -63,7 +64,9 @@ function Typing({ clearTimeout(timeoutToDisappear.current); timeoutToDisappear.current = undefined; } - setRefresh(Date.now()); + if (mounted.current) { + setRefresh(Date.now()); + } }, [channelId, rootId]); const onUserStopTyping = useCallback((msg: any) => { @@ -85,14 +88,23 @@ function Typing({ if (typing.current.length === 0) { timeoutToDisappear.current = setTimeout(() => { - setRefresh(Date.now()); + if (mounted.current) { + setRefresh(Date.now()); + } timeoutToDisappear.current = undefined; }, 500); - } else { + } else if (mounted.current) { setRefresh(Date.now()); } }, []); + useEffect(() => { + mounted.current = true; + return () => { + mounted.current = false; + }; + }, []); + useEffect(() => { const listener = DeviceEventEmitter.addListener(Events.USER_TYPING, onUserStartTyping); return () => { diff --git a/app/screens/gallery/footer/copy_public_link/index.tsx b/app/screens/gallery/footer/copy_public_link/index.tsx index 855e60596..f4f1319e9 100644 --- a/app/screens/gallery/footer/copy_public_link/index.tsx +++ b/app/screens/gallery/footer/copy_public_link/index.tsx @@ -6,6 +6,7 @@ import React, {useEffect, useRef, useState} from 'react'; import {useIntl} from 'react-intl'; import {StyleSheet} from 'react-native'; import {useAnimatedStyle, withTiming} from 'react-native-reanimated'; +import {useSafeAreaInsets} from 'react-native-safe-area-context'; import {fetchPublicLink} from '@actions/remote/file'; import Toast from '@components/toast'; @@ -29,13 +30,14 @@ const styles = StyleSheet.create({ const CopyPublicLink = ({item, setAction}: Props) => { const {formatMessage} = useIntl(); const serverUrl = useServerUrl(); + const insets = useSafeAreaInsets(); const [showToast, setShowToast] = useState(); const [error, setError] = useState(''); const mounted = useRef(false); const animatedStyle = useAnimatedStyle(() => ({ position: 'absolute', - bottom: GALLERY_FOOTER_HEIGHT + 8, + bottom: GALLERY_FOOTER_HEIGHT + 8 + insets.bottom, opacity: withTiming(showToast ? 1 : 0, {duration: 300}), })); diff --git a/app/screens/gallery/footer/download_with_action/index.tsx b/app/screens/gallery/footer/download_with_action/index.tsx index 7a9e35c1b..59e34af0b 100644 --- a/app/screens/gallery/footer/download_with_action/index.tsx +++ b/app/screens/gallery/footer/download_with_action/index.tsx @@ -10,6 +10,7 @@ import FileViewer from 'react-native-file-viewer'; import FileSystem from 'react-native-fs'; import {TouchableOpacity} from 'react-native-gesture-handler'; import {useAnimatedStyle, withTiming} from 'react-native-reanimated'; +import {useSafeAreaInsets} from 'react-native-safe-area-context'; import Share from 'react-native-share'; import {downloadFile} from '@actions/remote/file'; @@ -66,6 +67,7 @@ const styles = StyleSheet.create({ const DownloadWithAction = ({action, item, onDownloadSuccess, setAction}: Props) => { const intl = useIntl(); const serverUrl = useServerUrl(); + const insets = useSafeAreaInsets(); const [showToast, setShowToast] = useState(); const [error, setError] = useState(''); const [saved, setSaved] = useState(false); @@ -110,7 +112,7 @@ const DownloadWithAction = ({action, item, onDownloadSuccess, setAction}: Props) const animatedStyle = useAnimatedStyle(() => ({ position: 'absolute', - bottom: GALLERY_FOOTER_HEIGHT + 8, + bottom: GALLERY_FOOTER_HEIGHT + 8 + insets.bottom, opacity: withTiming(showToast ? 1 : 0, {duration: 300}), })); diff --git a/app/screens/gallery/video_renderer/index.tsx b/app/screens/gallery/video_renderer/index.tsx index c207a72a2..ab9fa44b1 100644 --- a/app/screens/gallery/video_renderer/index.tsx +++ b/app/screens/gallery/video_renderer/index.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useCallback, useEffect, useMemo, useState} from 'react'; +import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {useIntl} from 'react-intl'; import {Alert, DeviceEventEmitter, Platform, StyleSheet, useWindowDimensions} from 'react-native'; import Animated, {Easing, useAnimatedRef, useAnimatedStyle, useSharedValue, withTiming, WithTimingConfig} from 'react-native-reanimated'; @@ -57,6 +57,7 @@ const VideoRenderer = ({height, index, initialIndex, item, isPageActive, onShoul const {formatMessage} = useIntl(); const serverUrl = useServerUrl(); const videoRef = useAnimatedRef