@rpcbase/client 0.110.0 → 0.112.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/index.js +5 -2
- package/package.json +1 -1
- package/rts/getUseDocument.js +1 -1
- package/rts/getUseQuery/index.js +14 -2
package/auth/index.js
CHANGED
|
@@ -113,8 +113,11 @@ export const session_restrict = (ctx, next) => {
|
|
|
113
113
|
export const get_uid = () => __user_id
|
|
114
114
|
export const set_uid = (val) => {
|
|
115
115
|
__user_id = val
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
|
|
117
|
+
if (typeof val === "string") {
|
|
118
|
+
const tenant_id_prefix = val.slice(0, 8)
|
|
119
|
+
storage.setItem(uid_storage_key(tenant_id_prefix), val)
|
|
120
|
+
}
|
|
118
121
|
}
|
|
119
122
|
|
|
120
123
|
export const get_tenant_id = () => __tenant_id
|
package/package.json
CHANGED
package/rts/getUseDocument.js
CHANGED
|
@@ -9,7 +9,7 @@ const getUseDocument = (register_query) => (...args) => {
|
|
|
9
9
|
const res = useQuery(...args)
|
|
10
10
|
|
|
11
11
|
let data
|
|
12
|
-
// cache will always return [] when there are no matching documents, but we want null instead
|
|
12
|
+
// WARNING: cache will always return [] when there are no matching documents, but we want null instead
|
|
13
13
|
if (Array.isArray(res.data) && res.data.length === 0 && res.source === "cache") {
|
|
14
14
|
data = null
|
|
15
15
|
} else if (Array.isArray(res.data) && res.data.length > 0) {
|
package/rts/getUseQuery/index.js
CHANGED
|
@@ -6,6 +6,9 @@ import debug from "debug"
|
|
|
6
6
|
import _omit from "lodash/omit"
|
|
7
7
|
import LZString from "lz-string"
|
|
8
8
|
|
|
9
|
+
// TODO: remove this when stable
|
|
10
|
+
import isEqual from "fast-deep-equal/react"
|
|
11
|
+
|
|
9
12
|
import isEqualValues from "../../isEqualValues"
|
|
10
13
|
import get_uid from "../../auth/get_uid"
|
|
11
14
|
|
|
@@ -50,6 +53,7 @@ const getUseQuery = (register_query) => (
|
|
|
50
53
|
|
|
51
54
|
const [source, setSource] = useState()
|
|
52
55
|
|
|
56
|
+
const dataRef = useRef(null)
|
|
53
57
|
const [data, setData] = useData({useStorage, storageKey, hasInitiallySetFromStorage})
|
|
54
58
|
|
|
55
59
|
const [error, setError] = useState()
|
|
@@ -69,6 +73,8 @@ const getUseQuery = (register_query) => (
|
|
|
69
73
|
|
|
70
74
|
const applyNewData = (newData, context) => {
|
|
71
75
|
setData(newData)
|
|
76
|
+
// set data in a ref so that it doesn't force re-rendering ie: unsubscribe / resubscribe
|
|
77
|
+
dataRef.current = newData
|
|
72
78
|
|
|
73
79
|
// we only save network queries
|
|
74
80
|
if (useStorage && context.source === "network") {
|
|
@@ -158,7 +164,11 @@ const getUseQuery = (register_query) => (
|
|
|
158
164
|
return
|
|
159
165
|
}
|
|
160
166
|
|
|
161
|
-
if (!isEqualValues(data, newData)) {
|
|
167
|
+
if (isEqual(data, newData) && !isEqualValues(data, newData) && __DEV__) {
|
|
168
|
+
alert("EQUALITY MISMATCH THIS SHOULD NOT HAPPPEND!!!", data, newData)
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (!isEqualValues(dataRef.current, newData)) {
|
|
162
172
|
applyContext(context)
|
|
163
173
|
applyNewData(newData, context)
|
|
164
174
|
} else {
|
|
@@ -170,8 +180,10 @@ const getUseQuery = (register_query) => (
|
|
|
170
180
|
log && log("useQuery cleanup unsubscribe()")
|
|
171
181
|
typeof unsubscribe === "function" && unsubscribe()
|
|
172
182
|
}
|
|
183
|
+
|
|
184
|
+
// WARNING: do not change the hooks dependencies param or you risk creating infinite loops as it unsubscribes on cleanup
|
|
173
185
|
// TODO: this isnt right we need to update on options change too
|
|
174
|
-
}, [JSON.stringify(query),
|
|
186
|
+
}, [JSON.stringify(query), key])
|
|
175
187
|
|
|
176
188
|
|
|
177
189
|
const loadNextPage = useCallback(() => {
|