Skip to content

Commit e423079

Browse files
authored
fix: Limit request length before scrolling for long requests (#108)
* Update dependencies * Limit request length before scrolling * Revert "Update dependencies" This reverts commit 869f3aa. * Fit lint
1 parent 3dd6c00 commit e423079

File tree

6 files changed

+36
-24
lines changed

6 files changed

+36
-24
lines changed

.prettierrc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"singleQuote": true
2+
"quoteProps": "consistent",
3+
"singleQuote": true,
4+
"tabWidth": 2,
5+
"trailingComma": "es5",
6+
"useTabs": false
37
}

example/src/App.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ export default function App() {
2222
formData.append('test', 'hello');
2323
const makeRequest = () => {
2424
fetch(
25-
'https://postman-echo.com/post?query=some really long query that goes onto multiple lines so we can test what happens',
25+
`https://postman-echo.com/post?query=${'some really long query that goes onto multiple lines so we can test what happens'.repeat(
26+
5
27+
)}`,
2628
{
2729
method: 'POST',
2830
body: JSON.stringify({ test: 'hello' }),

package.json

+3-15
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"scripts": {
3939
"test": "jest",
4040
"typescript": "tsc --noEmit",
41-
"lint": "eslint \"**/*.{js,ts,tsx}\"",
41+
"lint": "yarn eslint && yarn prettier",
42+
"eslint": "eslint \"**/*.{js,ts,tsx}\"",
4243
"prettier": "prettier --check '{,example/}src/**/*.{js,json,ts,tsx}' '{*,example/*}.{js,ts,tsx}'",
4344
"prepare": "bob build",
4445
"release": "release-it",
@@ -55,7 +56,6 @@
5556
"@types/react-native": "^0.72.0",
5657
"eslint": "^8.41.0",
5758
"eslint-config-prettier": "^8.8.0",
58-
"eslint-plugin-prettier": "^4.2.1",
5959
"husky": "^8.0.3",
6060
"jest": "^29.5.0",
6161
"prettier": "^2.8.8",
@@ -109,19 +109,7 @@
109109
"extends": [
110110
"@react-native-community",
111111
"prettier"
112-
],
113-
"rules": {
114-
"prettier/prettier": [
115-
"error",
116-
{
117-
"quoteProps": "consistent",
118-
"singleQuote": true,
119-
"tabWidth": 2,
120-
"trailingComma": "es5",
121-
"useTabs": false
122-
}
123-
]
124-
}
112+
]
125113
},
126114
"eslintIgnore": [
127115
"node_modules/",

src/components/RequestList.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ const RequestList: React.FC<Props> = ({
5656
request={item}
5757
onPress={() => onPressItem(item.id)}
5858
compact={compact}
59+
list
5960
/>
6061
)}
6162
/>

src/components/ResultItem.tsx

+21-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import React from 'react';
2-
import { View, TouchableOpacity, Text, StyleSheet } from 'react-native';
2+
import {
3+
View,
4+
TouchableOpacity,
5+
Text,
6+
StyleSheet,
7+
ScrollView,
8+
} from 'react-native';
39
import { Theme, useThemedStyles, useTheme } from '../theme';
410
import { backHandlerSet } from '../backHandler';
511
import { NetworkRequestInfoRow } from '../types';
@@ -9,9 +15,16 @@ interface Props {
915
onPress?(): void;
1016
style?: any;
1117
compact?: boolean;
18+
list?: boolean;
1219
}
1320

14-
const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {
21+
const ResultItem: React.FC<Props> = ({
22+
style,
23+
request,
24+
onPress,
25+
compact,
26+
list,
27+
}) => {
1528
const styles = useThemedStyles(themedStyles);
1629
const theme = useTheme();
1730
const onDetailsPage = !onPress;
@@ -59,6 +72,8 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {
5972

6073
const gqlOperation = request.gqlOperation;
6174

75+
const UrlContainer = list ? View : ScrollView;
76+
6277
return (
6378
<MaybeTouchable
6479
style={[styles.container, style]}
@@ -93,8 +108,9 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {
93108
)}
94109
</View>
95110
</View>
96-
<View style={[styles.content]}>
111+
<UrlContainer style={[styles.content]}>
97112
<Text
113+
numberOfLines={list ? 5 : undefined}
98114
style={[
99115
styles.text,
100116
getUrlTextColor(request.status),
@@ -110,7 +126,7 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {
110126
</Text>
111127
</View>
112128
)}
113-
</View>
129+
</UrlContainer>
114130
</MaybeTouchable>
115131
);
116132
};
@@ -156,6 +172,7 @@ const themedStyles = (theme: Theme) =>
156172
paddingRight: 5,
157173
flexShrink: 1,
158174
flex: 1,
175+
maxHeight: 250,
159176
},
160177
method: {
161178
fontSize: 18,

yarn.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -2919,9 +2919,9 @@ camelcase@^7.0.1:
29192919
integrity sha512-xlx1yCK2Oc1APsPXDL2LdlNP6+uu8OCDdhOBSVT279M/S+y75O30C2VuD8T2ogdePBBl7PfPF4504tnLgX3zfw==
29202920

29212921
caniuse-lite@^1.0.30001449:
2922-
version "1.0.30001488"
2923-
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001488.tgz#d19d7b6e913afae3e98f023db97c19e9ddc5e91f"
2924-
integrity sha512-NORIQuuL4xGpIy6iCCQGN4iFjlBXtfKWIenlUuyZJumLRIindLb7wXM+GO8erEhb7vXfcnf4BAg2PrSDN5TNLQ==
2922+
version "1.0.30001663"
2923+
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001663.tgz"
2924+
integrity sha512-o9C3X27GLKbLeTYZ6HBOLU1tsAcBZsLis28wrVzddShCS16RujjHp9GDHKZqrB3meE0YjhawvMFsGb/igqiPzA==
29252925

29262926
chalk@5.3.0, chalk@^5.3.0:
29272927
version "5.3.0"

0 commit comments

Comments
 (0)