This commit is contained in:
Diego Mello 2022-09-19 18:09:30 -03:00
parent 86d5529cfd
commit 6bb7db9993
4 changed files with 8 additions and 16 deletions

View File

@ -5,15 +5,11 @@ import { FlatListProps, StyleSheet } from 'react-native';
import { FlashList } from '@shopify/flash-list'; import { FlashList } from '@shopify/flash-list';
import Animated from 'react-native-reanimated'; import Animated from 'react-native-reanimated';
import { isIOS } from '../../../lib/methods/helpers';
import scrollPersistTaps from '../../../lib/methods/helpers/scrollPersistTaps'; import scrollPersistTaps from '../../../lib/methods/helpers/scrollPersistTaps';
const AnimatedFlatList = Animated.createAnimatedComponent(FlashList); const AnimatedFlatList = Animated.createAnimatedComponent(FlashList);
const styles = StyleSheet.create({ const styles = StyleSheet.create({
list: {
flex: 1
},
contentContainer: { contentContainer: {
paddingTop: 10 paddingTop: 10
} }
@ -23,11 +19,13 @@ const styles = StyleSheet.create({
export type IListProps = FlatListProps<any>; export type IListProps = FlatListProps<any>;
// @ts-ignore
const List = ({ listRef, ...props }: IListProps) => ( const List = ({ listRef, ...props }: IListProps) => (
<AnimatedFlatList <AnimatedFlatList
testID='room-view-messages' testID='room-view-messages'
ref={listRef} ref={listRef}
keyExtractor={(item: any) => item.id} keyExtractor={(item: any) => item.id}
// @ts-ignore
contentContainerStyle={styles.contentContainer} contentContainerStyle={styles.contentContainer}
// style={styles.list} // style={styles.list}
inverted inverted

View File

@ -15,6 +15,7 @@ import { compareServerVersion, debounce } from '../../../lib/methods/helpers';
import { animateNextTransition } from '../../../lib/methods/helpers/layoutAnimation'; import { animateNextTransition } from '../../../lib/methods/helpers/layoutAnimation';
import log from '../../../lib/methods/helpers/log'; import log from '../../../lib/methods/helpers/log';
import EmptyRoom from '../EmptyRoom'; import EmptyRoom from '../EmptyRoom';
// @ts-ignore
import List, { IListProps, TListRef } from './List'; import List, { IListProps, TListRef } from './List';
import NavBottomFAB from './NavBottomFAB'; import NavBottomFAB from './NavBottomFAB';
import { loadMissedMessages, loadThreadMessages } from '../../../lib/methods'; import { loadMissedMessages, loadThreadMessages } from '../../../lib/methods';

View File

@ -78,7 +78,7 @@ import {
ICustomEmojis ICustomEmojis
} from '../../definitions'; } from '../../definitions';
import { E2E_MESSAGE_TYPE, E2E_STATUS, MESSAGE_TYPE_ANY_LOAD, MessageTypeLoad, themes } from '../../lib/constants'; import { E2E_MESSAGE_TYPE, E2E_STATUS, MESSAGE_TYPE_ANY_LOAD, MessageTypeLoad, themes } from '../../lib/constants';
import { TListRef } from './List/List'; // import { TListRef } from './List/List';
import { ModalStackParamList } from '../../stacks/MasterDetailStack/types'; import { ModalStackParamList } from '../../stacks/MasterDetailStack/types';
import { import {
callJitsi, callJitsi,
@ -215,7 +215,7 @@ class RoomView extends React.Component<IRoomViewProps, IRoomViewState> {
private messagebox: React.RefObject<MessageBoxType>; private messagebox: React.RefObject<MessageBoxType>;
private list: React.RefObject<ListContainerType>; private list: React.RefObject<ListContainerType>;
private joinCode: React.RefObject<IJoinCode>; private joinCode: React.RefObject<IJoinCode>;
private flatList: TListRef; private flatList: any;
private mounted: boolean; private mounted: boolean;
private offset = 0; private offset = 0;
private subObserveQuery?: Subscription; private subObserveQuery?: Subscription;

View File

@ -62,7 +62,6 @@ import {
hasPermission, hasPermission,
isRead, isRead,
debounce, debounce,
isIOS,
isTablet isTablet
} from '../../lib/methods/helpers'; } from '../../lib/methods/helpers';
import { E2E_BANNER_TYPE, DisplayMode, SortBy, MAX_SIDEBAR_WIDTH, themes } from '../../lib/constants'; import { E2E_BANNER_TYPE, DisplayMode, SortBy, MAX_SIDEBAR_WIDTH, themes } from '../../lib/constants';
@ -118,7 +117,6 @@ interface IRoomItem extends ISubscription {
outside?: boolean; outside?: boolean;
} }
const INITIAL_NUM_TO_RENDER = isTablet ? 20 : 12;
const CHATS_HEADER = 'Chats'; const CHATS_HEADER = 'Chats';
const UNREAD_HEADER = 'Unread'; const UNREAD_HEADER = 'Unread';
const FAVORITES_HEADER = 'Favorites'; const FAVORITES_HEADER = 'Favorites';
@ -159,11 +157,6 @@ const sortPreferencesShouldUpdate = ['sortBy', 'groupByType', 'showFavorites', '
const displayPropsShouldUpdate = ['showAvatar', 'displayMode']; const displayPropsShouldUpdate = ['showAvatar', 'displayMode'];
const getItemLayout = (data: ISubscription[] | null | undefined, index: number, height: number) => ({
length: height,
offset: height * index,
index
});
const keyExtractor = (item: ISubscription) => item.rid; const keyExtractor = (item: ISubscription) => item.rid;
class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewState> { class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewState> {
@ -176,7 +169,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
private shouldUpdate?: boolean; private shouldUpdate?: boolean;
private backHandler?: NativeEventSubscription; private backHandler?: NativeEventSubscription;
private querySubscription?: Subscription; private querySubscription?: Subscription;
private scroll?: FlatList; private scroll?: any;
private useRealName?: boolean; private useRealName?: boolean;
constructor(props: IRoomsListViewProps) { constructor(props: IRoomsListViewProps) {
@ -897,7 +890,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
} }
}; };
getScrollRef = (ref: FlatList) => (this.scroll = ref); getScrollRef = (ref: any) => (this.scroll = ref);
renderListHeader = () => { renderListHeader = () => {
const { searching } = this.state; const { searching } = this.state;
@ -1012,7 +1005,7 @@ class RoomsListView extends React.Component<IRoomsListViewProps, IRoomsListViewS
render = () => { render = () => {
console.count(`${this.constructor.name}.render calls`); console.count(`${this.constructor.name}.render calls`);
const { loading, chats, search, searching } = this.state; const { chats, search, searching } = this.state;
const { showServerDropdown, theme, navigation, displayMode, refreshing } = this.props; const { showServerDropdown, theme, navigation, displayMode, refreshing } = this.props;
const height = displayMode === DisplayMode.Condensed ? ROW_HEIGHT_CONDENSED : ROW_HEIGHT; const height = displayMode === DisplayMode.Condensed ? ROW_HEIGHT_CONDENSED : ROW_HEIGHT;