Skip to content

Commit

Permalink
Merge pull request #2002 from yadvirkaur/fsLimit
Browse files Browse the repository at this point in the history
Limit font size for quick tools
  • Loading branch information
Gauravjeetsingh authored Aug 5, 2024
2 parents c606079 + 0e8b638 commit e21c201
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions www/main/viewer/Slide/QuickTools.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const QuickTools = ({ isMiscSlide }) => {
let payload;
let actionName;
let stateName;
const maxFontSize = 20;
const minFontSize = 1;

if (index > 0) {
stateName = `content${index}${action}`;
Expand All @@ -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,
Expand All @@ -126,10 +136,10 @@ const QuickTools = ({ isMiscSlide }) => {
<i
className={getIconClassName(name, index, actionName)}
onClick={() => {
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));
}
}}
/>
</div>
Expand Down

0 comments on commit e21c201

Please sign in to comment.