Skip to content

Commit

Permalink
fix windows menu
Browse files Browse the repository at this point in the history
  • Loading branch information
adlk committed Dec 15, 2024
1 parent f0517db commit 33717e5
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 46 deletions.
10 changes: 5 additions & 5 deletions src/features/appMenu/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import React, { Component } from 'react';
import { PropTypes } from 'prop-types';
import { mdiDotsVertical } from '@mdi/js';
import { Icon } from '@meetfranz/ui';
import { inject, observer } from 'mobx-react';
import { PropTypes } from 'prop-types';
import React, { Component } from 'react';
import { intlShape } from 'react-intl';
import injectSheet from 'react-jss';
import { Icon } from '@meetfranz/ui';
import { mdiDotsVertical } from '@mdi/js';
import { windowsTitleBarHeight } from '../../theme/default/legacy';
import { AppMenu } from '../../lib/Menu';
import AppStore from '../../stores/AppStore';
import SettingsStore from '../../stores/SettingsStore';
import { windowsTitleBarHeight } from '../../theme/default/legacy';

export const APP_MENU_ACKNOWLEDGED_KEY = 'appMenuBarAcknowledged';

Expand Down
1 change: 0 additions & 1 deletion src/ipcChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const WORKSPACE_OPEN_SETTINGS = 'WORKSPACE_OPEN_SETTINGS';
export const WORKSPACE_ACTIVATE = 'WORKSPACE_ACTIVATE';

// General
export const CHECK_FOR_UPDATE = 'CHECK_FOR_UPDATE';
export const FETCH_DEBUG_INFO = 'FETCH_DEBUG_INFO';
export const TOGGLE_FULL_SCREEN = 'TOGGLE_FULL_SCREEN';
export const CHECK_MACOS_PERMISSIONS = 'CHECK_MACOS_PERMISSIONS';
Expand Down
75 changes: 40 additions & 35 deletions src/lib/Menu.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
import { shell, clipboard, ipcRenderer } from 'electron';
import {
app, Menu, dialog, webContents, getCurrentWindow,
app,
dialog,
getCurrentWindow,
Menu,
webContents,
} from '@electron/remote';
import { observable, autorun } from 'mobx';
import { clipboard, ipcRenderer, shell } from 'electron';
import { autorun, observable } from 'mobx';
import { defineMessages } from 'react-intl';

import { isMac, ctrlKey, cmdKey } from '../environment';
import { GA_CATEGORY_WORKSPACES, workspaceStore } from '../features/workspaces/index';
import { workspaceActions } from '../features/workspaces/actions';
import { gaEvent } from './analytics';
import { announcementActions } from '../features/announcements/actions';
import { DEFAULT_WEB_CONTENTS_ID } from '../config';
import { cmdKey, ctrlKey, isMac } from '../environment';
import { announcementsStore } from '../features/announcements';
import { announcementActions } from '../features/announcements/actions';
import { GA_CATEGORY_TODOS, todosStore } from '../features/todos';
import { todoActions } from '../features/todos/actions';
import { CUSTOM_WEBSITE_ID } from '../features/webControls/constants';
import { workspaceActions } from '../features/workspaces/actions';
import { GA_CATEGORY_WORKSPACES, workspaceStore } from '../features/workspaces/index';
import {
ACTIVATE_NEXT_SERVICE, ACTIVATE_PREVIOUS_SERVICE, ACTIVATE_SERVICE, CHECK_FOR_UPDATE, FETCH_DEBUG_INFO, GET_ACTIVE_SERVICE_WEB_CONTENTS_ID, OPEN_SERVICE_DEV_TOOLS, RELOAD_APP, RELOAD_SERVICE, SETTINGS_NAVIGATE_TO, TODOS_OPEN_DEV_TOOLS, TODOS_RELOAD, TODOS_TOGGLE_DRAWER, TODOS_TOGGLE_ENABLE_TODOS, TOGGLE_FULL_SCREEN, WORKSPACE_ACTIVATE, WORKSPACE_OPEN_SETTINGS, WORKSPACE_TOGGLE_DRAWER,
ACTIVATE_NEXT_SERVICE, ACTIVATE_PREVIOUS_SERVICE, ACTIVATE_SERVICE,
GET_ACTIVE_SERVICE_WEB_CONTENTS_ID, OPEN_SERVICE_DEV_TOOLS, RELOAD_APP, RELOAD_SERVICE, SETTINGS_NAVIGATE_TO, TODOS_OPEN_DEV_TOOLS, TODOS_RELOAD, TODOS_TOGGLE_DRAWER, TODOS_TOGGLE_ENABLE_TODOS, TOGGLE_FULL_SCREEN, WORKSPACE_ACTIVATE, WORKSPACE_OPEN_SETTINGS, WORKSPACE_TOGGLE_DRAWER,
} from '../ipcChannels';
import { DEFAULT_WEB_CONTENTS_ID } from '../config';
import { gaEvent } from './analytics';

export const menuItems = defineMessages({
edit: {
Expand Down Expand Up @@ -452,7 +457,7 @@ export const _titleBarTemplateFactory = ({ user, intl }) => [
label: intl.formatMessage(menuItems.reloadFranz),
accelerator: `${cmdKey}+Shift+R`,
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, RELOAD_APP);
window.location.reload();
},
},
{
Expand Down Expand Up @@ -493,7 +498,7 @@ export const _titleBarTemplateFactory = ({ user, intl }) => [
},
{
label: intl.formatMessage(menuItems.changelog),
click() { shell.openExternal('https://github.com/meetfranz/franz/blob/master/CHANGELOG.md'); },
click() { shell.openExternal('https://meetfranz.com/changelog'); },
},
{
type: 'separator',
Expand All @@ -519,17 +524,14 @@ export const _titleBarTemplateFactory = ({ user, intl }) => [
{
label: intl.formatMessage(menuItems.debugInfo),
click: () => {
ipcRenderer.on(FETCH_DEBUG_INFO, (e, data) => {
console.log('huhu, debug');
clipboard.write({
text: JSON.stringify(data),
});
const { debugInfo } = window.franz.stores.app;
clipboard.write({
text: JSON.stringify(debugInfo, null, 2),
});

const notification = new window.Notification(intl.formatMessage(menuItems.debugInfoCopiedHeadline), {
body: intl.formatMessage(menuItems.debugInfoCopiedBody),
});
const notification = new window.Notification(intl.formatMessage(menuItems.debugInfoCopiedHeadline), {
body: intl.formatMessage(menuItems.debugInfoCopiedBody),
});
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, FETCH_DEBUG_INFO);
},
},
],
Expand Down Expand Up @@ -557,7 +559,7 @@ export const _titleBarTemplateFactory = ({ user, intl }) => [
{
label: intl.formatMessage(menuItems.checkForUpdates),
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, CHECK_FOR_UPDATE);
window.franz.actions.app.checkForUpdates();
},
},
{
Expand All @@ -567,18 +569,13 @@ export const _titleBarTemplateFactory = ({ user, intl }) => [
label: intl.formatMessage(menuItems.settings),
accelerator: 'CmdOrCtrl+,',
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, SETTINGS_NAVIGATE_TO, {
path: 'app',
});
window.franz.actions.ui.openSettings({ path: 'app' });
},
enabled: user.isLoggedIn,
},
{
type: 'separator',
},
{
type: 'separator',
},
{
label: intl.formatMessage(menuItems.edit),
visible: false,
Expand Down Expand Up @@ -785,7 +782,8 @@ function serviceMenu({
&& services.length > 0) {
ipcRenderer.send(RELOAD_SERVICE);
} else {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, RELOAD_APP);
const contents = webContents.fromId(DEFAULT_WEB_CONTENTS_ID);
contents.send(RELOAD_APP);
}
},
});
Expand Down Expand Up @@ -819,7 +817,8 @@ function workspacesMenu({
label: intl.formatMessage(menuItems.addNewWorkspace),
accelerator: `${cmdKey}+Shift+N`,
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, WORKSPACE_OPEN_SETTINGS);
const contents = webContents.fromId(DEFAULT_WEB_CONTENTS_ID);
contents.send(WORKSPACE_OPEN_SETTINGS);
},
enabled: user.isLoggedIn,
});
Expand All @@ -832,7 +831,8 @@ function workspacesMenu({
label: intl.formatMessage(drawerLabel),
accelerator: `${cmdKey}+D`,
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, WORKSPACE_TOGGLE_DRAWER);
const contents = webContents.fromId(DEFAULT_WEB_CONTENTS_ID);
contents.send(WORKSPACE_TOGGLE_DRAWER);
gaEvent(GA_CATEGORY_WORKSPACES, 'toggleDrawer', 'menu');
},
enabled: user.isLoggedIn,
Expand All @@ -847,7 +847,8 @@ function workspacesMenu({
type: 'radio',
checked: !activeWorkspace,
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, WORKSPACE_ACTIVATE);
const contents = webContents.fromId(DEFAULT_WEB_CONTENTS_ID);
contents.send(WORKSPACE_ACTIVATE);
gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'menu');
},
});
Expand All @@ -860,7 +861,8 @@ function workspacesMenu({
type: 'radio',
checked: activeWorkspace ? workspace.id === activeWorkspace.id : false,
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, WORKSPACE_ACTIVATE, { workspaceId: workspace.id });
const contents = webContents.fromId(DEFAULT_WEB_CONTENTS_ID);
contents.send(WORKSPACE_ACTIVATE, { workspaceId: workspace.id });
gaEvent(GA_CATEGORY_WORKSPACES, 'switch', 'menu');
},
}));
Expand All @@ -880,7 +882,9 @@ function todosMenu({
label: intl.formatMessage(drawerLabel),
accelerator: `${cmdKey}+T`,
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, TODOS_TOGGLE_DRAWER);
const contents = webContents.fromId(DEFAULT_WEB_CONTENTS_ID);
contents.send(TODOS_TOGGLE_DRAWER);

gaEvent(GA_CATEGORY_TODOS, 'toggleDrawer', 'menu');
},
enabled: user.isLoggedIn && isTodosEnabled,
Expand Down Expand Up @@ -908,7 +912,8 @@ function todosMenu({
}, {
label: intl.formatMessage(menuItems.enableTodos),
click: () => {
ipcRenderer.sendTo(DEFAULT_WEB_CONTENTS_ID, TODOS_TOGGLE_ENABLE_TODOS);
const contents = webContents.fromId(DEFAULT_WEB_CONTENTS_ID);
contents.send(TODOS_TOGGLE_ENABLE_TODOS);
gaEvent(GA_CATEGORY_TODOS, 'enable', 'menu');
},
});
Expand Down
6 changes: 1 addition & 5 deletions src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_MACOS_PERMISSIONS, FETCH_DEBUG_INFO, OVERLAY_SHARE_SETTINGS, RELOAD_APP, WINDOWS_TITLEBAR_FETCH_MENU
} from '../ipcChannels';

const debug = require('debug')('Franz:AppStore');
Expand Down Expand Up @@ -180,10 +180,6 @@ export default class AppStore extends Store {
ipcRenderer.sendTo(e.senderId, FETCH_DEBUG_INFO, JSON.parse(JSON.stringify(this.debugInfo)));
});

ipcRenderer.on(CHECK_FOR_UPDATE, () => {
this._checkForUpdates();
});

// Handle deep linking (franz://)
ipcRenderer.on('navigateFromDeepLink', (event, data) => {
debug('Navigate from deep link', data);
Expand Down

0 comments on commit 33717e5

Please sign in to comment.