Skip to content

Commit 4a69eb9

Browse files
authored
Merge pull request #915 from SlideRuleEarth/carlos-dev4
in version v2.11.0 the records view can hang #913
2 parents 8837feb + 478dfb5 commit 4a69eb9

File tree

4 files changed

+28
-15
lines changed

4 files changed

+28
-15
lines changed

web-client/src/db/SlideRuleDb.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ export class SlideRuleDexie extends Dexie {
10661066
reqId: req_id,
10671067
error: parseError instanceof Error ? parseError.message : String(parseError)
10681068
})
1069-
return {} as SrRegion
1069+
return []
10701070
}
10711071

10721072
if (svrParmsUsed.server) {
@@ -1084,7 +1084,7 @@ export class SlideRuleDexie extends Dexie {
10841084
status: request?.status
10851085
})
10861086
}
1087-
return {} as SrRegion
1087+
return []
10881088
}
10891089
} else if (svrParmsUsed.poly) {
10901090
return svrParmsUsed.poly //atl24x with new server format
@@ -1094,15 +1094,15 @@ export class SlideRuleDexie extends Dexie {
10941094
} else {
10951095
logger.warn('No svr_parms.poly found', { reqId: req_id, status: request?.status })
10961096
}
1097-
return {} as SrRegion
1097+
return []
10981098
}
10991099
} else {
11001100
if (isSuccess) {
11011101
logger.error('No svr_parms found', { reqId: req_id, status: request?.status })
11021102
} else {
11031103
logger.warn('No svr_parms found', { reqId: req_id, status: request?.status })
11041104
}
1105-
return {} as SrRegion
1105+
return []
11061106
}
11071107
} catch (error) {
11081108
const request = await this.requests.get(req_id)

web-client/src/utils/SrDuckDbUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,6 @@ export const duckDbReadAndUpdateElevationData = async (
922922
updateDeckLayerWithObject(
923923
layerName,
924924
rows,
925-
summary.extHMean,
926925
height_fieldname,
927926
positions,
928927
projName,
@@ -1129,7 +1128,6 @@ export const duckDbReadAndUpdateSelectedLayer = async (req_id: number, layerName
11291128
updateDeckLayerWithObject(
11301129
layerName,
11311130
rowChunks,
1132-
summary.extHMean,
11331131
height_fieldname,
11341132
positions,
11351133
projName,

web-client/src/utils/SrMapUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import Graticule from 'ol/layer/Graticule.js'
1313
import type OLMap from 'ol/Map.js'
1414
import { unByKey } from 'ol/Observable'
1515
import type { EventsKey } from 'ol/events'
16-
import type { ExtHMean } from '@/workers/workerUtils'
1716
import { Style, Icon, Fill, Stroke, Circle as CircleStyle } from 'ol/style'
1817
import { Text as TextStyle } from 'ol/style'
1918
import { getSpotNumber, getGtsForSpotsAndScOrients } from '@/utils/spotUtils'
@@ -872,7 +871,6 @@ export function createDeckLayer(
872871
export function updateDeckLayerWithObject(
873872
name: string,
874873
elevationData: ElevationDataItem[],
875-
extHMean: ExtHMean,
876874
heightFieldName: string,
877875
positions: SrPosition[],
878876
_projName: string,

web-client/tests/unit/SlideRuleDb.spec.ts

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,35 +122,52 @@ describe('SlideRuleDb.getSvrReqPoly', () => {
122122
expect(result).toEqual(samplePoly)
123123
})
124124

125-
it('should return empty object when svr_parms is empty', async () => {
125+
it('should return empty array when svr_parms is empty', async () => {
126126
mockRequest.svr_parms = undefined
127127

128128
vi.spyOn(db.requests, 'get').mockResolvedValue(mockRequest)
129129

130130
const result = await db.getSvrReqPoly(123)
131131

132-
expect(result).toEqual({})
132+
expect(result).toEqual([])
133+
expect(Array.isArray(result)).toBe(true)
133134
})
134135

135-
it('should return empty object when svr_parms has no poly', async () => {
136+
it('should return empty array when svr_parms has no poly', async () => {
136137
mockRequest.svr_parms = { someOtherField: 'value' } as any
137138

138139
vi.spyOn(db.requests, 'get').mockResolvedValue(mockRequest)
139140

140141
const result = await db.getSvrReqPoly(123)
141142

142-
expect(result).toEqual({})
143+
expect(result).toEqual([])
144+
expect(Array.isArray(result)).toBe(true)
143145
})
144146

145-
it('should return empty object for invalid JSON string', async () => {
147+
it('should return empty array for invalid JSON string', async () => {
146148
mockRequest.svr_parms = 'not valid json{' as any
147149

148150
vi.spyOn(db.requests, 'get').mockResolvedValue(mockRequest)
149151

150152
const result = await db.getSvrReqPoly(123)
151153

152-
// Should return empty object instead of throwing
153-
expect(result).toEqual({})
154+
// Should return empty array instead of throwing
155+
expect(result).toEqual([])
156+
expect(Array.isArray(result)).toBe(true)
157+
})
158+
159+
it('should return a value that supports .map() even when empty', async () => {
160+
// This is a regression test for the bug where {} was returned instead of []
161+
// which caused "t.map is not a function" errors when code tried to use .map()
162+
mockRequest.svr_parms = undefined
163+
164+
vi.spyOn(db.requests, 'get').mockResolvedValue(mockRequest)
165+
166+
const result = await db.getSvrReqPoly(123)
167+
168+
// This is the key test - .map() should work without crashing
169+
expect(() => result.map((p) => [p.lon, p.lat])).not.toThrow()
170+
expect(result.map((p) => [p.lon, p.lat])).toEqual([])
154171
})
155172

156173
it('should handle nested server.rqst.parms structure with string input', async () => {

0 commit comments

Comments
 (0)