minor tweaks

This commit is contained in:
AlexAlexandre 2021-12-14 23:56:25 -03:00
parent 63a3e91fd9
commit d29b661ccc
2 changed files with 11 additions and 11 deletions

View File

@ -1,6 +1,6 @@
import React, { useCallback, useState } from 'react'; import React, { useCallback, useState } from 'react';
import { StyleSheet, View } from 'react-native'; import { StyleSheet, View } from 'react-native';
import Animated, { call, cond, greaterOrEq, useCode } from 'react-native-reanimated'; import Animated, { call, cond, greaterOrEq, useCode, Value } from 'react-native-reanimated';
import { themes } from '../../../constants/colors'; import { themes } from '../../../constants/colors';
import { CustomIcon } from '../../../lib/Icons'; import { CustomIcon } from '../../../lib/Icons';
@ -30,7 +30,7 @@ const styles = StyleSheet.create({
}); });
interface IRoomNavBottomFAB { interface IRoomNavBottomFAB {
y: number; y: Value<number>;
onPress: Function; onPress: Function;
isThread: boolean; isThread: boolean;
} }

View File

@ -1,5 +1,5 @@
import React from 'react'; import React from 'react';
import { FlatList, RefreshControl } from 'react-native'; import { FlatList, NativeScrollEvent, NativeSyntheticEvent, RefreshControl, ViewToken } from 'react-native';
import { Q } from '@nozbe/watermelondb'; import { Q } from '@nozbe/watermelondb';
import moment from 'moment'; import moment from 'moment';
import { dequal } from 'dequal'; import { dequal } from 'dequal';
@ -25,7 +25,7 @@ import { IThread } from '../../../definitions/IThread';
const QUERY_SIZE = 50; const QUERY_SIZE = 50;
const onScroll = ({ y }: any) => const onScroll = ({ y }: { y: Value<number> }) =>
event( event(
[ [
{ {
@ -57,15 +57,15 @@ class ListContainer extends React.Component<IRoomListContainerProps, any> {
private mounted: boolean; private mounted: boolean;
private animated: boolean; private animated: boolean;
private jumping: boolean; private jumping: boolean;
private y: any; private y: Value<number>;
private onScroll: (...args: any[]) => void; private onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
private unsubscribeFocus: any; private unsubscribeFocus: () => void;
private viewabilityConfig: { itemVisiblePercentThreshold: number }; private viewabilityConfig: { itemVisiblePercentThreshold: number };
private highlightedMessageTimeout: any; private highlightedMessageTimeout?: ReturnType<typeof setTimeout> | false;
private thread?: IThread; private thread?: IThread;
private messagesObservable?: Observable<Model>; private messagesObservable?: Observable<Model>;
private messagesSubscription?: Subscription; private messagesSubscription?: Subscription;
private viewableItems: any; private viewableItems?: ViewToken[];
constructor(props: IRoomListContainerProps) { constructor(props: IRoomListContainerProps) {
super(props); super(props);
@ -286,7 +286,7 @@ class ListContainer extends React.Component<IRoomListContainerProps, any> {
if (index > -1) { if (index > -1) {
listRef.current?.scrollToIndex({ index, viewPosition: 0.5, viewOffset: 100 }); listRef.current?.scrollToIndex({ index, viewPosition: 0.5, viewOffset: 100 });
await new Promise(res => setTimeout(res, 300)); await new Promise(res => setTimeout(res, 300));
if (!this.viewableItems.map((vi: { key: string }) => vi.key).includes(messageId)) { if (!this.viewableItems?.map((vi: { key: string }) => vi.key).includes(messageId)) {
if (!this.jumping) { if (!this.jumping) {
return resolve(); return resolve();
} }
@ -332,7 +332,7 @@ class ListContainer extends React.Component<IRoomListContainerProps, any> {
return renderRow(item, messages[index + 1], highlightedMessage); return renderRow(item, messages[index + 1], highlightedMessage);
}; };
onViewableItemsChanged = ({ viewableItems }: any) => { onViewableItemsChanged = ({ viewableItems }: { viewableItems: ViewToken[] }) => {
this.viewableItems = viewableItems; this.viewableItems = viewableItems;
}; };