diff --git a/package.json b/package.json index e84751a1d..4b0597b7a 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,15 @@ "win": { "publisherName": "Facebook, Inc." }, - "asar": false + "asar": false, + "fileAssociations": [ + { + "ext": [".flipper"], + "name": "Flipper Data", + "role": "Viewer", + "icon": "document-icons/document.icns" + } + ] }, "resolutions": { "@jest-runner/electron/electron": "3.0.0" diff --git a/src/MenuBar.js b/src/MenuBar.js index d3e5c70a3..2f1b3d47d 100644 --- a/src/MenuBar.js +++ b/src/MenuBar.js @@ -326,7 +326,7 @@ function getTemplate( null, { title: 'FlipperExport', - defaultPath: path.join(os.homedir(), 'FlipperExport.json'), + defaultPath: path.join(os.homedir(), 'FlipperExport.flipper'), }, file => { exportStoreToFile(file, store); diff --git a/src/dispatcher/application.js b/src/dispatcher/application.js index 98d4e9055..74451c343 100644 --- a/src/dispatcher/application.js +++ b/src/dispatcher/application.js @@ -9,7 +9,7 @@ import {remote, ipcRenderer} from 'electron'; import type {Store} from '../reducers/index.js'; import type Logger from '../fb-stubs/Logger.js'; import {parseFlipperPorts} from '../utils/environmentVariables'; - +import {importFileToStore} from '../utils/exportData'; import {selectPlugin, userPreferredPlugin} from '../reducers/connections'; export const uriComponents = (url: string) => { if (!url) { @@ -55,6 +55,11 @@ export default (store: Store, logger: Logger) => { ); } }); + + ipcRenderer.on('open-flipper-file', (event, url) => { + importFileToStore(url, store); + }); + ipcRenderer.on('flipper-deeplink-preferred-plugin', (event, url) => { // flipper://// const match = uriComponents(url); diff --git a/static/document-icons/document.icns b/static/document-icons/document.icns new file mode 100644 index 000000000..e4fe7ff3a Binary files /dev/null and b/static/document-icons/document.icns differ diff --git a/static/document-icons/document.ico b/static/document-icons/document.ico new file mode 100644 index 000000000..93d699c89 Binary files /dev/null and b/static/document-icons/document.ico differ diff --git a/static/document-icons/document.png b/static/document-icons/document.png new file mode 100644 index 000000000..b2089aa7e Binary files /dev/null and b/static/document-icons/document.png differ diff --git a/static/index.js b/static/index.js index ee281e6d1..b867dba45 100644 --- a/static/index.js +++ b/static/index.js @@ -66,6 +66,7 @@ let win; let appReady = false; let pluginsCompiled = false; let deeplinkURL = null; +let filePath = null; // tracking setInterval(() => { @@ -122,6 +123,15 @@ app.on('will-finish-launching', () => { win.webContents.send('flipper-deeplink', deeplinkURL); } }); + app.on('open-file', (event, path) => { + // When flipper app is running, and someone double clicks the import file, `componentDidMount` will not be called again and windows object will exist in that case. That's why calling `win.webContents.send('open-flipper-file', filePath);` again. + event.preventDefault(); + filePath = path; + if (win) { + win.webContents.send('open-flipper-file', filePath); + filePath = null; + } + }); }); app.on('ready', function() { @@ -145,6 +155,11 @@ ipcMain.on('componentDidMount', event => { win.webContents.send('flipper-deeplink-preferred-plugin', deeplinkURL); deeplinkURL = null; } + if (filePath) { + // When flipper app is not running, the windows object might not exist in the callback of `open-file`, but after ``componentDidMount` it will definitely exist. + win.webContents.send('open-flipper-file', filePath); + filePath = null; + } }); ipcMain.on('getLaunchTime', event => {