@@ -15,7 +15,7 @@ import { sortByIp, sortByNumber } from "@/utils/sorter";
1515import { useState } from "react" ;
1616import { Button } from "react-native-paper" ;
1717import { getStoredJson , storeJson } from "@/storage/localStorage" ;
18- import { I18n } from "@/localize" ;
18+ import { AppI18n } from "@/localize" ;
1919
2020export const STORAGE_KEY_USER_SETTINGS =
2121 "STORAGE_KEY_TEST_STATISTICS_USER_CONFIG" ;
@@ -94,31 +94,30 @@ function StatisticsDataInternal(props: { rows: CfIpStatistics[] }) {
9494 }
9595
9696 const { sortType, columnId } = getCurrentSortConf ( ) ;
97- const [ isShowAllData , setIsShowAllData ] = useState < boolean > ( false ) ;
97+ const [ isShowAllData , setIsShowAllData ] = useState < boolean > ( false ) ;
98+
99+ const PERFORMANCE_LIMIT = 50 ;
98100
99- const PERFORMANCE_LIMIT = 50 ;
100-
101101 // todo fix the type infer later
102102 const sortedRows = sortTableData (
103103 props . rows ,
104104 columnId as `${TestStatisticsTableHeaderCol } `,
105105 sortType
106- ) . slice ( 0 , isShowAllData ? props . rows . length : PERFORMANCE_LIMIT ) ;
106+ ) . slice ( 0 , isShowAllData ? props . rows . length : PERFORMANCE_LIMIT ) ;
107107
108- const [ isShowAllHeader , setIsShowAllHeader ] = useState < boolean > ( false ) ;
108+ const [ isShowAllHeader , setIsShowAllHeader ] = useState < boolean > ( false ) ;
109109
110110 let filteredTableHeaders = getFilteredTableHeaders (
111111 tableHeaders ,
112112 isShowAllHeader
113113 ) ;
114114
115- getStoredJson < Record < string , any > > (
116- STORAGE_KEY_USER_SETTINGS ,
117- { }
118- ) . then ( ( { isShowAllHeader, isShowAllData } ) => {
119- setIsShowAllHeader ( ( ) => ! ! isShowAllHeader ) ;
120- setIsShowAllData ( ( ) => ! ! isShowAllData )
121- } ) ;
115+ getStoredJson < Record < string , any > > ( STORAGE_KEY_USER_SETTINGS , { } ) . then (
116+ ( { isShowAllHeader, isShowAllData } ) => {
117+ setIsShowAllHeader ( ( ) => ! ! isShowAllHeader ) ;
118+ setIsShowAllData ( ( ) => ! ! isShowAllData ) ;
119+ }
120+ ) ;
122121
123122 function onIsShowAllHeaderChange ( isShowAllHeader : boolean ) {
124123 setIsShowAllHeader ( ( isShowAllHeader ) => ! isShowAllHeader ) ;
@@ -128,7 +127,7 @@ function StatisticsDataInternal(props: { rows: CfIpStatistics[] }) {
128127 setIsShowAllData ( ( isShowAllData ) => ! isShowAllData ) ;
129128 storeJson ( STORAGE_KEY_USER_SETTINGS , { isShowAllData } ) ;
130129 }
131-
130+
132131 return (
133132 < View style = { styles . getStartedContainer } >
134133 < View
@@ -145,17 +144,17 @@ function StatisticsDataInternal(props: { rows: CfIpStatistics[] }) {
145144 onPress = { ( ) => onIsShowAllHeaderChange ( ! isShowAllHeader ) }
146145 >
147146 { isShowAllHeader
148- ? I18n . t ( "testStatistics.hideSomeColumns" )
149- : I18n . t ( "testStatistics.showAllColumns" ) }
147+ ? AppI18n . t ( "testStatistics.hideSomeColumns" )
148+ : AppI18n . t ( "testStatistics.showAllColumns" ) }
150149 </ Button >
151150 < Button
152151 mode = "contained"
153152 contentStyle = { { marginHorizontal : - 5 , marginVertical : - 2 } }
154153 onPress = { ( ) => onIsShowAllDataChange ( ! isShowAllData ) }
155154 >
156155 { isShowAllData
157- ? I18n . t ( "general.showSortedTop" ) + PERFORMANCE_LIMIT
158- : I18n . t ( "general.showAllData" ) }
156+ ? AppI18n . t ( "general.showSortedTop" ) + PERFORMANCE_LIMIT
157+ : AppI18n . t ( "general.showAllData" ) }
159158 </ Button >
160159 </ View >
161160
0 commit comments