-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstore.ts
More file actions
31 lines (28 loc) · 1.07 KB
/
store.ts
File metadata and controls
31 lines (28 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { reactive } from 'vue'
import { getSettings } from './services/settings'
export const globalState = reactive({
dashboardUrl: '/',
contactSupportUrl: 'https://community.drycc.cc/',
settingsLoaded: false,
// Bumped whenever the user's message read-state changes (e.g. mark-all-read,
// mark single message as read). Components that display messages should
// watch this value and refresh their local state.
messagesVersion: 0,
})
/** Notify all message-aware components to refresh. */
export const invalidateMessages = () => {
globalState.messagesVersion += 1
}
export const fetchGlobalSettings = async () => {
if (globalState.settingsLoaded) return;
try {
const res = await getSettings()
if (res.data) {
if (res.data.dashboard_url) globalState.dashboardUrl = res.data.dashboard_url
if (res.data.contact_support_url) globalState.contactSupportUrl = res.data.contact_support_url
}
globalState.settingsLoaded = true
} catch (e) {
console.error("Failed to fetch settings", e)
}
}