mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
fix: Add omitempty for proper latency type (#3850)
This was causing an error on the frontend, because this value can be nil!
This commit is contained in:
@ -59,7 +59,7 @@ type WorkspaceAgent struct {
|
||||
Version string `json:"version"`
|
||||
Apps []WorkspaceApp `json:"apps"`
|
||||
// DERPLatency is mapped by region name (e.g. "New York City", "Seattle").
|
||||
DERPLatency map[string]DERPRegion `json:"latency"`
|
||||
DERPLatency map[string]DERPRegion `json:"latency,omitempty"`
|
||||
}
|
||||
|
||||
type WorkspaceAgentResourceMetadata struct {
|
||||
|
@ -536,7 +536,7 @@ export interface WorkspaceAgent {
|
||||
readonly directory?: string
|
||||
readonly version: string
|
||||
readonly apps: WorkspaceApp[]
|
||||
readonly latency: Record<string, DERPRegion>
|
||||
readonly latency?: Record<string, DERPRegion>
|
||||
}
|
||||
|
||||
// From codersdk/workspaceagents.go
|
||||
|
@ -10,9 +10,13 @@ export interface ResourceAgentLatencyProps {
|
||||
|
||||
export const ResourceAgentLatency: React.FC<ResourceAgentLatencyProps> = (props) => {
|
||||
const styles = useStyles()
|
||||
if (!props.latency) {
|
||||
return null
|
||||
}
|
||||
if (Object.keys(props.latency).length === 0) {
|
||||
return null
|
||||
}
|
||||
const latency = props.latency
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<div className={styles.title}>
|
||||
@ -24,10 +28,10 @@ export const ResourceAgentLatency: React.FC<ResourceAgentLatencyProps> = (props)
|
||||
</HelpTooltipText>
|
||||
</HelpTooltip>
|
||||
</div>
|
||||
{Object.keys(props.latency)
|
||||
{Object.keys(latency)
|
||||
.sort()
|
||||
.map((region) => {
|
||||
const value = props.latency[region]
|
||||
const value = latency[region]
|
||||
return (
|
||||
<div key={region} className={styles.region}>
|
||||
<b>{region}:</b> {Math.round(value.latency_ms * 100) / 100} ms
|
||||
|
Reference in New Issue
Block a user