Skip to content

Commit

Permalink
Showing correct tools window #207
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Apr 27, 2022
1 parent ba951ef commit 5e89ed0
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 65 deletions.
2 changes: 1 addition & 1 deletion app/application/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ const provideFeedback = () => {
}

const importPage = () => {
ipc.send("toggleImport")
ipc.invoke("toggleToolsWindow")
}

const settingsPage = () => {
Expand Down
8 changes: 2 additions & 6 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,9 @@ let close_tray_state = settings.settings.close_to_tray
if (close_tray_state === true) {
tgt1.textContent = "On"
tgl1.checked = true

ipc.send("enableTray")
} else {
tgt1.textContent = "Off"
tgl1.checked = false

ipc.send("disableTray")
}

// codes description
Expand Down Expand Up @@ -245,7 +241,7 @@ const closeTray = () => {
tgt1.textContent = "Off"
close_tray_state = false

ipc.send("disableTray")
ipc.invoke("saveWindowPosition")
} else {
settings.settings.close_to_tray = true

Expand All @@ -254,7 +250,7 @@ const closeTray = () => {
tgt1.textContent = "On"
close_tray_state = true

ipc.send("enableTray")
ipc.invoke("saveWindowPosition")
}
}

Expand Down
109 changes: 51 additions & 58 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ let tools_shown = false
*/
let authenticated = false
let shortcuts = false
let tray_minimized = false
let update_seen = false
let manual_update = false
let password_buffer = null
Expand Down Expand Up @@ -396,8 +395,6 @@ const saveWindowPosition = () => {
* Create application windows
*/
const createWindows = () => {
logger.log("Started creating windows")

/* Set language */
lang = en
let locale = "en"
Expand Down Expand Up @@ -515,7 +512,7 @@ const createWindows = () => {
})

window_settings = new BrowserWindow({
title: "Authme Settings",
title: "Authme (Settings)",
x: settings.window.x,
y: settings.window.y,
width: 1900,
Expand All @@ -539,7 +536,7 @@ const createWindows = () => {
})

window_tools = new BrowserWindow({
title: "Authme Import",
title: "Authme (Import)",
x: settings.window.x,
y: settings.window.y,
width: 1900,
Expand Down Expand Up @@ -604,7 +601,7 @@ const createWindows = () => {
if (dev === true) {
app.quit()
} else {
if (tray_minimized === false) {
if (settings.settings.close_to_tray === false) {
try {
password_buffer.fill(0)
} catch (error) {}
Expand Down Expand Up @@ -848,7 +845,7 @@ const createWindows = () => {
*/
app.whenReady()
.then(() => {
logger.log("Starting app")
logger.log("App starting")

process.on("uncaughtException", async (error) => {
logger.error("Error occurred while starting", error.stack)
Expand Down Expand Up @@ -964,6 +961,8 @@ app.whenReady()
}
})
}

logger.log("App finished loading")
})
.catch((error) => {
logger.error("Error occurred while starting", error.stack)
Expand Down Expand Up @@ -1207,24 +1206,6 @@ ipc.on("enableWindowCapture", () => {
logger.log("Screen capture enabled")
})

/**
* Disable close to tray
*/
ipc.on("disableTray", () => {
tray_minimized = false

logger.log("Close to tray disabled")
})

/**
* Enable close to tray
*/
ipc.on("enableTray", () => {
tray_minimized = true

logger.log("Close to tray enabled")
})

/**
* Set logs path
*/
Expand Down Expand Up @@ -1693,27 +1674,31 @@ const createMenu = () => {
accelerator: shortcuts ? "" : settings.shortcuts.edit,
click: () => {
const toggle = () => {
if (tools_shown === false) {
if (window_tools.getTitle() !== "Authme Edit codes") {
window_tools.loadFile("./app/edit/index.html")
}

if (window_tools.getTitle() !== "Authme (Edit codes)") {
window_tools.loadFile("./app/edit/index.html")
window_tools.setTitle("Authme Edit codes")

window_tools.maximize()
window_tools.show()

tools_shown = true

logger.log("Edit shown")
} else {
window_tools.hide()
if (tools_shown === false) {
window_tools.maximize()
window_tools.show()

window_application.focus()
tools_shown = true

logger.log("Edit shown")
} else {
window_tools.hide()

tools_shown = false
window_application.focus()

logger.log("Edit hidden")
tools_shown = false

logger.log("Edit hidden")
}
}
}

Expand All @@ -1733,27 +1718,31 @@ const createMenu = () => {
accelerator: shortcuts ? "" : settings.shortcuts.import,
click: () => {
const toggle = () => {
if (tools_shown === false) {
if (window_tools.getTitle() !== "Authme Import") {
window_tools.loadFile("./app/import/index.html")
}

if (window_tools.getTitle() !== "Authme (Import)") {
window_tools.loadFile("./app/import/index.html")
window_tools.setTitle("Authme Import")

window_tools.maximize()
window_tools.show()

tools_shown = true

logger.log("Import shown")
} else {
window_tools.hide()
if (tools_shown === false) {
window_tools.maximize()
window_tools.show()

window_application.focus()
tools_shown = true

logger.log("Import shown")
} else {
window_tools.hide()

window_application.focus()

tools_shown = false
tools_shown = false

logger.log("Import hidden")
logger.log("Import hidden")
}
}
}

Expand All @@ -1773,27 +1762,31 @@ const createMenu = () => {
accelerator: shortcuts ? "" : settings.shortcuts.export,
click: () => {
const toggle = () => {
if (tools_shown === false) {
if (window_tools.getTitle() !== "Authme Export") {
window_tools.loadFile("./app/export/index.html")
}

if (window_tools.getTitle() !== "Authme (Export)") {
window_tools.loadFile("./app/export/index.html")
window_tools.setTitle("Authme Export")

window_tools.maximize()
window_tools.show()

tools_shown = true

logger.log("Export shown")
} else {
window_tools.hide()
if (tools_shown === false) {
window_tools.maximize()
window_tools.show()

window_application.focus()
tools_shown = true

logger.log("Export shown")
} else {
window_tools.hide()

tools_shown = false
window_application.focus()

logger.log("Export hidden")
tools_shown = false

logger.log("Export hidden")
}
}
}

Expand Down

0 comments on commit 5e89ed0

Please sign in to comment.