Skip to content

Commit 2f234d0

Browse files
committed
Refactor compression mode handling in Compression.js
- Removed the updateCompressionMode function to streamline state management. - Moved the logic for setting compression mode directly into the existing update function. - Ensured that the canSave state is updated appropriately when changing compression modes.
1 parent 6c72ed0 commit 2f234d0

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

assets/src/dashboard/parts/connected/settings/Compression.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,7 @@ const Compression = ({
110110
data.quality = value;
111111
setSettings( data );
112112
};
113-
const updateCompressionMode = ( value ) => {
114-
setCanSave( true );
115-
const data = { ...settings };
116-
data.compression_mode = value;
117-
setSettings( data );
118-
};
113+
119114
const getCompressionRatio = () => {
120115
if ( sampleImages.optimized_size > sampleImages.original_size ) {
121116
return Math.floor( Math.random() * 60 ) + 10;
@@ -141,7 +136,7 @@ const Compression = ({
141136
//If user already changed those before, we need to save them so if he switch back to custom, we can use the old settings
142137
saveCustomSettings();
143138
}
144-
139+
setCanSave( true );
145140
const data = { ...settings };
146141
if ( 'speed_optimized' === value ) {
147142
data[ 'best_format' ] = 'disabled';
@@ -165,9 +160,8 @@ const Compression = ({
165160
data.avif = ( customSettings.avif ?? isAVIFEnabled ) ? 'enabled' : 'disabled';
166161
data[ 'strip_metadata' ] = ( customSettings.strip_metadata ?? isStripMetadataEnabled ) ? 'enabled' : 'disabled';
167162
}
163+
data.compression_mode = value;
168164
setSettings( data );
169-
updateCompressionMode( value );
170-
171165
};
172166
return (
173167
<>

0 commit comments

Comments
 (0)