Skip to content

Commit e21c201

Browse files
Merge pull request #2002 from yadvirkaur/fsLimit
Limit font size for quick tools
2 parents c606079 + 0e8b638 commit e21c201

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

www/main/viewer/Slide/QuickTools.jsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ const QuickTools = ({ isMiscSlide }) => {
8484
let payload;
8585
let actionName;
8686
let stateName;
87+
const maxFontSize = 20;
88+
const minFontSize = 1;
8789

8890
if (index > 0) {
8991
stateName = `content${index}${action}`;
@@ -93,13 +95,21 @@ const QuickTools = ({ isMiscSlide }) => {
9395
actionName = `set${convertToCamelCase(`${toolname}-${action}`, true)}`;
9496
}
9597

98+
const currentFontSize = parseInt(userSettings[stateName], 10);
99+
96100
if (name === 'visibility') {
97101
payload = !userSettings[stateName];
98102
} else if (name === 'minus') {
99-
payload = parseInt(userSettings[stateName], 10) - 1;
103+
payload = currentFontSize > minFontSize ? currentFontSize - 1 : minFontSize;
100104
} else if (name === 'plus') {
101-
payload = parseInt(userSettings[stateName], 10) + 1;
105+
payload = currentFontSize < maxFontSize ? currentFontSize + 1 : maxFontSize;
106+
}
107+
108+
// If payload does not change, return null to prevent unnecessary state updates
109+
if (payload === userSettings[stateName]) {
110+
return null;
102111
}
112+
103113
return {
104114
actionName,
105115
payload,
@@ -126,10 +136,10 @@ const QuickTools = ({ isMiscSlide }) => {
126136
<i
127137
className={getIconClassName(name, index, actionName)}
128138
onClick={() => {
129-
global.platform.ipc.send(
130-
'update-global-setting',
131-
JSON.stringify(createGlobalPlatformObj(name, toolName, index, actionName)),
132-
);
139+
const globalObj = createGlobalPlatformObj(name, toolName, index, actionName);
140+
if (globalObj) {
141+
global.platform.ipc.send('update-global-setting', JSON.stringify(globalObj));
142+
}
133143
}}
134144
/>
135145
</div>

0 commit comments

Comments
 (0)