Skip to content

Commit

Permalink
Limit request length before scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbrazier committed Sep 24, 2024
1 parent 869f3aa commit a876f35
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
4 changes: 2 additions & 2 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export default function App() {
formData.append('test', 'hello');
const makeRequest = () => {
fetch(
'https://postman-echo.com/post?query=some really long query that goes onto multiple lines so we can test what happens',
`https://postman-echo.com/post?query=${'some really long query that goes onto multiple lines so we can test what happens'.repeat(5)}`,
{
method: 'POST',
body: JSON.stringify({ test: 'hello' }),
}
},
);
fetch('https://postman-echo.com/post?formData', {
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions src/components/RequestList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const RequestList: React.FC<Props> = ({
request={item}
onPress={() => onPressItem(item.id)}
compact={compact}
list
/>
)}
/>
Expand Down
25 changes: 21 additions & 4 deletions src/components/ResultItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import React from 'react';
import { View, TouchableOpacity, Text, StyleSheet } from 'react-native';
import {
View,
TouchableOpacity,
Text,
StyleSheet,
ScrollView,
} from 'react-native';
import { Theme, useThemedStyles, useTheme } from '../theme';
import { backHandlerSet } from '../backHandler';
import { NetworkRequestInfoRow } from '../types';
Expand All @@ -9,9 +15,16 @@ interface Props {
onPress?(): void;
style?: any;
compact?: boolean;
list?: boolean;
}

const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {
const ResultItem: React.FC<Props> = ({
style,
request,
onPress,
compact,
list,
}) => {
const styles = useThemedStyles(themedStyles);
const theme = useTheme();
const onDetailsPage = !onPress;
Expand Down Expand Up @@ -59,6 +72,8 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {

const gqlOperation = request.gqlOperation;

const UrlContainer = list ? View : ScrollView;

return (
<MaybeTouchable
style={[styles.container, style]}
Expand Down Expand Up @@ -93,8 +108,9 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {
)}
</View>
</View>
<View style={[styles.content]}>
<UrlContainer style={[styles.content]}>
<Text
numberOfLines={list ? 5 : undefined}
style={[
styles.text,
getUrlTextColor(request.status),
Expand All @@ -110,7 +126,7 @@ const ResultItem: React.FC<Props> = ({ style, request, onPress, compact }) => {
</Text>
</View>
)}
</View>
</UrlContainer>
</MaybeTouchable>
);
};
Expand Down Expand Up @@ -156,6 +172,7 @@ const themedStyles = (theme: Theme) =>
paddingRight: 5,
flexShrink: 1,
flex: 1,
maxHeight: 250,
},
method: {
fontSize: 18,
Expand Down

0 comments on commit a876f35

Please sign in to comment.