1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-06-15 00:05:15 +02:00

UI: Automatically refresh connected browsers if Mailpit is upgraded (version change)

This commit is contained in:
Ralph Slooten
2024-01-03 12:54:12 +13:00
parent 12cfb09774
commit dd57596fd1
3 changed files with 19 additions and 5 deletions

View File

@ -15,10 +15,16 @@ export default {
reconnectRefresh: false,
socketURI: false,
pauseNotifications: false, // prevent spamming
version: false
}
},
mounted() {
let d = document.getElementById('app')
if (d) {
this.version = d.dataset.version
}
let proto = location.protocol == 'https:' ? 'wss' : 'ws'
this.socketURI = proto + "://" + document.location.host + this.resolve(`/api/events`)
@ -79,6 +85,11 @@ export default {
// refresh mailbox stats
mailbox.total = response.Data.Total
mailbox.unread = response.Data.Unread
// detect version updated, refresh is needed
if (self.version != response.Data.Version) {
location.reload();
}
}
}