diff --git a/src/plugins/navigation/index.tsx b/src/plugins/navigation/index.tsx index 15390e65a..99c36969b 100644 --- a/src/plugins/navigation/index.tsx +++ b/src/plugins/navigation/index.tsx @@ -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 { @@ -97,8 +103,9 @@ export default class extends FlipperPlugin { componentDidMount = () => { const {selectedApp} = this.props; this.subscribeToNavigationEvents(); - getAppMatchPatterns(selectedApp) - .then(patterns => { + this.getDevice() + .then(device => getAppMatchPatterns(selectedApp, device)) + .then((patterns: Array) => { this.props.setPersistedState({ appMatchPatterns: patterns, appMatchPatternsProvider: appMatchPatternsToAutoCompleteProvider( diff --git a/src/plugins/navigation/util/appMatchPatterns.tsx b/src/plugins/navigation/util/appMatchPatterns.tsx index 81f4f0f08..10b496557 100644 --- a/src/plugins/navigation/util/appMatchPatterns.tsx +++ b/src/plugins/navigation/util/appMatchPatterns.tsx @@ -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>((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);