diff --git a/package-lock.json b/package-lock.json index 3da2485ba..3f151d1e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -102,7 +102,7 @@ "cross-env": "^5.0.5", "cz-conventional-changelog": "2.1.0", "dotenv": "^4.0.0", - "electron": "29.0.0", + "electron": "33.2.1", "electron-builder": "24.9.1", "electron-notarize": "1.0.0", "electron-rebuild": "3.2.9", @@ -131,7 +131,7 @@ "lerna": "^3.8.0", "mobx-react-devtools": "6.0.3", "mocha": "5.2.0", - "node-abi": "3.54.0", + "node-abi": "3.71.0", "prettier": "1.15.2", "react-intl-translations-manager": "5.0.3", "terser-webpack-plugin": "1.2.1", @@ -11878,9 +11878,9 @@ } }, "node_modules/electron": { - "version": "29.0.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-29.0.0.tgz", - "integrity": "sha512-HhrRC5vWb6fAbWXP3A6ABwKUO9JvYSC4E141RzWFgnDBqNiNtabfmgC8hsVeCR65RQA2MLSDgC8uP52I9zFllQ==", + "version": "33.2.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-33.2.1.tgz", + "integrity": "sha512-SG/nmSsK9Qg1p6wAW+ZfqU+AV8cmXMTIklUL18NnOKfZLlum4ZsDoVdmmmlL39ZmeCaq27dr7CgslRPahfoVJg==", "dev": true, "hasInstallScript": true, "dependencies": { @@ -13107,12 +13107,12 @@ } }, "node_modules/electron/node_modules/@types/node": { - "version": "20.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", - "integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", + "version": "20.17.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.9.tgz", + "integrity": "sha512-0JOXkRyLanfGPE2QRCwgxhzlBAvaRdCNMcvbd7jFfpmD4eEXll7LRwy5ymJmyeZqk7Nh7eD2LeUyQ68BbndmXw==", "dev": true, "dependencies": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } }, "node_modules/elliptic": { @@ -23830,9 +23830,9 @@ } }, "node_modules/node-abi": { - "version": "3.54.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.54.0.tgz", - "integrity": "sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA==", + "version": "3.71.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.71.0.tgz", + "integrity": "sha512-SZ40vRiy/+wRTf21hxkkEjPJZpARzUMVcJoQse2EF8qkUWbbO2z7vd5oA/H6bVH6SZQ5STGcu0KRDS7biNRfxw==", "dev": true, "dependencies": { "semver": "^7.3.5" @@ -26696,7 +26696,6 @@ }, "node_modules/npm/node_modules/lodash._baseindexof": { "version": "3.1.0", - "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -26711,19 +26710,16 @@ }, "node_modules/npm/node_modules/lodash._bindcallback": { "version": "3.0.1", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._cacheindexof": { "version": "3.0.2", - "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._createcache": { "version": "3.1.2", - "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26737,7 +26733,6 @@ }, "node_modules/npm/node_modules/lodash._getnative": { "version": "3.9.1", - "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -26753,7 +26748,6 @@ }, "node_modules/npm/node_modules/lodash.restparam": { "version": "3.6.1", - "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -34761,9 +34755,9 @@ "dev": true }, "node_modules/undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "dev": true }, "node_modules/unicode-canonical-property-names-ecmascript": { @@ -46200,9 +46194,9 @@ } }, "electron": { - "version": "29.0.0", - "resolved": "https://registry.npmjs.org/electron/-/electron-29.0.0.tgz", - "integrity": "sha512-HhrRC5vWb6fAbWXP3A6ABwKUO9JvYSC4E141RzWFgnDBqNiNtabfmgC8hsVeCR65RQA2MLSDgC8uP52I9zFllQ==", + "version": "33.2.1", + "resolved": "https://registry.npmjs.org/electron/-/electron-33.2.1.tgz", + "integrity": "sha512-SG/nmSsK9Qg1p6wAW+ZfqU+AV8cmXMTIklUL18NnOKfZLlum4ZsDoVdmmmlL39ZmeCaq27dr7CgslRPahfoVJg==", "dev": true, "requires": { "@electron/get": "^2.0.0", @@ -46211,12 +46205,12 @@ }, "dependencies": { "@types/node": { - "version": "20.11.19", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.19.tgz", - "integrity": "sha512-7xMnVEcZFu0DikYjWOlRq7NTPETrm7teqUT2WkQjrTIkEgUyyGdWsj/Zg8bEJt5TNklzbPD1X3fqfsHw3SpapQ==", + "version": "20.17.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.17.9.tgz", + "integrity": "sha512-0JOXkRyLanfGPE2QRCwgxhzlBAvaRdCNMcvbd7jFfpmD4eEXll7LRwy5ymJmyeZqk7Nh7eD2LeUyQ68BbndmXw==", "dev": true, "requires": { - "undici-types": "~5.26.4" + "undici-types": "~6.19.2" } } } @@ -55778,9 +55772,9 @@ } }, "node-abi": { - "version": "3.54.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.54.0.tgz", - "integrity": "sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA==", + "version": "3.71.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.71.0.tgz", + "integrity": "sha512-SZ40vRiy/+wRTf21hxkkEjPJZpARzUMVcJoQse2EF8qkUWbbO2z7vd5oA/H6bVH6SZQ5STGcu0KRDS7biNRfxw==", "dev": true, "requires": { "semver": "^7.3.5" @@ -57742,8 +57736,7 @@ }, "lodash._baseindexof": { "version": "3.1.0", - "bundled": true, - "extraneous": true + "bundled": true }, "lodash._baseuniq": { "version": "4.6.0", @@ -57755,18 +57748,15 @@ }, "lodash._bindcallback": { "version": "3.0.1", - "bundled": true, - "extraneous": true + "bundled": true }, "lodash._cacheindexof": { "version": "3.0.2", - "bundled": true, - "extraneous": true + "bundled": true }, "lodash._createcache": { "version": "3.1.2", "bundled": true, - "extraneous": true, "requires": { "lodash._getnative": "^3.0.0" } @@ -57777,8 +57767,7 @@ }, "lodash._getnative": { "version": "3.9.1", - "bundled": true, - "extraneous": true + "bundled": true }, "lodash._root": { "version": "3.0.1", @@ -57790,8 +57779,7 @@ }, "lodash.restparam": { "version": "3.6.1", - "bundled": true, - "extraneous": true + "bundled": true }, "lodash.union": { "version": "4.6.0", @@ -64397,9 +64385,9 @@ "dev": true }, "undici-types": { - "version": "5.26.5", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", - "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", "dev": true }, "unicode-canonical-property-names-ecmascript": { diff --git a/package.json b/package.json index 274c530ce..e4b1d80c4 100644 --- a/package.json +++ b/package.json @@ -127,7 +127,7 @@ "cross-env": "^5.0.5", "cz-conventional-changelog": "2.1.0", "dotenv": "^4.0.0", - "electron": "29.0.0", + "electron": "33.2.1", "electron-builder": "24.9.1", "electron-notarize": "1.0.0", "electron-rebuild": "3.2.9", @@ -156,7 +156,7 @@ "lerna": "^3.8.0", "mobx-react-devtools": "6.0.3", "mocha": "5.2.0", - "node-abi": "3.54.0", + "node-abi": "3.71.0", "prettier": "1.15.2", "react-intl-translations-manager": "5.0.3", "terser-webpack-plugin": "1.2.1", diff --git a/src/app.js b/src/app.js index 9a1306622..a8d7f086d 100644 --- a/src/app.js +++ b/src/app.js @@ -1,52 +1,54 @@ import { webFrame } from 'electron'; -import React from 'react'; -import { render } from 'react-dom'; import { Provider } from 'mobx-react'; -import { syncHistoryWithStore, RouterStore } from 'mobx-react-router'; +import { RouterStore, syncHistoryWithStore } from 'mobx-react-router'; +import { render } from 'react-dom'; import { - Router, Route, hashHistory, IndexRoute, IndexRedirect, + hashHistory, + IndexRedirect, + Route, + Router, } from 'react-router'; import '@babel/polyfill'; import smoothScroll from 'smoothscroll-polyfill'; -import ServerApi from './api/server/ServerApi'; -import LocalApi from './api/server/LocalApi'; -import storeFactory from './stores'; -import apiFactory from './api'; import actions from './actions'; +import apiFactory from './api'; +import LocalApi from './api/server/LocalApi'; +import ServerApi from './api/server/ServerApi'; import MenuFactory from './lib/Menu'; import TouchBarFactory from './lib/TouchBar'; import * as analytics from './lib/analytics'; +import storeFactory from './stores'; import I18N from './I18n'; -import AppLayoutContainer from './containers/layout/AppLayoutContainer'; -import SettingsWindow from './containers/settings/SettingsWindow'; -import RecipesScreen from './containers/settings/RecipesScreen'; -import ServicesScreen from './containers/settings/ServicesScreen'; -import EditServiceScreen from './containers/settings/EditServiceScreen'; -import AccountScreen from './containers/settings/AccountScreen'; -import TeamScreen from './containers/settings/TeamScreen'; -import EditUserScreen from './containers/settings/EditUserScreen'; -import EditSettingsScreen from './containers/settings/EditSettingsScreen'; -import InviteSettingsScreen from './containers/settings/InviteScreen'; -import WelcomeScreen from './containers/auth/WelcomeScreen'; +import AuthLayoutContainer from './containers/auth/AuthLayoutContainer'; +import ImportScreen from './containers/auth/ImportScreen'; +import InviteScreen from './containers/auth/InviteScreen'; import LoginScreen from './containers/auth/LoginScreen'; import PasswordScreen from './containers/auth/PasswordScreen'; -import SignupScreen from './containers/auth/SignupScreen'; -import ImportScreen from './containers/auth/ImportScreen'; import PricingScreen from './containers/auth/PricingScreen'; -import InviteScreen from './containers/auth/InviteScreen'; import SetupAssistentScreen from './containers/auth/SetupAssistantScreen'; -import AuthLayoutContainer from './containers/auth/AuthLayoutContainer'; +import SignupScreen from './containers/auth/SignupScreen'; +import WelcomeScreen from './containers/auth/WelcomeScreen'; +import AppLayoutContainer from './containers/layout/AppLayoutContainer'; +import AccountScreen from './containers/settings/AccountScreen'; +import EditServiceScreen from './containers/settings/EditServiceScreen'; +import EditSettingsScreen from './containers/settings/EditSettingsScreen'; +import EditUserScreen from './containers/settings/EditUserScreen'; +import InviteSettingsScreen from './containers/settings/InviteScreen'; +import RecipesScreen from './containers/settings/RecipesScreen'; +import ServicesScreen from './containers/settings/ServicesScreen'; +import SettingsWindow from './containers/settings/SettingsWindow'; +import TeamScreen from './containers/settings/TeamScreen'; import SubscriptionPopupScreen from './containers/subscription/SubscriptionPopupScreen'; -import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; -import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; -import { WORKSPACES_ROUTES } from './features/workspaces'; -import AnnouncementScreen from './features/announcements/components/AnnouncementScreen'; -import { ANNOUNCEMENTS_ROUTES } from './features/announcements'; import { isMac } from './environment'; +import { ANNOUNCEMENTS_ROUTES } from './features/announcements'; +import AnnouncementScreen from './features/announcements/components/AnnouncementScreen'; +import { WORKSPACES_ROUTES } from './features/workspaces'; +import EditWorkspaceScreen from './features/workspaces/containers/EditWorkspaceScreen'; +import WorkspacesScreen from './features/workspaces/containers/WorkspacesScreen'; // Add Polyfills smoothScroll.polyfill(); @@ -110,7 +112,7 @@ window.addEventListener('load', () => { - + diff --git a/src/components/ui/FeatureList.js b/src/components/ui/FeatureList.js index 72c799819..979ae569b 100644 --- a/src/components/ui/FeatureList.js +++ b/src/components/ui/FeatureList.js @@ -1,9 +1,9 @@ -import React, { Component } from 'react'; import PropTypes from 'prop-types'; +import { Component } from 'react'; import { defineMessages, intlShape } from 'react-intl'; -import { FeatureItem } from './FeatureItem'; import { PLANS } from '../../config'; +import { FeatureItem } from './FeatureItem'; const messages = defineMessages({ availableRecipes: { @@ -139,7 +139,7 @@ export class FeatureList extends Component { return ( ); } diff --git a/src/electron/ipc-api/overlayWindow.ts b/src/electron/ipc-api/overlayWindow.ts index 42650140f..a70757e7e 100644 --- a/src/electron/ipc-api/overlayWindow.ts +++ b/src/electron/ipc-api/overlayWindow.ts @@ -1,7 +1,10 @@ -import { BrowserWindow, ipcMain, webContents } from 'electron'; +import { + BrowserWindow, ipcMain, + webContents, +} from 'electron'; // eslint-disable-next-line import/no-named-default import { isDevMode, isLinux, isMac } from '../../environment'; -import { OVERLAY_OPEN } from '../../ipcChannels'; +import { OVERLAY_OPEN, RELAY_MESSAGE } from '../../ipcChannels'; const debug = require('debug')('Franz:ipcApi:overlayWindow'); @@ -66,6 +69,17 @@ export function openOverlay(mainWindow: BrowserWindow, settings: any, args: IArg }); window.on('close', () => resolve('closed')); + + // ipc messages + ipcMain.on(RELAY_MESSAGE, (event, channel, ...data) => { + const mainWindowWebContentsId = mainWindow.webContents.id; + + if (event.sender.id === mainWindowWebContentsId) { + window.webContents.send(channel, event.sender.id, ...data); + } else { + mainWindow.webContents.send(channel, event.sender.id, ...data); + } + }); } catch (err) { console.log(err); resolve('error'); diff --git a/src/electron/ipc-api/settings.js b/src/electron/ipc-api/settings.js index 15182739c..4383f6236 100644 --- a/src/electron/ipc-api/settings.js +++ b/src/electron/ipc-api/settings.js @@ -1,10 +1,11 @@ import { ipcMain } from 'electron'; +import { GET_SETTINGS, SEND_SETTINGS } from '../../ipcChannels'; export default (params) => { - ipcMain.on('getAppSettings', (event, type) => { - params.mainWindow.webContents.send('appSettings', { + ipcMain.on(GET_SETTINGS, (event, type) => { + event.sender.send(SEND_SETTINGS, { type, - data: params.settings[type].allSerialized, + data: params.settings[type]?.allSerialized, }); }); diff --git a/src/features/planSelection/containers/PlanSelectionScreen.js b/src/features/planSelection/containers/PlanSelectionScreen.js index c97c65d0d..c3b236458 100644 --- a/src/features/planSelection/containers/PlanSelectionScreen.js +++ b/src/features/planSelection/containers/PlanSelectionScreen.js @@ -1,14 +1,13 @@ -import React, { Component } from 'react'; import { dialog, getCurrentWindow } from '@electron/remote'; -import { defineMessages, intlShape } from 'react-intl'; import { ipcRenderer } from 'electron'; +import { Component } from 'react'; +import { defineMessages, intlShape } from 'react-intl'; -import PlanSelection from '../components/PlanSelection'; -import ErrorBoundary from '../../../components/util/ErrorBoundary'; import { ACTIONS, GA_CATEGORY_PLAN_SELECTION } from '..'; +import ErrorBoundary from '../../../components/util/ErrorBoundary'; +import { PLAN_SELECTION_GET_DATA, PLAN_SELECTION_TRIGGER_ACTION, RELAY_MESSAGE } from '../../../ipcChannels'; import { gaEvent, gaPage } from '../../../lib/analytics'; -import { DEFAULT_WEB_CONTENTS_ID } from '../../../config'; -import { PLAN_SELECTION_GET_DATA, PLAN_SELECTION_TRIGGER_ACTION } from '../../../ipcChannels'; +import PlanSelection from '../components/PlanSelection'; const messages = defineMessages({ dialogTitle: { @@ -44,7 +43,7 @@ class PlanSelectionScreen extends Component { } componentWillMount() { - ipcRenderer.on(PLAN_SELECTION_GET_DATA, (event, data) => { + ipcRenderer.on(PLAN_SELECTION_GET_DATA, (event, senderId, data) => { this.setState(prevState => ({ ...prevState, ...data, @@ -52,11 +51,11 @@ class PlanSelectionScreen extends Component { })); }); - ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, PLAN_SELECTION_GET_DATA); + ipcRenderer.send(RELAY_MESSAGE, PLAN_SELECTION_GET_DATA); } triggerAction(action, data) { - ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, PLAN_SELECTION_TRIGGER_ACTION, action, data); + ipcRenderer.send(RELAY_MESSAGE, PLAN_SELECTION_TRIGGER_ACTION, action, data); } render() { diff --git a/src/features/planSelection/index.js b/src/features/planSelection/index.js index 97154a31c..8d65b1635 100644 --- a/src/features/planSelection/index.js +++ b/src/features/planSelection/index.js @@ -1,7 +1,9 @@ import { BrowserWindow, webContents } from '@electron/remote'; import { ipcRenderer } from 'electron'; import { reaction } from 'mobx'; -import { OVERLAY_OPEN, PLAN_SELECTION_GET_DATA, PLAN_SELECTION_TRIGGER_ACTION } from '../../ipcChannels'; +import { + OVERLAY_OPEN, PLAN_SELECTION_GET_DATA, PLAN_SELECTION_TRIGGER_ACTION, RELAY_MESSAGE, +} from '../../ipcChannels'; import PlanSelectionStore from './store'; const debug = require('debug')('Franz:feature:planSelection'); @@ -24,6 +26,7 @@ export default function initPlanSelection(stores, actions) { reaction( () => features.features.isPlanSelectionEnabled, (isEnabled) => { + console.log('planSelection: isEnabled', isEnabled); if (isEnabled) { debug('Initializing `planSelection` feature'); planSelectionStore.start(stores, actions); @@ -35,9 +38,9 @@ export default function initPlanSelection(stores, actions) { route: '/plan-selection', modal: true, }); - ipcRenderer.on(PLAN_SELECTION_GET_DATA, (event) => { + ipcRenderer.on(PLAN_SELECTION_GET_DATA, () => { debug('requesting data'); - ipcRenderer.sendTo(event.senderId, PLAN_SELECTION_GET_DATA, { + ipcRenderer.send(RELAY_MESSAGE, PLAN_SELECTION_GET_DATA, { firstname: user.data.firstname, hadSubscription: user.data.hadSubscription, isSubscriptionExpired: user.team && user.team.state === 'expired' && !user.team.userHasDowngraded, @@ -48,14 +51,14 @@ export default function initPlanSelection(stores, actions) { }); }); - ipcRenderer.on(PLAN_SELECTION_TRIGGER_ACTION, (event, action, data) => { + ipcRenderer.on(PLAN_SELECTION_TRIGGER_ACTION, (event, senderId, action, data) => { if (action === ACTIONS.UPGRADE_ACCOUNT) { debug('upgrade account'); actions.payment.upgradeAccount({ planId: data.planId, - overrideParent: event.senderId, + overrideParent: senderId, onCloseWindow: async () => { - const planSelectionWindow = BrowserWindow.fromWebContents(webContents.fromId(event.senderId)); + const planSelectionWindow = BrowserWindow.fromWebContents(webContents.fromId(senderId)); await user.getUserInfoRequest._promise; diff --git a/src/features/shareFranz/Component.js b/src/features/shareFranz/Component.js index 0f22bd367..6aa55a8c9 100644 --- a/src/features/shareFranz/Component.js +++ b/src/features/shareFranz/Component.js @@ -1,20 +1,22 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; -import { observer } from 'mobx-react'; -import injectSheet from 'react-jss'; -import { defineMessages, intlShape } from 'react-intl'; import { Button } from '@meetfranz/forms'; import { H1, Icon } from '@meetfranz/ui'; +import { observer } from 'mobx-react'; +import PropTypes from 'prop-types'; +import { Component } from 'react'; +import { defineMessages, intlShape } from 'react-intl'; +import injectSheet from 'react-jss'; import { - mdiHeart, mdiEmail, mdiFacebookBox, mdiTwitter, mdiLinkedinBox, mdiClose, + mdiClose, + mdiEmail, mdiFacebookBox, + mdiHeart, + mdiLinkedinBox, + mdiTwitter, } from '@mdi/js'; import { ipcRenderer } from 'electron'; import { state } from '.'; +import { RELAY_MESSAGE, SHARE_FRANZ_GET_SERVICE_COUNT } from '../../ipcChannels'; import { gaEvent } from '../../lib/analytics'; -import { DEFAULT_WEB_CONTENTS_ID } from '../../config'; -import { SHARE_FRANZ_GET_SERVICE_COUNT } from '../../ipcChannels'; -import service from '../../actions/service'; const messages = defineMessages({ headline: { @@ -120,10 +122,10 @@ export default @injectSheet(styles) @observer class ShareFranzModal extends Comp } componentDidMount() { - ipcRenderer.on(SHARE_FRANZ_GET_SERVICE_COUNT, (event, { serviceCount }) => { + ipcRenderer.on(SHARE_FRANZ_GET_SERVICE_COUNT, (event, senderId, { serviceCount }) => { this.setState({ serviceCount }); }); - ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, SHARE_FRANZ_GET_SERVICE_COUNT); + ipcRenderer.send(RELAY_MESSAGE, SHARE_FRANZ_GET_SERVICE_COUNT); } close() { diff --git a/src/features/shareFranz/index.js b/src/features/shareFranz/index.js index 488e6a1db..3400e71c9 100644 --- a/src/features/shareFranz/index.js +++ b/src/features/shareFranz/index.js @@ -2,9 +2,9 @@ import { observable, reaction } from 'mobx'; import ms from 'ms'; import { ipcRenderer } from 'electron'; -import { state as delayAppState } from '../delayApp'; +import { OVERLAY_OPEN, RELAY_MESSAGE, SHARE_FRANZ_GET_SERVICE_COUNT } from '../../ipcChannels'; import { gaEvent, gaPage } from '../../lib/analytics'; -import { OVERLAY_OPEN, SHARE_FRANZ_GET_SERVICE_COUNT } from '../../ipcChannels'; +import { state as delayAppState } from '../delayApp'; import { planSelectionStore } from '../planSelection'; export { default as Component } from './Component'; @@ -25,8 +25,8 @@ export default function initialize(stores) { state, }; - ipcRenderer.on(SHARE_FRANZ_GET_SERVICE_COUNT, (event) => { - ipcRenderer.sendTo(event.senderId, SHARE_FRANZ_GET_SERVICE_COUNT, { serviceCount: stores.services.all.length }); + ipcRenderer.on(SHARE_FRANZ_GET_SERVICE_COUNT, () => { + ipcRenderer.send(RELAY_MESSAGE, SHARE_FRANZ_GET_SERVICE_COUNT, { serviceCount: stores.services.all.length }); }); function showModal() { diff --git a/src/index.js b/src/index.js index bc460238c..dd6425cc1 100644 --- a/src/index.js +++ b/src/index.js @@ -3,25 +3,25 @@ import { app, BrowserWindow, - shell, - ipcMain, dialog, + ipcMain, + shell, } from 'electron'; // import isDevMode from 'electron-is-dev'; -import fs from 'fs-extra'; -import path from 'path'; -import windowStateKeeper from 'electron-window-state'; -import { enforceMacOSAppLocation } from 'electron-util'; import * as remoteMain from '@electron/remote/main'; +import { enforceMacOSAppLocation } from 'electron-util'; +import windowStateKeeper from 'electron-window-state'; import { EventEmitter } from 'events'; +import fs from 'fs-extra'; +import path from 'path'; remoteMain.initialize(); import { + isLinux, isMac, isWindows, - isLinux, } from './environment'; // Set app directory before loading user modules @@ -44,23 +44,23 @@ if (isDevMode) { app.commandLine.appendSwitch('disable-features', 'CrossOriginOpenerPolicy'); app.commandLine.appendSwitch('disable-site-isolation-trials'); -import ipcApi from './electron/ipc-api'; -import Tray from './lib/Tray'; import Settings from './electron/Settings'; import handleDeepLink from './electron/deepLinking'; +import './electron/exception'; +import ipcApi from './electron/ipc-api'; import { isPositionValid } from './electron/windowUtils'; +import Tray from './lib/Tray'; import { appId } from './package.json'; // eslint-disable-line import/no-unresolved -import './electron/exception'; import { DEFAULT_APP_SETTINGS, DEFAULT_WINDOW_OPTIONS, LIVE_API_WEBSITE, } from './config'; +import { openOverlay } from './electron/ipc-api/overlayWindow'; import { asarPath } from './helpers/asar-helpers'; import { isValidExternalURL } from './helpers/url-helpers'; import userAgent from './helpers/userAgent-helpers'; -import { openOverlay } from './electron/ipc-api/overlayWindow'; import { darkThemeGrayDarker, themeGrayLightest, windowsTitleBarHeight } from './theme/default/legacy'; /* eslint-enable import/first */ diff --git a/src/ipcChannels.ts b/src/ipcChannels.ts index 49102514e..f24c5da8e 100644 --- a/src/ipcChannels.ts +++ b/src/ipcChannels.ts @@ -20,6 +20,10 @@ export const UPDATE_SERVICE_STATE = 'UPDATE_SERVICE_STATE'; export const OVERLAY_OPEN = 'OVERLAY_OPEN'; export const OVERLAY_SHARE_SETTINGS = 'OVERLAY_SHARE_SETTINGS'; +// Settings +export const GET_SETTINGS = 'REQUEST_SETTINGS'; +export const SEND_SETTINGS = 'SEND_SETTINGS'; + // Share Franz Dialog export const SHARE_FRANZ_GET_SERVICE_COUNT = 'SHARE_FRANZ_GET_SERVICE_COUNT'; @@ -51,3 +55,6 @@ export const FETCH_DEBUG_INFO = 'FETCH_DEBUG_INFO'; export const TOGGLE_FULL_SCREEN = 'TOGGLE_FULL_SCREEN'; export const CHECK_MACOS_PERMISSIONS = 'CHECK_MACOS_PERMISSIONS'; export const RELOAD_APP = 'RELOAD_APP'; + +// Relay +export const RELAY_MESSAGE = 'RELAY_MESSAGE'; diff --git a/src/overlayApp.js b/src/overlayApp.js index 23f9ae8f4..24e26672d 100644 --- a/src/overlayApp.js +++ b/src/overlayApp.js @@ -1,25 +1,25 @@ import { ipcRenderer, webFrame } from 'electron'; -import React from 'react'; -import { IntlProvider } from 'react-intl'; import { render } from 'react-dom'; +import { IntlProvider } from 'react-intl'; import { - Router, Route, hashHistory, + Route, + Router, + hashHistory, } from 'react-router'; import '@babel/polyfill'; -import smoothScroll from 'smoothscroll-polyfill'; -import { ThemeProvider } from 'react-jss'; import { theme } from '@meetfranz/theme'; +import { ThemeProvider } from 'react-jss'; +import smoothScroll from 'smoothscroll-polyfill'; -import translations from './i18n/translations'; -import ShareFranz from './features/shareFranz/Component'; -import { OVERLAY_SHARE_SETTINGS } from './ipcChannels'; -import { DEFAULT_WEB_CONTENTS_ID } from './config'; import SubscriptionPopupScreen from './containers/subscription/SubscriptionPopupScreen'; -import PlanSelectionScreen from './features/planSelection/containers/PlanSelectionScreen'; -import { Component as DesktopCapturer } from './features/desktopCapturer'; import { Component as BasicAuth } from './features/basicAuth'; +import { Component as DesktopCapturer } from './features/desktopCapturer'; +import PlanSelectionScreen from './features/planSelection/containers/PlanSelectionScreen'; +import ShareFranz from './features/shareFranz/Component'; +import translations from './i18n/translations'; +import { GET_SETTINGS, SEND_SETTINGS } from './ipcChannels'; // Add Polyfills smoothScroll.polyfill(); @@ -58,7 +58,7 @@ let checkAppInitLoop; function initOverlayApp() { if (!overlayAppInitialized) { - ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, OVERLAY_SHARE_SETTINGS); + ipcRenderer.send(GET_SETTINGS, 'app'); } else { clearInterval(checkAppInitLoop); } @@ -70,10 +70,10 @@ window.addEventListener('load', () => { checkAppInitLoop = setInterval(() => initOverlayApp(), 500); }); -ipcRenderer.on(OVERLAY_SHARE_SETTINGS, (event, settings) => { +ipcRenderer.on(SEND_SETTINGS, (event, { data: settings }) => { setup(settings); - if (settings.theme === 'dark') { + if (settings.darkMode) { document.querySelector('body').classList.add('theme__dark'); } diff --git a/src/stores/AppStore.js b/src/stores/AppStore.js index 5e0beab80..aa674e04f 100644 --- a/src/stores/AppStore.js +++ b/src/stores/AppStore.js @@ -30,7 +30,7 @@ import { sleep } from '../helpers/async-helpers'; import { getServiceIdsFromPartitions, removeServicePartitionDirectory } from '../helpers/service-helpers.js'; import { isValidExternalURL } from '../helpers/url-helpers'; import { - CHECK_FOR_UPDATE, CHECK_MACOS_PERMISSIONS, FETCH_DEBUG_INFO, OVERLAY_SHARE_SETTINGS, RELOAD_APP, WINDOWS_TITLEBAR_FETCH_MENU + CHECK_FOR_UPDATE, CHECK_MACOS_PERMISSIONS, FETCH_DEBUG_INFO, OVERLAY_SHARE_SETTINGS, RELOAD_APP, WINDOWS_TITLEBAR_FETCH_MENU, } from '../ipcChannels'; const debug = require('debug')('Franz:AppStore'); diff --git a/src/stores/ServicesStore.js b/src/stores/ServicesStore.js index cf77bdc01..aed5c7548 100644 --- a/src/stores/ServicesStore.js +++ b/src/stores/ServicesStore.js @@ -523,11 +523,13 @@ export default class ServicesStore extends Store { this.allDisplayed[prevIndex].isActive = true; } - @action _setUnreadMessageCount({ serviceId, count }) { + @action _setUnreadMessageCount({ serviceId, count = { direct: 0, indirect: 0 } }) { const service = this.one(serviceId); - service.unreadDirectMessageCount = count.direct; - service.unreadIndirectMessageCount = count.indirect; + if (service) { + service.unreadDirectMessageCount = count.direct; + service.unreadIndirectMessageCount = count.indirect; + } } @action _toggleService({ serviceId }) { diff --git a/src/stores/SettingsStore.js b/src/stores/SettingsStore.js index c10a99b4f..9e1ce8f37 100644 --- a/src/stores/SettingsStore.js +++ b/src/stores/SettingsStore.js @@ -4,13 +4,14 @@ import { } from 'mobx'; import localStorage from 'mobx-localstorage'; -import Store from './lib/Store'; -import Request from './lib/Request'; import { getLocale } from '../helpers/i18n-helpers'; +import Request from './lib/Request'; +import Store from './lib/Store'; import { DEFAULT_APP_SETTINGS, FILE_SYSTEM_SETTINGS_TYPES } from '../config'; -import { SPELLCHECKER_LOCALES } from '../i18n/languages'; import { APP_MENU_ACKNOWLEDGED_KEY } from '../features/appMenu'; +import { SPELLCHECKER_LOCALES } from '../i18n/languages'; +import { GET_SETTINGS, SEND_SETTINGS } from '../ipcChannels'; const debug = require('debug')('Franz:SettingsStore'); @@ -31,14 +32,14 @@ export default class SettingsStore extends Store { this.actions.settings.update.listen(this._update.bind(this)); this.actions.settings.remove.listen(this._remove.bind(this)); - ipcRenderer.on('appSettings', (event, resp) => { + ipcRenderer.on(SEND_SETTINGS, (event, resp) => { debug('Get appSettings resolves', resp.type, resp.data); Object.assign(this._fileSystemSettingsCache[resp.type], resp.data); }); this.fileSystemSettingsTypes.forEach((type) => { - ipcRenderer.send('getAppSettings', type); + ipcRenderer.send(GET_SETTINGS, type); }); } diff --git a/src/styles/layout.scss b/src/styles/layout.scss index 1919026d4..fc26ad52d 100644 --- a/src/styles/layout.scss +++ b/src/styles/layout.scss @@ -77,7 +77,7 @@ body:not(.darwin):not(.isFullScreen) .app .app__content { .electron-app-title-bar { z-index: 99999999; } body.darwin .window-draggable { - height: 35px; + height: 15px; left: 0; pointer-events: none; position: absolute; @@ -177,4 +177,4 @@ body:not(.darwin) .window-draggable { .appMenuBar { background: $theme-gray-lightest; -} \ No newline at end of file +}