Skip to content

Commit

Permalink
Refresh menu #159
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Dec 11, 2021
1 parent 88021a7 commit e78dead
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 10 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,7 +1444,7 @@ app.whenReady()
dialog
.showMessageBox({
title: "Authme",
buttons: ["Report", "Close"],
buttons: ["Report", "Close", "Exit"],
defaultId: 0,
cancelId: 1,
noLink: true,
Expand All @@ -1454,7 +1454,7 @@ app.whenReady()
.then((result) => {
if (result.response === 0) {
shell.openExternal("https://github.com/Levminer/authme/issues/")
} else if (result.response === 1) {
} else if (result.response === 2) {
app.exit()
}
})
Expand Down Expand Up @@ -1586,6 +1586,14 @@ const createTray = () => {
* Create application menu
*/
const createMenu = () => {
if (window_application !== undefined) {
window_application.webContents.send("refreshMenu")
window_settings.webContents.send("refreshMenu")
window_import.webContents.send("refreshMenu")
window_export.webContents.send("refreshMenu")
window_edit.webContents.send("refreshMenu")
}

const template = [
{
label: "File",
Expand Down
12 changes: 11 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { app, Menu, getCurrentWindow } = require("@electron/remote")
const Titlebar = require("@6c65726f79/custom-titlebar")
const { ipcRenderer: ipc } = require("electron")
const path = require("path")
const fs = require("fs")
const ipc = electron.ipcRenderer

/**
* Check if running in development
Expand Down Expand Up @@ -98,3 +98,13 @@ if (process.platform === "win32") {
backgroundColor: "#000000",
icon: "../../img/icon.png",
unfocusEffect: false,
})
})
}

/**
* Refresh title bar
*/
ipc.on("refreshMenu", () => {
titlebar.updateMenu(Menu.getApplicationMenu())
})

0 comments on commit e78dead

Please sign in to comment.