Skip to content

Commit

Permalink
Fix errors in packetviewer when there's no target/packet set
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-pratt committed Jan 2, 2025
1 parent 4b7d72c commit 20aaa1f
Showing 1 changed file with 42 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -491,31 +491,49 @@ export default {
}
},
packetChanged(event) {
this.api.get_target(event.targetName).then((target) => {
this.ignoredItems = target.ignored_items
})
this.api
.get_packet_derived_items(event.targetName, event.packetName)
.then((derived) => {
this.derivedItems = derived
.get_target(event.targetName)
.then((target) => {
if (target) {
this.ignoredItems = target.ignored_items

return this.api.get_packet_derived_items(
event.targetName,
event.packetName,
)
} else {
// Probably got here from an old config or URL params that point to something that no longer exists
// (e.g. the plugin that defined this target was deleted). Unset these to avoid API errors.
this.targetName = null
this.packetName = null
this.$router.push({
name: 'PackerViewer',
params: {},
})
}
})
.then((derived) => {
if (derived) {
this.derivedItems = derived

this.targetName = event.targetName
this.packetName = event.packetName
if (
this.$route.params.target !== event.targetName ||
this.$route.params.packet !== event.packetName
) {
this.saveDefaultConfig(this.currentConfig)
this.$router.push({
name: 'PackerViewer',
params: {
target: this.targetName,
packet: this.packetName,
},
this.targetName = event.targetName
this.packetName = event.packetName
if (
this.$route.params.target !== event.targetName ||
this.$route.params.packet !== event.packetName
) {
this.saveDefaultConfig(this.currentConfig)
this.$router.push({
name: 'PackerViewer',
params: {
target: this.targetName,
packet: this.packetName,
},
})
}
this.changeUpdater(true)
}
})
}
this.changeUpdater(true)
},
changeUpdater(clearExisting) {
if (this.updater != null) {
Expand All @@ -526,6 +544,9 @@ export default {
this.rows = []
}
this.updater = setInterval(() => {
if (!this.targetName || !this.packetName) {
return // noop if target/packet aren't set
}
this.api
.get_tlm_packet(
this.targetName,
Expand Down

0 comments on commit 20aaa1f

Please sign in to comment.