1
0
mirror of https://github.com/axllent/mailpit.git synced 2025-01-16 02:47:11 +02:00
mailpit/server/ui-src/stores/mailbox.js
2023-09-22 15:06:03 +12:00

60 lines
1.2 KiB
JavaScript

// State Management
import { reactive, watch } from 'vue'
import Tinycon from 'tinycon'
Tinycon.setOptions({
height: 11,
background: '#dd0000',
fallback: false,
font: '9px arial',
})
// global mailbox info
export const mailbox = reactive({
total: 0, // total number of messages in database
unread: 0, // total unread messages in database
count: 0, // total in mailbox or search
messages: [], // current messages
tags: [], // all tags
showTagColors: false, // show tag colors?
selected: [], // currently selected
connected: false, // websocket connection
searching: false, // current search, false for none
refresh: false, // to listen from MessagesMixin
notificationsSupported: false,
notificationsEnabled: false,
appInfo: {}, // application information
uiConfig: {}, // configuration for UI
lastMessage: false, // return scrolling
})
watch(
() => mailbox.unread,
(v) => {
if (v == 0) {
Tinycon.reset()
} else {
Tinycon.setBubble(v)
}
}
)
watch(
() => mailbox.count,
(v) => {
mailbox.selected = []
}
)
watch(
() => mailbox.showTagColors,
(v) => {
if (v) {
localStorage.setItem('showTagsColors', '1')
} else {
localStorage.removeItem('showTagsColors')
}
}
)