2023-09-14 22:30:20 +12:00
|
|
|
// State Management
|
|
|
|
|
|
|
|
import { reactive, watch } from 'vue'
|
|
|
|
|
|
|
|
// global mailbox info
|
|
|
|
export const mailbox = reactive({
|
2023-09-22 15:06:03 +12:00
|
|
|
total: 0, // total number of messages in database
|
|
|
|
unread: 0, // total unread messages in database
|
2023-09-14 22:30:20 +12:00
|
|
|
count: 0, // total in mailbox or search
|
|
|
|
messages: [], // current messages
|
|
|
|
tags: [], // all tags
|
|
|
|
selected: [], // currently selected
|
|
|
|
connected: false, // websocket connection
|
2023-09-22 15:06:03 +12:00
|
|
|
searching: false, // current search, false for none
|
2023-09-14 22:30:20 +12:00
|
|
|
refresh: false, // to listen from MessagesMixin
|
|
|
|
notificationsSupported: false,
|
|
|
|
notificationsEnabled: false,
|
2023-09-22 15:06:03 +12:00
|
|
|
appInfo: {}, // application information
|
|
|
|
uiConfig: {}, // configuration for UI
|
|
|
|
lastMessage: false, // return scrolling
|
2024-04-13 00:25:04 +12:00
|
|
|
|
|
|
|
// settings
|
|
|
|
showTagColors: !localStorage.getItem('hideTagColors') == '1',
|
|
|
|
showHTMLCheck: !localStorage.getItem('hideHTMLCheck') == '1',
|
|
|
|
showLinkCheck: !localStorage.getItem('hideLinkCheck') == '1',
|
|
|
|
showSpamCheck: !localStorage.getItem('hideSpamCheck') == '1',
|
|
|
|
timeZone: localStorage.getItem('timeZone') ? localStorage.getItem('timeZone') : Intl.DateTimeFormat().resolvedOptions().timeZone,
|
2023-09-14 22:30:20 +12:00
|
|
|
})
|
|
|
|
|
2023-09-22 15:06:03 +12:00
|
|
|
watch(
|
|
|
|
() => mailbox.count,
|
|
|
|
(v) => {
|
|
|
|
mailbox.selected = []
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
2023-09-14 22:30:20 +12:00
|
|
|
watch(
|
|
|
|
() => mailbox.showTagColors,
|
|
|
|
(v) => {
|
|
|
|
if (v) {
|
2023-12-01 15:30:14 +13:00
|
|
|
localStorage.removeItem('hideTagColors')
|
2023-09-14 22:30:20 +12:00
|
|
|
} else {
|
2023-12-01 15:30:14 +13:00
|
|
|
localStorage.setItem('hideTagColors', '1')
|
2023-09-14 22:30:20 +12:00
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
2024-04-13 00:25:04 +12:00
|
|
|
|
|
|
|
watch(
|
|
|
|
() => mailbox.showHTMLCheck,
|
|
|
|
(v) => {
|
|
|
|
if (v) {
|
|
|
|
localStorage.removeItem('hideHTMLCheck')
|
|
|
|
} else {
|
|
|
|
localStorage.setItem('hideHTMLCheck', '1')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => mailbox.showLinkCheck,
|
|
|
|
(v) => {
|
|
|
|
if (v) {
|
|
|
|
localStorage.removeItem('hideLinkCheck')
|
|
|
|
} else {
|
|
|
|
localStorage.setItem('hideLinkCheck', '1')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => mailbox.showSpamCheck,
|
|
|
|
(v) => {
|
|
|
|
if (v) {
|
|
|
|
localStorage.removeItem('hideSpamCheck')
|
|
|
|
} else {
|
|
|
|
localStorage.setItem('hideSpamCheck', '1')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
watch(
|
|
|
|
() => mailbox.timeZone,
|
|
|
|
(v) => {
|
|
|
|
if (v == Intl.DateTimeFormat().resolvedOptions().timeZone) {
|
|
|
|
localStorage.removeItem('timeZone')
|
|
|
|
} else {
|
|
|
|
localStorage.setItem('timeZone', v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|