Skip to content

Commit

Permalink
remove platform specific code from about page
Browse files Browse the repository at this point in the history
  • Loading branch information
azimgd committed Apr 20, 2023
1 parent cbf030c commit 9e0932c
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import _ from 'underscore';
import getKeyEventModifiers from '../getKeyEventModifiers';

/**
* Checks if an event for that key is configured and if so, runs it.
* @param {Function} getDisplayName
* @param {Object} eventHandlers
* @param {Object} keycommandEvent
* @param {Event} event
* @private
*/
function bindHandlerToKeydownEvent(getDisplayName, eventHandlers, keycommandEvent, event) {
const eventModifiers = getKeyEventModifiers(keycommandEvent);
const displayName = getDisplayName(keycommandEvent.input, eventModifiers);

// Loop over all the callbacks
_.every(eventHandlers[displayName], (callback) => {
// Determine if the event should bubble before executing the callback (which may have side-effects)
let shouldBubble = callback.shouldBubble || false;
if (_.isFunction(callback.shouldBubble)) {
shouldBubble = callback.shouldBubble();
}

if (_.isFunction(callback.callback)) {
callback.callback(event);
}

// If the event should not bubble, short-circuit the loop
return shouldBubble;
});
}

export default bindHandlerToKeydownEvent;
10 changes: 6 additions & 4 deletions src/pages/settings/AboutPage/AboutPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@ import Logo from '../../../../assets/images/new-expensify.svg';
import pkg from '../../../../package.json';
import * as Report from '../../../libs/actions/Report';
import * as Link from '../../../libs/actions/Link';
import getPlatformSpecificMenuItems from './getPlatformSpecificMenuItems';
import compose from '../../../libs/compose';
import * as KeyboardShortcuts from '../../../libs/actions/KeyboardShortcuts';

const propTypes = {
...withLocalizePropTypes,
...windowDimensionsPropTypes,
};

const AboutPage = (props) => {
const platformSpecificMenuItems = getPlatformSpecificMenuItems(props.isSmallScreenWidth);

const menuItems = [
{
translationKey: 'initialSettingsPage.aboutPage.appDownloadLinks',
Expand All @@ -36,7 +34,11 @@ const AboutPage = (props) => {
Navigation.navigate(ROUTES.SETTINGS_APP_DOWNLOAD_LINKS);
},
},
...platformSpecificMenuItems,
{
translationKey: 'initialSettingsPage.aboutPage.viewKeyboardShortcuts',
icon: Expensicons.Keyboard,
action: KeyboardShortcuts.showKeyboardShortcutModal,
},
{
translationKey: 'initialSettingsPage.aboutPage.viewTheCode',
icon: Expensicons.Eye,
Expand Down
15 changes: 0 additions & 15 deletions src/pages/settings/AboutPage/getPlatformSpecificMenuItems/index.js

This file was deleted.

This file was deleted.

4 changes: 3 additions & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -2799,7 +2799,9 @@ const styles = {

keyboardShortcutModalContainer: {
maxHeight: '100%',
flex: '0 0 auto',
flexShrink: 0,
flexGrow: 0,
flexBasis: 'auto',
},

keyboardShortcutTableWrapper: {
Expand Down

0 comments on commit 9e0932c

Please sign in to comment.