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

UI: Add favicon unread message counter

This commit is contained in:
Ralph Slooten
2022-09-14 22:37:47 +12:00
parent 4e2e59ec87
commit f6a8de3215
3 changed files with 41 additions and 4 deletions

View File

@ -1,7 +1,8 @@
<script>
import commonMixins from './mixins.js'
import commonMixins from './mixins.js';
import Message from './templates/Message.vue';
import moment from 'moment'
import moment from 'moment';
import Tinycon from 'tinycon';
export default {
mixins: [commonMixins],
@ -26,7 +27,8 @@ export default {
messageNext: false,
notificationsSupported: false,
notificationsEnabled: false,
selected: []
selected: [],
tcStatus: 0
}
},
watch: {
@ -36,6 +38,17 @@ export default {
} else {
this.message = false;
}
},
unread(v, old) {
if (v == this.tcStatus) {
return;
}
this.tcStatus = v;
if (v == 0) {
Tinycon.reset();
} else {
Tinycon.setBubble(v);
}
}
},
computed: {
@ -56,6 +69,12 @@ export default {
&& ("Notification" in window && Notification.permission !== "denied");
this.notificationsEnabled = this.notificationsSupported && Notification.permission == "granted";
Tinycon.setOptions({
height: 11,
background: '#dd0000',
fallback: false
});
this.connect();
this.loadMessages();
},
@ -192,6 +211,7 @@ export default {
let self = this;
let uri = 'api/delete'
self.get(uri, false, function(response) {
window.location.hash = "";
self.reloadMessages();
});
},
@ -206,7 +226,6 @@ export default {
window.location.hash = "";
self.scrollInPlace = true;
self.loadMessages();
});
},
@ -388,6 +407,12 @@ export default {
let selecting = false;
let lastSelected = this.selected.length > 0 && this.selected[this.selected.length - 1];
if (lastSelected == id) {
this.selected = this.selected.filter(function(ele){
return ele != id;
});
return
}
if (lastSelected === false) {
this.selected.push(id);