typing the listRef as a flatList and removing the `.getNode()`
This commit is contained in:
parent
2ca5a06c5e
commit
5622d1b25d
|
@ -19,6 +19,7 @@ const styles = StyleSheet.create({
|
|||
|
||||
interface IRoomListProps extends FlatListProps<IRoomItem> {
|
||||
listRef: React.Ref<FlatList>;
|
||||
// listRef: React.MutableRefObject<AnimatedComponent<typeof FlatList>>;
|
||||
}
|
||||
|
||||
const List = ({ listRef, ...props }: IRoomListProps): JSX.Element => (
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import React from 'react';
|
||||
import { RefreshControl } from 'react-native';
|
||||
import { FlatList, RefreshControl } from 'react-native';
|
||||
import { Q } from '@nozbe/watermelondb';
|
||||
import moment from 'moment';
|
||||
import { dequal } from 'dequal';
|
||||
|
@ -42,7 +42,7 @@ interface IRoomListContainerProps {
|
|||
tmid?: string;
|
||||
theme: string;
|
||||
loading: boolean;
|
||||
listRef: any;
|
||||
listRef: React.RefObject<FlatList>;
|
||||
hideSystemMessages: any[];
|
||||
tunread: [];
|
||||
ignored: [];
|
||||
|
@ -273,7 +273,7 @@ class ListContainer extends React.Component<IRoomListContainerProps, any> {
|
|||
|
||||
handleScrollToIndexFailed = (params: { highestMeasuredFrameIndex: number }) => {
|
||||
const { listRef } = this.props;
|
||||
listRef.current.getNode().scrollToIndex({ index: params.highestMeasuredFrameIndex, animated: false });
|
||||
listRef.current?.scrollToIndex({ index: params.highestMeasuredFrameIndex, animated: false });
|
||||
};
|
||||
|
||||
jumpToMessage = (messageId: string): Promise<void> =>
|
||||
|
@ -283,7 +283,7 @@ class ListContainer extends React.Component<IRoomListContainerProps, any> {
|
|||
const { listRef } = this.props;
|
||||
const index = messages.findIndex((item: { id: string }) => item.id === messageId);
|
||||
if (index > -1) {
|
||||
listRef.current.getNode().scrollToIndex({ index, viewPosition: 0.5, viewOffset: 100 });
|
||||
listRef.current?.scrollToIndex({ index, viewPosition: 0.5, viewOffset: 100 });
|
||||
await new Promise(res => setTimeout(res, 300));
|
||||
if (!this.viewableItems.map((vi: { key: string }) => vi.key).includes(messageId)) {
|
||||
if (!this.jumping) {
|
||||
|
@ -299,7 +299,7 @@ class ListContainer extends React.Component<IRoomListContainerProps, any> {
|
|||
}, 10000);
|
||||
await setTimeout(() => resolve(), 300);
|
||||
} else {
|
||||
listRef.current.getNode().scrollToIndex({ index: messages.length - 1, animated: false });
|
||||
listRef.current?.scrollToIndex({ index: messages.length - 1, animated: false });
|
||||
if (!this.jumping) {
|
||||
return resolve();
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ class ListContainer extends React.Component<IRoomListContainerProps, any> {
|
|||
|
||||
jumpToBottom = () => {
|
||||
const { listRef } = this.props;
|
||||
listRef.current.getNode().scrollToOffset({ offset: -100 });
|
||||
listRef.current?.scrollToOffset({ offset: -100 });
|
||||
};
|
||||
|
||||
renderFooter = () => {
|
||||
|
|
Loading…
Reference in New Issue