Skip to content

Commit

Permalink
Merge pull request Expensify#38607 from tienifr/fix/38155
Browse files Browse the repository at this point in the history
Fix: Debug console always scrolls to new data position
  • Loading branch information
puneetlath authored Mar 27, 2024
2 parents b2ab3a9 + a3db9bd commit 9dbec73
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/pages/settings/AboutPage/ConsolePage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import {format} from 'date-fns';
import isEmpty from 'lodash/isEmpty';
import React, {useCallback, useEffect, useMemo, useState} from 'react';
import {FlatList, View} from 'react-native';
import {View} from 'react-native';
import type {ListRenderItem, ListRenderItemInfo} from 'react-native';
import {withOnyx} from 'react-native-onyx';
import type {OnyxEntry} from 'react-native-onyx';
import Button from '@components/Button';
import ConfirmModal from '@components/ConfirmModal';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import * as Expensicons from '@components/Icon/Expensicons';
import InvertedFlatList from '@components/InvertedFlatList';
import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import TextInput from '@components/TextInput';
Expand Down Expand Up @@ -69,7 +70,13 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
const {translate} = useLocalize();
const styles = useThemeStyles();

const logsList = useMemo(() => (logs ? Object.values(logs).reverse() : []), [logs]);
const logsList = useMemo(
() =>
Object.entries(logs ?? {})
.map(([key, value]) => ({key, ...value}))
.reverse(),
[logs],
);

useEffect(() => {
if (!shouldStoreLogs) {
Expand Down Expand Up @@ -136,11 +143,10 @@ function ConsolePage({capturedLogs, shouldStoreLogs}: ConsolePageProps) {
onBackButtonPress={() => Navigation.goBack(ROUTES.SETTINGS_TROUBLESHOOT)}
/>
<View style={[styles.border, styles.highlightBG, styles.borderNone, styles.mh5, styles.flex1]}>
<FlatList
<InvertedFlatList
data={logsList}
renderItem={renderItem}
contentContainerStyle={styles.p5}
inverted
ListEmptyComponent={<Text>{translate('initialSettingsPage.debugConsole.noLogsAvailable')}</Text>}
/>
</View>
Expand Down

0 comments on commit 9dbec73

Please sign in to comment.