Skip to content

Commit

Permalink
Display iOS patterns when iOS device is used
Browse files Browse the repository at this point in the history
Summary:
Previously url's were displayed only for the Android app even if the user was using the iOS app.

This commit displays the url's for the iOS app if the user is using the iOS app.

Reviewed By: danielbuechele

Differential Revision: D17318175

fbshipit-source-id: 3bd8be4de55ea5b3ce634c2c6b713cba14ffcccd
  • Loading branch information
bnelo12 authored and facebook-github-bot committed Sep 12, 2019
1 parent 99b4436 commit 99cfc14
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
13 changes: 10 additions & 3 deletions src/plugins/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ import {
} from './util/autoCompleteProvider';
import {getAppMatchPatterns} from './util/appMatchPatterns';
import {getRequiredParameters, filterOptionalParameters} from './util/uri';
import {State, PersistedState, Bookmark, NavigationEvent} from './types';
import {
State,
PersistedState,
Bookmark,
NavigationEvent,
AppMatchPattern,
} from './types';
import React from 'react';

export default class extends FlipperPlugin<State, any, PersistedState> {
Expand Down Expand Up @@ -97,8 +103,9 @@ export default class extends FlipperPlugin<State, any, PersistedState> {
componentDidMount = () => {
const {selectedApp} = this.props;
this.subscribeToNavigationEvents();
getAppMatchPatterns(selectedApp)
.then(patterns => {
this.getDevice()
.then(device => getAppMatchPatterns(selectedApp, device))
.then((patterns: Array<AppMatchPattern>) => {
this.props.setPersistedState({
appMatchPatterns: patterns,
appMatchPatternsProvider: appMatchPatternsToAutoCompleteProvider(
Expand Down
20 changes: 14 additions & 6 deletions src/plugins/navigation/util/appMatchPatterns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import fs from 'fs';
import path from 'path';

import {BaseDevice, AndroidDevice, IOSDevice} from 'flipper';
import {AppMatchPattern} from '../types';

const extractAppNameFromSelectedApp = (selectedApp: string | null) => {
Expand All @@ -18,14 +18,22 @@ const extractAppNameFromSelectedApp = (selectedApp: string | null) => {
}
};

export const getAppMatchPatterns = (selectedApp: string | null) => {
export const getAppMatchPatterns = (
selectedApp: string | null,
device: BaseDevice,
) => {
return new Promise<Array<AppMatchPattern>>((resolve, reject) => {
const appName = extractAppNameFromSelectedApp(selectedApp);
if (appName === 'Facebook') {
const patternsPath = path.join(
'facebook',
'facebook-match-patterns.json',
);
let filename: string;
if (device instanceof AndroidDevice) {
filename = 'facebook-match-patterns-android.json';
} else if (device instanceof IOSDevice) {
filename = 'facebook-match-patterns-ios.json';
} else {
return;
}
const patternsPath = path.join('facebook', filename);
fs.readFile(patternsPath, (err, data) => {
if (err) {
reject(err);
Expand Down

0 comments on commit 99cfc14

Please sign in to comment.