@rpcbase/client 0.65.0 → 0.67.0
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/hashState.js
CHANGED
|
@@ -30,17 +30,17 @@ const parse_hash_str = (hash_str = window.location.hash) => {
|
|
|
30
30
|
// On first load, retrieve hashState from URL
|
|
31
31
|
const __initial_state = _omitBy(parse_hash_str(), _isNil)
|
|
32
32
|
|
|
33
|
-
export const
|
|
33
|
+
export const encodeHashState = (payload) =>
|
|
34
34
|
LZString.compressToEncodedURIComponent(JSON.stringify(payload))
|
|
35
35
|
|
|
36
36
|
// add payload to window hash
|
|
37
37
|
const apply_hash_state = (payload) => {
|
|
38
|
-
const str =
|
|
38
|
+
const str = encodeHashState(payload)
|
|
39
39
|
|
|
40
40
|
if (str === EMPTY_STATE_TOKEN) {
|
|
41
41
|
history.replaceState(null, null, window.location.pathname)
|
|
42
42
|
} else {
|
|
43
|
-
history.replaceState(null, null, `${window.location.pathname}#${
|
|
43
|
+
history.replaceState(null, null, `${window.location.pathname}#${encodeHashState(payload)}`)
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -124,7 +124,7 @@ export const HashStateProvider = ({children}) => {
|
|
|
124
124
|
_isNil,
|
|
125
125
|
)
|
|
126
126
|
|
|
127
|
-
return
|
|
127
|
+
return encodeHashState(newState)
|
|
128
128
|
}, [])
|
|
129
129
|
|
|
130
130
|
return (
|
package/package.json
CHANGED
package/rts/getUseQuery.js
CHANGED
|
@@ -8,8 +8,6 @@ import _omit from "lodash/omit"
|
|
|
8
8
|
|
|
9
9
|
import get_uid from "../auth/get_uid"
|
|
10
10
|
|
|
11
|
-
// import cacheStorage from "./cacheStorage"
|
|
12
|
-
|
|
13
11
|
|
|
14
12
|
const log = debug("rb:rts:useQuery")
|
|
15
13
|
|
|
@@ -53,21 +51,6 @@ const getUseQuery = (register_query) => (
|
|
|
53
51
|
}
|
|
54
52
|
}, [])
|
|
55
53
|
|
|
56
|
-
// useEffect(() => {
|
|
57
|
-
// const load = async() => {
|
|
58
|
-
// const val = await cacheStorage.get(storageKey)
|
|
59
|
-
// // TODO: rm this
|
|
60
|
-
// // always initially apply when first load here
|
|
61
|
-
// if (val) {
|
|
62
|
-
// console.log("Will set val from cache storage")
|
|
63
|
-
// setData(val)
|
|
64
|
-
// setLoading(false)
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
//
|
|
68
|
-
// load()
|
|
69
|
-
// }, [storageKey])
|
|
70
|
-
|
|
71
54
|
const applyNewData = (newData, context) => {
|
|
72
55
|
setData(newData)
|
|
73
56
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const getEmptyStorage = () => {
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const storage = {
|
|
6
6
|
get: async(key) => {
|
|
7
7
|
},
|
|
8
8
|
set: async(key, obj) => {
|
|
@@ -11,7 +11,7 @@ const getEmptyStorage = () => {
|
|
|
11
11
|
},
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
return
|
|
14
|
+
return storage
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
import AsyncStorage from "@react-native-async-storage/async-storage"
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const getStorage = () => {
|
|
5
|
+
const storage = {
|
|
6
6
|
get: async(key) => {
|
|
7
7
|
try {
|
|
8
8
|
const res = await AsyncStorage.getItem(key)
|
|
@@ -21,8 +21,8 @@ const getNativeStorage = () => {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
return
|
|
24
|
+
return storage
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
export default
|
|
28
|
+
export default getStorage()
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
const storeName = "store"
|
|
3
3
|
const version = 1
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
dbName = "rb-
|
|
5
|
+
const getStorage = (
|
|
6
|
+
dbName = "rb-store"
|
|
7
7
|
) => {
|
|
8
8
|
let __db
|
|
9
9
|
|
|
@@ -28,7 +28,7 @@ const getWebStorage = (
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
const
|
|
31
|
+
const storage = {
|
|
32
32
|
get: (key) => new Promise((resolve, reject) => {
|
|
33
33
|
const transaction = __db.transaction([storeName], "readonly")
|
|
34
34
|
const objectStore = transaction.objectStore(storeName)
|
|
@@ -78,8 +78,8 @@ const getWebStorage = (
|
|
|
78
78
|
}),
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
return
|
|
81
|
+
return storage
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
|
|
85
|
-
export default
|
|
85
|
+
export default getStorage()
|