Make dispatcher/application.tsx strict

Summary: _typescript_

Reviewed By: jknoxville

Differential Revision: D17258139

fbshipit-source-id: d1ab484e981b2802a22c2fc92ac52c75970ee3d2
This commit is contained in:
Pascal Hartig
2019-09-09 09:56:45 -07:00
committed by Facebook Github Bot
parent 962bd03785
commit c506cc57b1

View File

@@ -51,39 +51,42 @@ export default (store: Store, logger: Logger) => {
}); });
}); });
ipcRenderer.on('flipper-protocol-handler', (event, query: string) => { ipcRenderer.on(
if (query.startsWith('flipper://import')) { 'flipper-protocol-handler',
const {search} = new URL(query); (_event: string, query: string) => {
const {url} = qs.parse(search); if (query.startsWith('flipper://import')) {
store.dispatch(toggleAction('downloadingImportData', true)); const {search} = new URL(query);
return ( const {url} = qs.parse(search);
typeof url === 'string' && store.dispatch(toggleAction('downloadingImportData', true));
fetch(url) return (
.then(res => res.text()) typeof url === 'string' &&
.then(data => importDataToStore(data, store)) fetch(url)
.then(() => { .then(res => res.text())
store.dispatch(toggleAction('downloadingImportData', false)); .then(data => importDataToStore(data, store))
}) .then(() => {
.catch((e: Error) => { store.dispatch(toggleAction('downloadingImportData', false));
console.error(e); })
store.dispatch(toggleAction('downloadingImportData', false)); .catch((e: Error) => {
}) console.error(e);
); store.dispatch(toggleAction('downloadingImportData', false));
} })
const match = uriComponents(query); );
if (match.length > 1) { }
// flipper://<client>/<pluginId>/<payload> const match = uriComponents(query);
return store.dispatch( if (match.length > 1) {
selectPlugin({ // flipper://<client>/<pluginId>/<payload>
selectedApp: match[0], return store.dispatch(
selectedPlugin: match[1], selectPlugin({
deepLinkPayload: match[2], selectedApp: match[0],
}), selectedPlugin: match[1],
); deepLinkPayload: match[2],
} }),
}); );
}
},
);
ipcRenderer.on('open-flipper-file', (event, url) => { ipcRenderer.on('open-flipper-file', (_event: string, url: string) => {
tryCatchReportPlatformFailures(() => { tryCatchReportPlatformFailures(() => {
return importFileToStore(url, store); return importFileToStore(url, store);
}, `${IMPORT_FLIPPER_TRACE_EVENT}:Deeplink`); }, `${IMPORT_FLIPPER_TRACE_EVENT}:Deeplink`);