Skip to content

Commit

Permalink
Merge pull request #1301 from FlowFuse/747_fix-ws-reactivity-caused-b…
Browse files Browse the repository at this point in the history
…y-incorrect-component-lifecycle-mount-order

Alter alert subscription causing the vue application to silently crash
  • Loading branch information
joepavitt authored Sep 17, 2024
2 parents 40d360a + 9bcbfdd commit 7ed2420
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
23 changes: 13 additions & 10 deletions ui/src/layouts/Baseline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<ui-notification
id="ui-inline-alert" ref="alert"
:props="{position: 'top right', showCountdown: alert.showCountdown, displayTime: alert.displayTime, raw: true, allowDismiss: alert.allowDismiss}"
@mounted="subscribeAlerts"
/>
</div>
</v-main>
Expand Down Expand Up @@ -187,18 +188,20 @@ export default {
},
mounted () {
this.updateTheme()
Alerts.subscribe((title, description, color, alertOptions) => {
this.$refs.alert.close()
this.alert = alertOptions
this.$nextTick(() => {
this.$refs.alert.onMsgInput({
payload: `<h3>${title}</h3><p>${description}</p>`,
color
})
})
})
},
methods: {
subscribeAlerts (context) {
Alerts.subscribe((title, description, color, alertOptions) => {
context.close()
this.alert = alertOptions
this.$nextTick(() => {
context.onMsgInput({
payload: `<h3>${title}</h3><p>${description}</p>`,
color
})
})
})
},
go: function (name) {
this.$router.push({
name
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fetch('_setup')
}
// tell the user we're trying to connect
Alerts.emit('Connection Lost', 'Attempting to reconnect to server...', 'red', {
displayTime: 0,
displayTime: 0, // displayTime 0 persists notifications until another notification closes it
allowDismiss: false,
showCountdown: false
})
Expand Down
4 changes: 4 additions & 0 deletions ui/src/widgets/ui-notification/UINotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
props: { type: Object, default: () => ({}) },
state: { type: Object, default: () => ({}) }
},
emits: ['mounted'],
data () {
return {
show: false,
Expand Down Expand Up @@ -100,6 +101,9 @@ export default {
// can't do this in setup as we have custom onInput function
this.$dataTracker(this.id, this.onMsgInput, null, this.onDynamicProperties)
},
mounted () {
this.$emit('mounted', this)
},
methods: {
onDynamicProperties (msg) {
const updates = msg.ui_update
Expand Down

0 comments on commit 7ed2420

Please sign in to comment.