Skip to content

Commit

Permalink
Merge pull request #114 from manojVivek/browser-extension
Browse files Browse the repository at this point in the history
Browser extension, app support #78
  • Loading branch information
manojVivek authored May 25, 2020
2 parents 1f4a9c2 + d739dd3 commit d464c17
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions desktop-app/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/entitlements.mac.plist
39 changes: 39 additions & 0 deletions desktop-app/app/main.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import installExtension, {
REDUX_DEVTOOLS,
} from 'electron-devtools-installer';
import devtron from 'devtron';
import fs from 'fs';

const path = require('path');

Expand All @@ -41,6 +42,7 @@ export default class AppUpdater {
}

let mainWindow = null;
let urlToOpen = null;

let httpAuthCallbacks = {};

Expand All @@ -67,11 +69,44 @@ const installExtensions = async () => {
}
};

const openUrl = url => {
mainWindow.webContents.send(
'address-change',
url.replace('responsively://', '')
);
mainWindow.show();
};

/**
* Add event listeners...
*/

app.on('will-finish-launching', () => {
if (['win32', 'darwin'].includes(process.platform)) {
if (process.argv.length >= 2) {
app.setAsDefaultProtocolClient('responsively', process.execPath, [
path.resolve(process.argv[1]),
]);
} else {
app.setAsDefaultProtocolClient('responsively');
}
}
});

app.on('open-url', async (event, url) => {
log.info('Open-url', url);
if (mainWindow) {
openUrl(url);
} else {
urlToOpen = url;
}
});

app.on('window-all-closed', () => {
if (process.env.NODE_ENV === 'development') {
['win32', 'darwin'].includes(process.platform) &&
app.removeAsDefaultProtocolClient('responsively');
}
// Respect the OSX convention of having the application in memory even
// after all windows have been closed
if (process.platform !== 'darwin') {
Expand Down Expand Up @@ -144,6 +179,10 @@ const createWindow = async () => {
});

mainWindow.once('ready-to-show', () => {
if (urlToOpen) {
openUrl(urlToOpen);
urlToOpen = null;
}
mainWindow.show();
});

Expand Down
10 changes: 10 additions & 0 deletions desktop-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@
"category": "public.app-category.developer-tools",
"entitlements": "build/entitlements.mac.plist",
"entitlementsInherit": "build/entitlements.mac.plist",
"extendInfo": {
"CFBundleURLTypes": [
{
"CFBundleURLSchemes": [
"responsively"
],
"CFBundleURLName": "app.responsively"
}
]
},
"icon": "resources/icon.icns",
"target": [
"dmg"
Expand Down

0 comments on commit d464c17

Please sign in to comment.