Skip to content

Commit

Permalink
Merge branch 'develop' into 2493-improve-contact-selection-for-evm-ne…
Browse files Browse the repository at this point in the history
…tworks
  • Loading branch information
Tuditi authored May 29, 2024
2 parents a22ba2c + 27b1e50 commit 097fb90
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 112 deletions.
28 changes: 15 additions & 13 deletions packages/desktop/lib/electron/menus/edit.menu.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MENU_STATE } from './menu-state.constant'
import { menuState } from './menu'

interface MenuItem extends Electron.MenuItemConstructorOptions {
selector: string
Expand All @@ -8,20 +8,22 @@ const menuItem = (
role: NonNullable<Electron.MenuItemConstructorOptions['role']>,
accelerator: Electron.MenuItemConstructorOptions['accelerator']
): MenuItem => ({
label: MENU_STATE.strings[role],
label: menuState.strings[role],
accelerator,
selector: `${role}:`,
})

export const editMenu: Electron.MenuItemConstructorOptions = {
label: MENU_STATE.strings.edit,
submenu: [
menuItem('undo', 'CmdOrCtrl+Z'),
menuItem('redo', 'Shift+CmdOrCtrl+Z'),
{ type: 'separator' },
menuItem('cut', 'CmdOrCtrl+X'),
menuItem('copy', 'CmdOrCtrl+C'),
menuItem('paste', 'CmdOrCtrl+V'),
menuItem('selectAll', 'CmdOrCtrl+A'),
],
export function buildEditMenu(): Electron.MenuItemConstructorOptions {
return {
label: menuState.strings.edit,
submenu: [
menuItem('undo', 'CmdOrCtrl+Z'),
menuItem('redo', 'Shift+CmdOrCtrl+Z'),
{ type: 'separator' },
menuItem('cut', 'CmdOrCtrl+X'),
menuItem('copy', 'CmdOrCtrl+C'),
menuItem('paste', 'CmdOrCtrl+V'),
menuItem('selectAll', 'CmdOrCtrl+A'),
],
}
}
22 changes: 12 additions & 10 deletions packages/desktop/lib/electron/menus/help.menu.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { MENU_STATE } from './menu-state.constant'
import { menuState } from './menu'
import { shell } from 'electron'
import { DISCORD_URL, DOCUMENTATION_URL, ISSUE_REPORT_URL } from '@contexts/settings/constants'

const menuItem = (
action: 'faq' | 'documentation' | 'discord' | 'reportAnIssue',
url: string
): Electron.MenuItemConstructorOptions => ({
label: MENU_STATE.strings[action],
label: menuState.strings[action],
click: () => void shell.openExternal(url),
})

export const helpMenu: Electron.MenuItemConstructorOptions = {
label: MENU_STATE.strings.help,
submenu: [
// menuItem('faq', FAQ_URL),
menuItem('documentation', DOCUMENTATION_URL),
menuItem('discord', DISCORD_URL),
menuItem('reportAnIssue', ISSUE_REPORT_URL),
],
export function buildHelpMenu(): Electron.MenuItemConstructorOptions {
return {
label: menuState.strings.help,
submenu: [
// menuItem('faq', FAQ_URL),
menuItem('documentation', DOCUMENTATION_URL),
menuItem('discord', DISCORD_URL),
menuItem('reportAnIssue', ISSUE_REPORT_URL),
],
}
}
59 changes: 31 additions & 28 deletions packages/desktop/lib/electron/menus/menu-state.constant.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,36 @@
import $ from '../../../../shared/src/locales/en.json'

export const MENU_STATE = {
enabled: true,
strings: {
about: 'About Bloom',
checkForUpdates: 'Check for Updates',
importThirdPartyProfiles: 'Import Third-Party Profiles',
settings: 'Settings',
security: 'Security',
advanced: 'Advanced',
errorLog: 'Error Log',
diagnostics: 'Diagnostics',
logout: 'Log Out',
hide: 'Hide',
hideOthers: 'Hide Others',
showAll: 'Show All',
quit: 'Quit',
edit: 'Edit',
undo: 'Undo',
redo: 'Redo',
cut: 'Cut',
copy: 'Copy',
paste: 'Paste',
selectAll: 'Select All',
wallet: 'Wallet',
addAccount: 'Add Account',
help: 'Help',
faq: 'FAQ',
documentation: 'Documentation',
discord: 'Discord',
reportAnIssue: 'Report an Issue',
version: 'Version {version}',
about: $.views.settings.about.title,
addAccount: $.actions.addAccount,
advanced: $.views.settings.advanced.title,
checkForUpdates: $.actions.checkForUpdates,
copy: $.actions.copy,
cut: $.actions.cut,
developerTools: $.general.developerTools,
diagnostics: $.views.settings.diagnostics.title,
discord: $.views.settings.discord.title,
documentation: $.views.settings.documentation.title,
edit: $.actions.edit,
errorLog: $.views.settings.errorLog.title,
faq: $.views.settings.faq.title,
help: $.general.help,
hide: $.actions.hide,
hideOthers: $.actions.hideOthers,
importThirdPartyProfiles: $.actions.importThirdPartyProfiles,
logout: $.views.dashboard.profileMenu.logout,
paste: $.actions.paste,
quit: $.actions.quit,
redo: $.actions.redo,
reportAnIssue: $.actions.reportAnIssue,
security: $.views.settings.security.title,
selectAll: $.actions.selectAll,
settings: $.views.settings.settings,
showAll: $.actions.showAll,
undo: $.actions.undo,
version: $.general.versionFull,
wallet: $.general.wallet,
},
}
46 changes: 23 additions & 23 deletions packages/desktop/lib/electron/menus/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import { app, ipcMain, Menu } from 'electron'
import features from '@features/features'
import { getOrInitWindow } from '../processes/main.process'
import { MENU_STATE } from './menu-state.constant'
import { editMenu } from './edit.menu'
import { helpMenu } from './help.menu'
import { walletMenu } from './wallet.menu'
import { buildEditMenu } from './edit.menu'
import { buildHelpMenu } from './help.menu'
import { buildWalletMenu } from './wallet.menu'
import { AboutWindow } from '../windows/about.window'

interface MenuState {
Expand All @@ -15,7 +15,7 @@ interface MenuState {
loggedIn?: boolean
}

let state: MenuState = MENU_STATE
export let menuState: MenuState = MENU_STATE

function createMenu(): Electron.Menu {
const template = buildTemplate()
Expand Down Expand Up @@ -44,14 +44,14 @@ export function initMenu(): void {

app.once('ready', () => {
ipcMain.handle('menu-update', (e, args) => {
state = { ...state, ...args }
menuState = { ...menuState, ...args }
mainMenu = createMenu()
})

ipcMain.handle('menu-popup', () => {
mainMenu.popup({ window: getOrInitWindow('main') })
})
ipcMain.handle('menu-data', () => state)
ipcMain.handle('menu-data', () => menuState)
handleWindowControls()
mainMenu = createMenu()
})
Expand Down Expand Up @@ -79,12 +79,12 @@ function buildTemplate(): Electron.MenuItemConstructorOptions[] {
let firstMenuSubmenu: Electron.MenuItemConstructorOptions[] = getFirstSubmenuItems()

if (!app.isPackaged || features?.electron?.developerTools?.enabled) {
firstMenuSubmenu = [...firstMenuSubmenu, roleMenuItem('Developer Tools', 'toggleDevTools')]
firstMenuSubmenu = [...firstMenuSubmenu, roleMenuItem(menuState.strings.developerTools, 'toggleDevTools')]
}

firstMenuSubmenu = [
...firstMenuSubmenu,
commandMenuItem(state.strings.errorLog, 'menu-error-log'),
commandMenuItem(menuState.strings.errorLog, 'menu-error-log'),
{ type: 'separator' },
]

Expand All @@ -95,7 +95,7 @@ function buildTemplate(): Electron.MenuItemConstructorOptions[] {
firstMenuSubmenu = [
...firstMenuSubmenu,
{
label: state.strings.quit,
label: menuState.strings.quit,
accelerator: process.platform === 'win32' ? 'Alt+F4' : 'CmdOrCtrl+Q',
click: function (): void {
app.quit()
Expand All @@ -108,48 +108,48 @@ function buildTemplate(): Electron.MenuItemConstructorOptions[] {
submenu: firstMenuSubmenu,
}

const template: Electron.MenuItemConstructorOptions[] = [firstMenu, editMenu]
const template: Electron.MenuItemConstructorOptions[] = [firstMenu, buildEditMenu()]

// TODO: this doesn't work because the state is not updated when the user logs in
if (state.loggedIn) {
template.push(walletMenu)
if (menuState.loggedIn) {
template.push(buildWalletMenu())
}

template.push(helpMenu)
template.push(buildHelpMenu())

return template
}

function getFirstSubmenuItems(): Electron.MenuItemConstructorOptions[] {
let menuItems: Electron.MenuItemConstructorOptions[] = [
{
label: `${state.strings.about} ${app.name}`,
label: `${menuState.strings.about} ${app.name}`,
click: AboutWindow.open,
enabled: state.enabled,
enabled: menuState.enabled,
},
commandMenuItem(
`${state.strings.checkForUpdates}...`,
`${menuState.strings.checkForUpdates}...`,
'menu-check-for-update',
app.isPackaged && state.enabled
app.isPackaged && menuState.enabled
),
]
if (features?.electron?.importFromThirdParty?.enabled) {
menuItems.push(commandMenuItem(state.strings.importThirdPartyProfiles, 'import-third-party-profile'))
menuItems.push(commandMenuItem(menuState.strings.importThirdPartyProfiles, 'import-third-party-profile'))
}
menuItems = [
...menuItems,
{ type: 'separator' },
commandMenuItem(state.strings.settings, 'menu-navigate-settings'),
commandMenuItem(menuState.strings.settings, 'menu-navigate-settings'),
{ type: 'separator' },
commandMenuItem(state.strings.diagnostics, 'menu-diagnostics'),
commandMenuItem(menuState.strings.diagnostics, 'menu-diagnostics'),
]
return menuItems
}

function getDarwinSubmenuItems(): Electron.MenuItemConstructorOptions[] {
return [
roleMenuItem(`${state.strings.hide} ${app.name}`, 'hide'),
roleMenuItem(state.strings.hideOthers, 'hideOthers'),
roleMenuItem(state.strings.showAll, 'unhide'),
roleMenuItem(`${menuState.strings.hide} ${app.name}`, 'hide'),
roleMenuItem(menuState.strings.hideOthers, 'hideOthers'),
roleMenuItem(menuState.strings.showAll, 'unhide'),
]
}
24 changes: 13 additions & 11 deletions packages/desktop/lib/electron/menus/wallet.menu.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { getOrInitWindow } from '../processes/main.process'
import { MENU_STATE } from './menu-state.constant'
import { menuState } from './menu'

export const walletMenu: Electron.MenuItemConstructorOptions = {
label: MENU_STATE.strings.wallet,
submenu: [
{ type: 'separator' },
{
label: MENU_STATE.strings.logout,
click: (): void => getOrInitWindow('main').webContents.send('menu-logout'),
enabled: MENU_STATE.enabled,
},
],
export function buildWalletMenu(): Electron.MenuItemConstructorOptions {
return {
label: menuState.strings.wallet,
submenu: [
{ type: 'separator' },
{
label: menuState.strings.logout,
click: (): void => getOrInitWindow('main').webContents.send('menu-logout'),
enabled: menuState.enabled,
},
],
}
}
2 changes: 2 additions & 0 deletions packages/desktop/lib/electron/processes/main.process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ initialiseDeepLinks()
// @ts-expect-error
app.setAppUserModelId(APP_ID)

app.disableHardwareAcceleration()

/**
* Terminate application if Node remote debugging detected
*/
Expand Down
39 changes: 20 additions & 19 deletions packages/desktop/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,34 @@ import { appVersionDetails } from '@core/app/stores'
*/
export const getLocalisedMenuItems = (): unknown => ({
about: localize('views.settings.about.title'),
checkForUpdates: localize('actions.checkForUpdates'),
importThirdPartyProfiles: localize('actions.importThirdPartyProfiles'),
settings: localize('views.settings.settings'),
security: localize('views.settings.security.title'),
addAccount: localize('actions.addAccount'),
advanced: localize('views.settings.advanced.title'),
errorLog: localize('views.settings.errorLog.title'),
checkForUpdates: localize('actions.checkForUpdates'),
copy: localize('actions.copy'),
cut: localize('actions.cut'),
developerTools: localize('general.developerTools'),
diagnostics: localize('views.settings.diagnostics.title'),
logout: localize('views.dashboard.profileMenu.logout'),
discord: localize('views.settings.discord.title'),
documentation: localize('views.settings.documentation.title'),
edit: localize('actions.edit'),
errorLog: localize('views.settings.errorLog.title'),
faq: localize('views.settings.faq.title'),
help: localize('general.help'),
hide: localize('actions.hide'),
hideOthers: localize('actions.hideOthers'),
showAll: localize('actions.showAll'),
importThirdPartyProfiles: localize('actions.importThirdPartyProfiles'),
logout: localize('views.dashboard.profileMenu.logout'),
paste: localize('actions.paste'),
quit: localize('actions.quit'),
edit: localize('actions.edit'),
undo: localize('actions.undo'),
redo: localize('actions.redo'),
cut: localize('actions.cut'),
copy: localize('actions.copy'),
paste: localize('actions.paste'),
selectAll: localize('actions.selectAll'),
wallet: localize('general.wallet'),
addAccount: localize('actions.addAccount'),
help: localize('general.help'),
faq: localize('views.settings.faq.title'),
documentation: localize('views.settings.documentation.title'),
discord: localize('views.settings.discord.title'),
reportAnIssue: localize('actions.reportAnIssue'),
security: localize('views.settings.security.title'),
selectAll: localize('actions.selectAll'),
settings: localize('views.settings.settings'),
showAll: localize('actions.showAll'),
undo: localize('actions.undo'),
version: localize('general.versionFull'),
wallet: localize('general.wallet'),
})

export function registerMenuButtons(): void {
Expand Down
9 changes: 1 addition & 8 deletions packages/shared/src/components/QR.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
foreground: color,
level: 'L',
padding: 0,
size: 200, // if this value is changed, the image gets some weird padding. Therefore we need to do the sizing with css
size: 135,
value: data,
})
Expand All @@ -36,10 +36,3 @@
<div class="flex justify-center items-center">
<img src={image} alt={data} class="qr-code" />
</div>

<style lang="scss">
.qr-code {
width: 96px;
height: 96px;
}
</style>

0 comments on commit 097fb90

Please sign in to comment.