react-native-in-app-debugger 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Api/index.jsx CHANGED
@@ -279,7 +279,11 @@ export default (props) => {
279
279
  </TouchableOpacity>
280
280
  {item.interface === "axios" && (
281
281
  <TouchableOpacity
282
- onPress={() => props.goToMock(item)}
282
+ onPress={() => {
283
+ props.goToMock(
284
+ item.mockid ? { ...item, id: item.mockid } : item
285
+ );
286
+ }}
283
287
  style={styles.actionButton}
284
288
  >
285
289
  <Text style={{ color: "black", fontSize: 10 }}>Mock</Text>
@@ -54,7 +54,7 @@ export default ({ maxNumOfApiToStore, blacklists, blacklistRef, mocks }) => {
54
54
  };
55
55
  setApis((v) => {
56
56
  const newData = [
57
- { request, id: Date.now().toString(36) + Math.random().toString(36), mockid: !!data.mockid, interface: data.interface },
57
+ { request, id: Date.now().toString(36) + Math.random().toString(36), mockid: data.mockid, interface: data.interface },
58
58
  ...(maxNumOfApiToStore ? v.slice(0, maxNumOfApiToStore - 1) : v),
59
59
  ];
60
60
  return newData;
@@ -1,5 +1,5 @@
1
- import React, { use, useEffect, useState } from 'react';
2
- import { FlatList, View, StyleSheet, TextInput, TouchableHighlight, TouchableOpacity, Alert } from 'react-native';
1
+ import { useEffect, useState } from 'react';
2
+ import { Alert, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
3
3
  import Text from '../Text';
4
4
  import X from '../X';
5
5
 
@@ -54,11 +54,18 @@ export default (p) => {
54
54
  cb?.();
55
55
  }
56
56
  };
57
+ const hasResponse = !!p.mockDetails.response
58
+
57
59
  const reset = () => {
58
60
  if (!p.mockDetails) return;
59
61
  setTmpMockDetails(JSON.stringify(p.mockDetails, removeId, 4));
60
- setTmpResBody(JSON.stringify(p.mockDetails.response.data, removeId, 4));
61
- setTmpResStatus(p.mockDetails.response.status + '' || '');
62
+ if (hasResponse) {
63
+ setTmpResBody(JSON.stringify(p.mockDetails.response.data, removeId, 4));
64
+ setTmpResStatus(p.mockDetails.response.status + '' || '');
65
+ } else {
66
+ setTmpResBody('');
67
+ setTmpResStatus('');
68
+ }
62
69
  };
63
70
  useEffect(reset, [p.mockDetails]);
64
71
  // const [canReset, setCanReset] = useState(false);
@@ -84,13 +91,13 @@ export default (p) => {
84
91
  // }, [p.mockDetails, tmpMockDetails]);
85
92
  if (!p.mockDetails) return null;
86
93
  // const canReset = JSON.stringify(p.mockDetails, removeId)?.replace(/\s+/g, '') !== tmpMockDetails?.replace?.(/\s+/g, '');
87
- const canReset =
94
+ const canReset = !hasResponse ||
88
95
  tmpResStatus != p.mockDetails.response.status ||
89
96
  JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, '') !== tmpResBody?.replace?.(/\s+/g, '');
90
97
  const isnew = !p.mocks.some((m) => m.id === p.mockDetails.id);
91
98
 
92
- console.log('xxxxx response', JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, ''));
93
- console.log('xxxxx tmpResBody', tmpResBody?.replace?.(/\s+/g, ''));
99
+ // console.log('xxxxx response', JSON.stringify(p.mockDetails.response.data)?.replace(/\s+/g, ''));
100
+ // console.log('xxxxx tmpResBody', tmpResBody?.replace?.(/\s+/g, ''));
94
101
 
95
102
  return (
96
103
  <View
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-in-app-debugger",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "This library's main usage is to be used by Non-Technical testers during UAT, SIT or any testing phase.",
5
5
  "main": "index.jsx",
6
6
  "scripts": {