forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautoUpdates.js
More file actions
54 lines (49 loc) · 1.25 KB
/
Copy pathautoUpdates.js
File metadata and controls
54 lines (49 loc) · 1.25 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { ipcRenderer } from 'electron'
import notice from '../services/notification'
const state = {}
const getters = {}
const mutations = {}
// mt::UPDATE_DOWNLOADED
const actions = {
LISTEN_FOR_UPDATE ({ commit }) {
ipcRenderer.on('mt::UPDATE_ERROR', (e, message) => {
notice.notify({
title: 'Update',
type: 'error',
time: 10000,
message
})
})
ipcRenderer.on('mt::UPDATE_NOT_AVAILABLE', (e, message) => {
notice.notify({
title: 'Update not Available',
type: 'primary',
message
})
})
ipcRenderer.on('mt::UPDATE_DOWNLOADED', (e, message) => {
notice.notify({
title: 'Update Downloaded',
type: 'info',
message
})
})
ipcRenderer.on('mt::UPDATE_AVAILABLE', (e, message) => {
notice.notify({
title: 'Update Available',
type: 'primary',
message,
showConfirm: true
})
.then(() => {
const needUpdate = true
ipcRenderer.send('mt::NEED_UPDATE', { needUpdate })
})
.catch(() => {
const needUpdate = false
ipcRenderer.send('mt::NEED_UPDATE', { needUpdate })
})
})
}
}
export default { state, getters, mutations, actions }