removed offSetY

This commit is contained in:
Avinash Lingaloo
2022-04-20 13:58:22 +04:00
parent a65af7057b
commit c59a2cfc05
6 changed files with 9 additions and 34 deletions

View File

@@ -3,17 +3,7 @@
import {FlatList} from '@stream-io/flat-list-mvcp'; import {FlatList} from '@stream-io/flat-list-mvcp';
import React, {ReactElement, useCallback, useEffect, useMemo, useRef, useState} from 'react'; import React, {ReactElement, useCallback, useEffect, useMemo, useRef, useState} from 'react';
import { import {DeviceEventEmitter, NativeScrollEvent, NativeSyntheticEvent, Platform, StyleProp, StyleSheet, ViewStyle} from 'react-native';
DeviceEventEmitter,
LayoutChangeEvent,
NativeScrollEvent,
NativeSyntheticEvent,
Platform,
StyleProp,
StyleSheet,
View,
ViewStyle,
} from 'react-native';
import Animated from 'react-native-reanimated'; import Animated from 'react-native-reanimated';
import {fetchPosts, fetchPostThread} from '@actions/remote/post'; import {fetchPosts, fetchPostThread} from '@actions/remote/post';
@@ -121,12 +111,6 @@ const PostList = ({
return orderedPosts.indexOf(START_OF_NEW_MESSAGES); return orderedPosts.indexOf(START_OF_NEW_MESSAGES);
}, [orderedPosts]); }, [orderedPosts]);
const [offSetY, setOffSetY] = useState(0);
const onLayout = useCallback((layoutEvent: LayoutChangeEvent) => {
const {layout} = layoutEvent.nativeEvent;
setOffSetY(layout.y);
}, []);
useEffect(() => { useEffect(() => {
listRef.current?.scrollToOffset({offset: 0, animated: false}); listRef.current?.scrollToOffset({offset: 0, animated: false});
}, [channelId]); }, [channelId]);
@@ -312,7 +296,6 @@ const PostList = ({
previousPost, previousPost,
shouldRenderReplyButton, shouldRenderReplyButton,
skipSaveddHeader, skipSaveddHeader,
offSetY,
}; };
return ( return (
@@ -324,7 +307,7 @@ const PostList = ({
{...postProps} {...postProps}
/> />
); );
}, [currentTimezone, highlightPinnedOrSaved, isTimezoneEnabled, orderedPosts, shouldRenderReplyButton, theme, offSetY]); }, [currentTimezone, highlightPinnedOrSaved, isTimezoneEnabled, orderedPosts, shouldRenderReplyButton, theme]);
const scrollToIndex = useCallback((index: number, animated = true, applyOffset = true) => { const scrollToIndex = useCallback((index: number, animated = true, applyOffset = true) => {
listRef.current?.scrollToIndex({ listRef.current?.scrollToIndex({
@@ -383,7 +366,6 @@ const PostList = ({
testID={`${testID}.flat_list`} testID={`${testID}.flat_list`}
/> />
</PostListRefreshControl> </PostListRefreshControl>
<View onLayout={onLayout}/>
{showMoreMessages && {showMoreMessages &&
<MoreMessages <MoreMessages
channelId={channelId} channelId={channelId}

View File

@@ -55,7 +55,6 @@ type PostProps = {
skipPinnedHeader?: boolean; skipPinnedHeader?: boolean;
style?: StyleProp<ViewStyle>; style?: StyleProp<ViewStyle>;
testID?: string; testID?: string;
offSetY: number;
}; };
const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => { const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => {
@@ -100,7 +99,7 @@ const Post = ({
appsEnabled, canDelete, currentUser, differentThreadSequence, filesCount, hasReplies, highlight, highlightPinnedOrSaved = true, highlightReplyBar, appsEnabled, canDelete, currentUser, differentThreadSequence, filesCount, hasReplies, highlight, highlightPinnedOrSaved = true, highlightReplyBar,
isConsecutivePost, isEphemeral, isFirstReply, isSaved, isJumboEmoji, isLastReply, isPostAddChannelMember, isConsecutivePost, isEphemeral, isFirstReply, isSaved, isJumboEmoji, isLastReply, isPostAddChannelMember,
location, post, reactionsCount, shouldRenderReplyButton, skipSavedHeader, skipPinnedHeader, showAddReaction = true, style, location, post, reactionsCount, shouldRenderReplyButton, skipSavedHeader, skipPinnedHeader, showAddReaction = true, style,
testID, previousPost, offSetY, testID, previousPost,
}: PostProps) => { }: PostProps) => {
const pressDetected = useRef(false); const pressDetected = useRef(false);
const intl = useIntl(); const intl = useIntl();
@@ -167,7 +166,7 @@ const Post = ({
} }
Keyboard.dismiss(); Keyboard.dismiss();
const passProps = {location, post, showAddReaction, offSetY}; const passProps = {location, post, showAddReaction};
const title = isTablet ? intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}) : ''; const title = isTablet ? intl.formatMessage({id: 'post.options.title', defaultMessage: 'Options'}) : '';
if (isTablet) { if (isTablet) {

View File

@@ -19,16 +19,15 @@ type Props = {
location: typeof Screens[keyof typeof Screens]; location: typeof Screens[keyof typeof Screens];
post: PostModel; post: PostModel;
teamName: string; teamName: string;
offSetY: number;
} }
const CopyPermalinkOption = ({teamName, post, location, offSetY}: Props) => { const CopyPermalinkOption = ({teamName, post, location}: Props) => {
const serverUrl = useServerUrl(); const serverUrl = useServerUrl();
const handleCopyLink = useCallback(async () => { const handleCopyLink = useCallback(async () => {
const permalink = `${serverUrl}/${teamName}/pl/${post.id}`; const permalink = `${serverUrl}/${teamName}/pl/${post.id}`;
Clipboard.setString(permalink); Clipboard.setString(permalink);
await dismissBottomSheet(Screens.POST_OPTIONS); await dismissBottomSheet(Screens.POST_OPTIONS);
showSnackBar({barType: SNACK_BAR_TYPE.LINK_COPIED, location, offSetY}); showSnackBar({barType: SNACK_BAR_TYPE.LINK_COPIED, location});
}, [teamName, post.id]); }, [teamName, post.id]);
return ( return (

View File

@@ -15,13 +15,12 @@ import BaseOption from './base_option';
type Props = { type Props = {
location: typeof Screens[keyof typeof Screens]; location: typeof Screens[keyof typeof Screens];
postMessage: string; postMessage: string;
offSetY: number;
} }
const CopyTextOption = ({postMessage, location, offSetY}: Props) => { const CopyTextOption = ({postMessage, location}: Props) => {
const handleCopyText = useCallback(async () => { const handleCopyText = useCallback(async () => {
Clipboard.setString(postMessage); Clipboard.setString(postMessage);
await dismissBottomSheet(Screens.POST_OPTIONS); await dismissBottomSheet(Screens.POST_OPTIONS);
showSnackBar({barType: SNACK_BAR_TYPE.MESSAGE_COPIED, location, offSetY}); showSnackBar({barType: SNACK_BAR_TYPE.MESSAGE_COPIED, location});
}, [postMessage]); }, [postMessage]);
return ( return (

View File

@@ -37,14 +37,13 @@ type PostOptionsProps = {
post: PostModel; post: PostModel;
thread: Partial<PostModel>; thread: Partial<PostModel>;
componentId: string; componentId: string;
offSetY: number;
}; };
const PostOptions = ({ const PostOptions = ({
canAddReaction, canDelete, canEdit, canAddReaction, canDelete, canEdit,
canMarkAsUnread, canPin, canReply, canMarkAsUnread, canPin, canReply,
combinedPost, componentId, isSaved, combinedPost, componentId, isSaved,
location, post, thread, offSetY, location, post, thread,
}: PostOptionsProps) => { }: PostOptionsProps) => {
const managedConfig = useManagedConfig<ManagedConfig>(); const managedConfig = useManagedConfig<ManagedConfig>();
@@ -98,7 +97,6 @@ const PostOptions = ({
<CopyLinkOption <CopyLinkOption
post={post} post={post}
location={location} location={location}
offSetY={offSetY}
/>} />}
{!isSystemPost && {!isSystemPost &&
<SaveOption <SaveOption
@@ -110,7 +108,6 @@ const PostOptions = ({
<CopyTextOption <CopyTextOption
postMessage={post.message} postMessage={post.message}
location={location} location={location}
offSetY={offSetY}
/>} />}
{canPin && {canPin &&
<PinChannelOption <PinChannelOption

View File

@@ -8,7 +8,6 @@ type ShowSnackBarArgs = {
barType: keyof typeof SNACK_BAR_TYPE; barType: keyof typeof SNACK_BAR_TYPE;
onPress?: () => void; onPress?: () => void;
location?: typeof Screens[keyof typeof Screens]; location?: typeof Screens[keyof typeof Screens];
offSetY?: number;
}; };
export const showSnackBar = (passProps: ShowSnackBarArgs) => { export const showSnackBar = (passProps: ShowSnackBarArgs) => {
const screen = Screens.SNACK_BAR; const screen = Screens.SNACK_BAR;