From 20e7166bfda810c2356d0efda7a83554efebdc2d Mon Sep 17 00:00:00 2001 From: Yadvir Kaur Date: Fri, 19 Jul 2024 15:09:16 +0530 Subject: [PATCH 1/2] Limit font size for quick tools --- www/main/viewer/Slide/QuickTools.jsx | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/www/main/viewer/Slide/QuickTools.jsx b/www/main/viewer/Slide/QuickTools.jsx index 4e3b761a..4fb55922 100644 --- a/www/main/viewer/Slide/QuickTools.jsx +++ b/www/main/viewer/Slide/QuickTools.jsx @@ -84,6 +84,8 @@ const QuickTools = ({ isMiscSlide }) => { let payload; let actionName; let stateName; + const maxFontSize = 30; + const minFontSize = 1; if (index > 0) { stateName = `content${index}${action}`; @@ -93,13 +95,21 @@ const QuickTools = ({ isMiscSlide }) => { actionName = `set${convertToCamelCase(`${toolname}-${action}`, true)}`; } + const currentFontSize = parseInt(userSettings[stateName], 10); + if (name === 'visibility') { payload = !userSettings[stateName]; } else if (name === 'minus') { - payload = parseInt(userSettings[stateName], 10) - 1; + payload = currentFontSize > minFontSize ? currentFontSize - 1 : minFontSize; } else if (name === 'plus') { - payload = parseInt(userSettings[stateName], 10) + 1; + payload = currentFontSize < maxFontSize ? currentFontSize + 1 : maxFontSize; + } + + // If payload does not change, return null to prevent unnecessary state updates + if (payload === userSettings[stateName]) { + return null; } + return { actionName, payload, @@ -126,10 +136,10 @@ const QuickTools = ({ isMiscSlide }) => { { - global.platform.ipc.send( - 'update-global-setting', - JSON.stringify(createGlobalPlatformObj(name, toolName, index, actionName)), - ); + const globalObj = createGlobalPlatformObj(name, toolName, index, actionName); + if (globalObj) { + global.platform.ipc.send('update-global-setting', JSON.stringify(globalObj)); + } }} /> From 0e8b63865dd634de45f7f7762cfa219f5a274a34 Mon Sep 17 00:00:00 2001 From: Yadvir Kaur Date: Mon, 5 Aug 2024 11:36:51 +0530 Subject: [PATCH 2/2] minnor change for font size limit inside quick tools --- www/main/viewer/Slide/QuickTools.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/main/viewer/Slide/QuickTools.jsx b/www/main/viewer/Slide/QuickTools.jsx index 4fb55922..c444579e 100644 --- a/www/main/viewer/Slide/QuickTools.jsx +++ b/www/main/viewer/Slide/QuickTools.jsx @@ -84,7 +84,7 @@ const QuickTools = ({ isMiscSlide }) => { let payload; let actionName; let stateName; - const maxFontSize = 30; + const maxFontSize = 20; const minFontSize = 1; if (index > 0) {