Skip to content

Commit

Permalink
Simplify code by asking instanced messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Jan 30, 2024
1 parent 279034e commit de53c72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
16 changes: 6 additions & 10 deletions src/components/Plotly.vue
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ export default {
return new Promise((resolve, reject) => {
interval = setInterval(function () {
for (const message of messages) {
if (!_this.loadedMessages().includes(message.split('[')[0])) {
if (!_this.loadedMessages().includes(message)) {
counter += 1
if (counter > 30) { // 30 * 300ms = 9 s timeout
console.log('not resolving')
Expand Down Expand Up @@ -610,7 +610,7 @@ export default {
return [true, '']
}
for (const [message, field] of messages) {
if (!(this.messagesInLog.includes(message.split('[')[0]))) {
if (!(this.messagesInLog.includes(message))) {
console.log('ERROR: attempted to plot unavailable message: ' + message)
this.state.plotLoading = false
if (reask) {
Expand All @@ -634,8 +634,8 @@ export default {
// let fields = expression.name.match(RE)
for (const message of messages) {
if (!(message in this.state.messages) || this.state.messages[message].lenght === 0) {
if (!((message + '[0]') in this.state.messages) ||
this.state.messages[message + '[0]'].lenght === 0) {
if (!((message) in this.state.messages) ||
this.state.messages[message].lenght === 0) {
return false
}
}
Expand Down Expand Up @@ -1069,9 +1069,7 @@ export default {
]
},
loadedMessages () {
return Object.keys(this.state.messages).map(key => {
return key.split('[')[0]
})
return Object.keys(this.state.messages)
}
},
computed: {
Expand All @@ -1094,9 +1092,7 @@ export default {
return this.state.expressions
},
messagesInLog () {
return Object.keys(this.state.messageTypes).map(key => {
return key.split('[')[0]
})
return Object.keys(this.state.messageTypes)
}
},
watch: {
Expand Down
10 changes: 3 additions & 7 deletions src/components/PlotlyPopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default {
return new Promise((resolve, reject) => {
interval = setInterval(function () {
for (const message of messages) {
if (!_this.loadedMessages.includes(message.split('[')[0])) {
if (!_this.loadedMessages.includes(message)) {
counter += 1
if (counter > 30) { // 30 * 300ms = 9 s timeout
console.log('not resolving')
Expand Down Expand Up @@ -513,14 +513,10 @@ export default {
return this.state.expressions
},
loadedMessages () {
return Object.keys(this.state.messages).map(key => {
return key.split('[')[0]
})
return Object.keys(this.state.messages)
},
messagesInLog () {
return Object.keys(this.state.messageTypes).map(key => {
return key.split('[')[0]
})
return Object.keys(this.state.messageTypes)
}
},
watch: {
Expand Down

0 comments on commit de53c72

Please sign in to comment.