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

View File

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

View File

@@ -19,16 +19,15 @@ type Props = {
location: typeof Screens[keyof typeof Screens];
post: PostModel;
teamName: string;
offSetY: number;
}
const CopyPermalinkOption = ({teamName, post, location, offSetY}: Props) => {
const CopyPermalinkOption = ({teamName, post, location}: Props) => {
const serverUrl = useServerUrl();
const handleCopyLink = useCallback(async () => {
const permalink = `${serverUrl}/${teamName}/pl/${post.id}`;
Clipboard.setString(permalink);
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]);
return (

View File

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

View File

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

View File

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