Display iOS patterns when iOS device is used
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
This commit is contained in:
committed by
Facebook Github Bot
parent
99b4436ceb
commit
99cfc14134
@@ -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> {
|
||||
@@ -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(
|
||||
|
||||
@@ -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) => {
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user