Skip to content

Commit 1541f78

Browse files
authored
Merge pull request Expensify#67133 from allgandalf/fixtoggleProfileTool
Refactor `toggleProfileTool` to remove usage of `Onyx.Connect`
2 parents 7ba0f03 + 58b28b4 commit 1541f78

3 files changed

Lines changed: 4 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"test:debug": "TZ=utc NODE_OPTIONS='--inspect-brk --experimental-vm-modules' jest --runInBand",
4747
"perf-test": "NODE_OPTIONS=--experimental-vm-modules npx reassure",
4848
"typecheck": "NODE_OPTIONS=--max_old_space_size=8192 tsc",
49-
"lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=332 --cache --cache-location=node_modules/.cache/eslint",
49+
"lint": "NODE_OPTIONS=--max_old_space_size=8192 eslint . --max-warnings=331 --cache --cache-location=node_modules/.cache/eslint",
5050
"lint-changed": "NODE_OPTIONS=--max_old_space_size=8192 ./scripts/lintChanged.sh",
5151
"lint-watch": "npx eslint-watch --watch --changed",
5252
"shellcheck": "./scripts/shellCheck.sh",

src/components/RecordTroubleshootDataToolMenu/BaseRecordTroubleshootDataToolMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function BaseRecordTroubleshootDataToolMenu({
103103
} else {
104104
Performance.disableMonitoring();
105105
}
106-
toggleProfileTool();
106+
toggleProfileTool(isProfilingInProgress);
107107
return () => {
108108
Performance.disableMonitoring();
109109
};

src/libs/actions/ProfilingTool.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,12 @@ import Onyx from 'react-native-onyx';
33
import CONST from '@src/CONST';
44
import ONYXKEYS from '@src/ONYXKEYS';
55

6-
let isProfilingInProgress = false;
7-
Onyx.connect({
8-
key: ONYXKEYS.APP_PROFILING_IN_PROGRESS,
9-
callback: (val) => (isProfilingInProgress = val ?? false),
10-
});
11-
126
/**
137
* Toggle the test tools modal open or closed.
148
* Throttle the toggle to make the modal stay open if you accidentally tap an extra time, which is easy to do.
159
*/
16-
function toggleProfileTool() {
17-
const toggle = () => Onyx.set(ONYXKEYS.APP_PROFILING_IN_PROGRESS, !isProfilingInProgress);
10+
function toggleProfileTool(isProfilingInProgress = false) {
11+
const toggle = () => Onyx.set(ONYXKEYS.APP_PROFILING_IN_PROGRESS, isProfilingInProgress);
1812
const throttledToggle = throttle(toggle, CONST.TIMING.TEST_TOOLS_MODAL_THROTTLE_TIME);
1913
throttledToggle();
2014
}

0 commit comments

Comments
 (0)