@@ -84,6 +84,8 @@ const QuickTools = ({ isMiscSlide }) => {
84
84
let payload ;
85
85
let actionName ;
86
86
let stateName ;
87
+ const maxFontSize = 20 ;
88
+ const minFontSize = 1 ;
87
89
88
90
if ( index > 0 ) {
89
91
stateName = `content${ index } ${ action } ` ;
@@ -93,13 +95,21 @@ const QuickTools = ({ isMiscSlide }) => {
93
95
actionName = `set${ convertToCamelCase ( `${ toolname } -${ action } ` , true ) } ` ;
94
96
}
95
97
98
+ const currentFontSize = parseInt ( userSettings [ stateName ] , 10 ) ;
99
+
96
100
if ( name === 'visibility' ) {
97
101
payload = ! userSettings [ stateName ] ;
98
102
} else if ( name === 'minus' ) {
99
- payload = parseInt ( userSettings [ stateName ] , 10 ) - 1 ;
103
+ payload = currentFontSize > minFontSize ? currentFontSize - 1 : minFontSize ;
100
104
} 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 ;
102
111
}
112
+
103
113
return {
104
114
actionName,
105
115
payload,
@@ -126,10 +136,10 @@ const QuickTools = ({ isMiscSlide }) => {
126
136
< i
127
137
className = { getIconClassName ( name , index , actionName ) }
128
138
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
+ }
133
143
} }
134
144
/>
135
145
</ div >
0 commit comments