frappe-ui 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
deleteRowInListResource,
|
|
6
6
|
revertRowInListResource,
|
|
7
7
|
} from './listResource'
|
|
8
|
-
import { getLocal, saveLocal } from './local'
|
|
8
|
+
import { getLocal, saveLocal, deleteLocal } from './local'
|
|
9
9
|
import { onDocUpdate } from './realtime'
|
|
10
10
|
import { getConfig } from '../utils/config'
|
|
11
11
|
|
|
@@ -83,7 +83,12 @@ export function createDocumentResource(options, vm) {
|
|
|
83
83
|
out.originalDoc = JSON.parse(JSON.stringify(out.doc))
|
|
84
84
|
options.onSuccess?.call(vm, out.doc)
|
|
85
85
|
},
|
|
86
|
-
onError
|
|
86
|
+
onError(error) {
|
|
87
|
+
deleteLocal(cacheKey)
|
|
88
|
+
out.doc = null
|
|
89
|
+
out.originalDoc = null
|
|
90
|
+
options.onError?.call(vm, error)
|
|
91
|
+
},
|
|
87
92
|
},
|
|
88
93
|
vm
|
|
89
94
|
),
|
package/src/resources/local.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { get, set } from 'idb-keyval'
|
|
1
|
+
import { get, set, del } from 'idb-keyval'
|
|
2
2
|
|
|
3
3
|
export function saveLocal(key, data) {
|
|
4
4
|
if (typeof indexedDB === 'undefined') {
|
|
@@ -8,6 +8,14 @@ export function saveLocal(key, data) {
|
|
|
8
8
|
return set(key, JSON.stringify(data))
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
export function deleteLocal(key) {
|
|
12
|
+
if (typeof indexedDB === 'undefined') {
|
|
13
|
+
return Promise.resolve(null)
|
|
14
|
+
}
|
|
15
|
+
if (!key) return Promise.resolve()
|
|
16
|
+
return del(key)
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
export function getLocal(key) {
|
|
12
20
|
if (typeof indexedDB === 'undefined') {
|
|
13
21
|
return Promise.resolve(null)
|