Skip to content

Commit

Permalink
Merge pull request #51659 from bernhardoj/fix/51653-pressing-debug-sh…
Browse files Browse the repository at this point in the history
…ortcut-again-close-and-reopen-the-modal

[CP Staging] Fix pressing debug shortcut again won't close the debug modal

(cherry picked from commit 25c8dc3)

(CP triggered by mountiny)
  • Loading branch information
mountiny authored and OSBotify committed Oct 30, 2024
1 parent 3398081 commit 12bd71d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libs/Navigation/AppNavigator/AuthScreens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ function AuthScreens({session, lastOpenedPublicRoomID, initialLastUpdateIDApplie

const unsubscribeDebugShortcut = KeyboardShortcut.subscribe(
debugShortcutConfig.shortcutKey,
() => Modal.close(toggleTestToolsModal),
() => toggleTestToolsModal(),
debugShortcutConfig.descriptionKey,
debugShortcutConfig.modifiers,
true,
Expand Down
12 changes: 11 additions & 1 deletion src/libs/actions/TestTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import throttle from 'lodash/throttle';
import Onyx from 'react-native-onyx';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import * as Modal from './Modal';

let isTestToolsModalOpen = false;
Onyx.connect({
Expand All @@ -14,7 +15,16 @@ Onyx.connect({
* Throttle the toggle to make the modal stay open if you accidentally tap an extra time, which is easy to do.
*/
function toggleTestToolsModal() {
const toggle = () => Onyx.set(ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN, !isTestToolsModalOpen);
const toggle = () => {
const toggleIsTestToolsModalOpen = () => {
Onyx.set(ONYXKEYS.IS_TEST_TOOLS_MODAL_OPEN, !isTestToolsModalOpen);
};
if (!isTestToolsModalOpen) {
Modal.close(toggleIsTestToolsModalOpen);
return;
}
toggleIsTestToolsModalOpen();
};
const throttledToggle = throttle(toggle, CONST.TIMING.TEST_TOOLS_MODAL_THROTTLE_TIME);
throttledToggle();
}
Expand Down

0 comments on commit 12bd71d

Please sign in to comment.