From 9853358414a2e2d7a815c887d10dc6e86e21c92d Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Fri, 31 May 2024 06:17:22 -0700 Subject: [PATCH 1/2] Restoring from mini mode doesn't work on Windows Fixes #79 --- src/index.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index bb1b13f..dcb7277 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,16 +60,22 @@ const setAudioSettings = () => { }; const toggleMiniMode = () => { - if ( - mainWindow.getSize()[0] == mainWindow.getMinimumSize()[0] && - mainWindow.getSize()[1] == mainWindow.getMinimumSize()[1] - ) { + // Issue 79: Use the size of the content and the width breakpoint for mini-mode + // to determine whether to restore from mini-mode. This solves an issue where + // getSize() was returning a width value off by one from the getMinSize() + // call. + if (mainWindow.getContentSize()[0] <= 300) { mainWindow.setSize(savedLastWindowSize.width, savedLastWindowSize.height); return; } savedLastWindowSize.width = mainWindow.getSize()[0]; savedLastWindowSize.height = mainWindow.getSize()[1]; - mainWindow.setSize(1, 1); + + // Issue 79: Use the width breakpoint for the width instead of setting to 1 + // so the window doesn't go as small as possible when put in mini-mode. This + // makes toggling work properly when using 300 as the value for determining when + // to switch to big mode. + mainWindow.setSize(300, 1); }; const restoreWindowBounds = (win: BrowserWindow) => { From 47250d129208637bd580810ac5993ae8e70b8bcf Mon Sep 17 00:00:00 2001 From: Neil Enns Date: Fri, 31 May 2024 06:20:34 -0700 Subject: [PATCH 2/2] Add code comments --- src/app/style/app.scss | 6 ++++++ src/index.ts | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/style/app.scss b/src/app/style/app.scss index 4727f6e..bb3a457 100644 --- a/src/app/style/app.scss +++ b/src/app/style/app.scss @@ -238,6 +238,8 @@ button:disabled { padding-right: 0; } +// When changing the max-width property make sure to update the miniModeWidthBreakpoint constant in +// the toggleMiniMode method in index.ts as well. @media only screen and (max-width: 300px) { .freq-box { display: none; @@ -383,12 +385,16 @@ select:disabled { font-size: $mini-font-size; } +// When changing the max-width property make sure to update the miniModeWidthBreakpoint constant in +// the toggleMiniMode method in index.ts as well. @media only screen and (max-width: 300px) { .mini { display: block; } } +// When changing the max-width property make sure to update the miniModeWidthBreakpoint constant in +// the toggleMiniMode method in index.ts as well. @media only screen and (max-width: 300px) { .hide-topbar { display: none !important; diff --git a/src/index.ts b/src/index.ts index dcb7277..2b0521c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -60,11 +60,13 @@ const setAudioSettings = () => { }; const toggleMiniMode = () => { + const miniModeWidthBreakpoint = 300; + // Issue 79: Use the size of the content and the width breakpoint for mini-mode // to determine whether to restore from mini-mode. This solves an issue where // getSize() was returning a width value off by one from the getMinSize() // call. - if (mainWindow.getContentSize()[0] <= 300) { + if (mainWindow.getContentSize()[0] <= miniModeWidthBreakpoint) { mainWindow.setSize(savedLastWindowSize.width, savedLastWindowSize.height); return; } @@ -75,7 +77,7 @@ const toggleMiniMode = () => { // so the window doesn't go as small as possible when put in mini-mode. This // makes toggling work properly when using 300 as the value for determining when // to switch to big mode. - mainWindow.setSize(300, 1); + mainWindow.setSize(miniModeWidthBreakpoint, 1); }; const restoreWindowBounds = (win: BrowserWindow) => {