@rpcbase/client 0.121.0 → 0.123.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/auth/getUid.js +11 -0
- package/auth/index.js +1 -1
- package/helpers/useRPC.js +10 -1
- package/package.json +1 -1
- package/rts/getUseQuery/index.js +2 -2
- package/auth/get_uid.js +0 -11
package/auth/getUid.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* @flow */
|
|
2
|
+
import {Platform} from "react-native"
|
|
3
|
+
|
|
4
|
+
import {getUid as _getUid} from "./index"
|
|
5
|
+
|
|
6
|
+
const getUid = Platform.OS === "web" ? _getUid : () => {
|
|
7
|
+
console.warn("native should not call getUid, use userId from AuthContext")
|
|
8
|
+
return null
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default getUid
|
package/auth/index.js
CHANGED
package/helpers/useRPC.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import {useCallback, useMemo, useState, useEffect} from "react"
|
|
2
|
+
import {useCallback, useMemo, useState, useEffect, useRef} from "react"
|
|
3
|
+
import isEqual from "fast-deep-equal"
|
|
3
4
|
|
|
4
5
|
const useRPC = (fn, payload) => {
|
|
6
|
+
const previousPayloadRef = useRef(null)
|
|
7
|
+
|
|
5
8
|
const [loading, setLoading] = useState(true)
|
|
6
9
|
const [error, setError] = useState()
|
|
7
10
|
const [data, setData] = useState()
|
|
@@ -12,6 +15,12 @@ const useRPC = (fn, payload) => {
|
|
|
12
15
|
}, [payload])
|
|
13
16
|
|
|
14
17
|
useEffect(() => {
|
|
18
|
+
if (isEqual(previousPayloadRef.current, memoPayload)) {
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
previousPayloadRef.current = memoPayload
|
|
23
|
+
|
|
15
24
|
const load = async() => {
|
|
16
25
|
setLoading(true)
|
|
17
26
|
|
package/package.json
CHANGED
package/rts/getUseQuery/index.js
CHANGED
|
@@ -10,7 +10,7 @@ import LZString from "lz-string"
|
|
|
10
10
|
import isEqual from "fast-deep-equal/react"
|
|
11
11
|
|
|
12
12
|
import isEqualValues from "../../isEqualValues"
|
|
13
|
-
import
|
|
13
|
+
import getUid from "../../auth/getUid"
|
|
14
14
|
|
|
15
15
|
import useData from "./useData"
|
|
16
16
|
|
|
@@ -28,7 +28,7 @@ const getUseQuery = (register_query) => (
|
|
|
28
28
|
// TODO: retrieve this from future AuthContext in client
|
|
29
29
|
const uid = useMemo(() => {
|
|
30
30
|
// TODO: why is there a options.userId here ??
|
|
31
|
-
const _uid = Platform.OS === "web" ?
|
|
31
|
+
const _uid = Platform.OS === "web" ? getUid() : options.userId
|
|
32
32
|
assert(_uid, "missing uid")
|
|
33
33
|
return _uid
|
|
34
34
|
}, [])
|
package/auth/get_uid.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* @flow */
|
|
2
|
-
import {Platform} from "react-native"
|
|
3
|
-
|
|
4
|
-
import {get_uid as _get_uid} from "./index"
|
|
5
|
-
|
|
6
|
-
const get_uid = Platform.OS === "web" ? _get_uid : () => {
|
|
7
|
-
console.warn("native should not call get_uid, use userId from AuthContext")
|
|
8
|
-
return null
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export default get_uid
|