forked from cerebral/overmind
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheffects.ts
More file actions
55 lines (52 loc) · 1.22 KB
/
effects.ts
File metadata and controls
55 lines (52 loc) · 1.22 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
55
import * as jsonStorage from 'electron-json-storage'
import BackendConnector from '../BackendConnector'
export const connector = new BackendConnector()
export const utils = {
confirmDialog(text): boolean {
return window.confirm(text)
},
}
export const storage = {
clear() {
return new Promise((resolve, reject) => {
jsonStorage.clear((error) => {
if (error) {
reject(error)
} else {
resolve()
}
})
})
},
get<T>(key: string): Promise<T> {
return new Promise((resolve, reject) => {
jsonStorage.get(key, (err, data) => {
if (err) {
reject(err)
} else {
resolve(
// Insanely weird that when "no value", an empty
// object is returned. Should be null
typeof data === 'object' &&
!Array.isArray(data) &&
data !== null &&
Object.keys(data).length === 0
? null
: data
)
}
})
})
},
set(key, data) {
return new Promise((resolve, reject) => {
jsonStorage.set(key, data, (err) => {
if (err) {
reject(err)
} else {
resolve()
}
})
})
},
}