Skip to content

Commit 2847307

Browse files
committed
Handle quantile check better, remove unneeded asyncs, rename
1 parent ea1f119 commit 2847307

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

packages/base/src/dialogs/components/symbology/SingleBandPseudoColor.tsx

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ const SingleBandPseudoColor = ({
8080
const stateDb = GlobalStateDbManager.getInstance().getStateDb();
8181

8282
useEffect(() => {
83-
setInitialFunction();
83+
populateOptions();
8484

8585
okSignalPromise.promise.then(okSignal => {
8686
okSignal.connect(handleOk);
@@ -93,23 +93,23 @@ const SingleBandPseudoColor = ({
9393
};
9494
}, []);
9595

96-
useEffect(() => {
97-
bandRowsRef.current = bandRows;
98-
buildColorInfo();
99-
}, [bandRows]);
100-
10196
useEffect(() => {
10297
layerStateRef.current = layerState;
10398
getBandInfo();
10499
}, [layerState]);
105100

101+
useEffect(() => {
102+
bandRowsRef.current = bandRows;
103+
buildColorInfo();
104+
}, [bandRows]);
105+
106106
useEffect(() => {
107107
stopRowsRef.current = stopRows;
108108
selectedFunctionRef.current = selectedFunction;
109109
colorRampOptionsRef.current = colorRampOptions;
110110
}, [stopRows, selectedFunction, colorRampOptions]);
111111

112-
const setInitialFunction = async () => {
112+
const populateOptions = async () => {
113113
const layerState = (await stateDb?.fetch(
114114
`jupytergis:${layerId}`
115115
)) as ReadonlyJSONObject;
@@ -137,7 +137,7 @@ const SingleBandPseudoColor = ({
137137
: setSelectedFunction('exact');
138138
};
139139

140-
const getBandInfo = async () => {
140+
const getBandInfo = () => {
141141
const bandsArr: IBandRow[] = [];
142142
const source = context.model.getSource(layer?.parameters?.source);
143143
const sourceInfo = source?.parameters?.urls[0];
@@ -167,7 +167,7 @@ const SingleBandPseudoColor = ({
167167
}
168168
};
169169

170-
const buildColorInfo = async () => {
170+
const buildColorInfo = () => {
171171
// This it to parse a color object on the layer
172172
if (!layer.parameters?.color || !layerState) {
173173
return;
@@ -180,9 +180,7 @@ const SingleBandPseudoColor = ({
180180
return;
181181
}
182182

183-
const isQuantile =
184-
((layerState as ReadonlyJSONObject).selectedMode as string) ===
185-
'quantile';
183+
const isQuantile = (layerState.selectedMode as string) === 'quantile';
186184

187185
const valueColorPairs: IStopRow[] = [];
188186

@@ -226,7 +224,7 @@ const SingleBandPseudoColor = ({
226224
setStopRows(valueColorPairs);
227225
};
228226

229-
const handleOk = async () => {
227+
const handleOk = () => {
230228
// Update source
231229
const bandRow = bandRowsRef.current[selectedBand - 1];
232230
if (!bandRow) {
@@ -239,9 +237,7 @@ const SingleBandPseudoColor = ({
239237
return;
240238
}
241239

242-
const isQuantile = layerStateRef.current
243-
? (layerStateRef.current.selectedMode as string) === 'quantile'
244-
: false;
240+
const isQuantile = colorRampOptionsRef.current?.selectedMode === 'quantile';
245241

246242
stateDb?.save(`jupytergis:${layerId}`, {
247243
...layerStateRef.current,

0 commit comments

Comments
 (0)