@rpcbase/client 0.114.0 → 0.116.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.114.0",
3
+ "version": "0.116.0",
4
4
  "scripts": {
5
5
  "build-firebase": "webpack -c firebase/webpack.config.js",
6
6
  "build": "yarn build-firebase",
@@ -48,14 +48,16 @@ const run_query = async({model_name, query, query_key, options}, callback) => {
48
48
 
49
49
  const replaced_query = replace_query_keys(query, (k) => (k.startsWith("_") && k !== "_id") ? `${UNDERSCORE_PREFIX}${k}` : k)
50
50
 
51
- // console.time(`query-${model_name}`)
52
- // https://github.com/pouchdb/pouchdb/tree/master/packages/node_modules/pouchdb-find#dbcreateindexindex--callback
53
- const {docs} = await collection.find({
51
+ const find_query = {
54
52
  selector: replaced_query,
55
53
  // DO NOT INCLUDE FIELDS HERE AS IT USES PICK AND WE WOULD GO through the list twice
56
54
  // https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-find/src/adapters/local/find/index.js
57
55
  // fields: [""]
58
- })
56
+ }
57
+
58
+ // console.time(`query-${model_name}`)
59
+ // https://github.com/pouchdb/pouchdb/tree/master/packages/node_modules/pouchdb-find#dbcreateindexindex--callback
60
+ const {docs} = await collection.find(find_query)
59
61
  // console.timeEnd(`query-${model_name}`)
60
62
 
61
63
  let mapped_docs = docs
@@ -76,6 +78,21 @@ const run_query = async({model_name, query, query_key, options}, callback) => {
76
78
  })
77
79
  }
78
80
 
81
+ if (options.sort) {
82
+ mapped_docs = mapped_docs.sort((a, b) => {
83
+ for (const key in options.sort) {
84
+ // Check if property exists on both objects
85
+ if (a.hasOwnProperty(key) && b.hasOwnProperty(key)) {
86
+ const dir = options.sort[key] // Direction of sorting: 1 or -1
87
+
88
+ if (a[key] < b[key]) return -1 * dir
89
+ if (a[key] > b[key]) return 1 * dir
90
+ }
91
+ }
92
+ return 0
93
+ })
94
+ }
95
+
79
96
  callback(null, mapped_docs, {source: "cache"})
80
97
  }
81
98
 
@@ -14,9 +14,6 @@ const Avatar = ({
14
14
  }) => {
15
15
  const sizeStyles = SIZE_STYLES[size]
16
16
 
17
- // TODO: too many re-renders in conv sidebar
18
- // console.log("RENDER AVATAR", text)
19
-
20
17
  return (
21
18
  <div
22
19
  className={cx("font-monospace", className)}
@@ -26,13 +23,11 @@ const Avatar = ({
26
23
  alignItems: "center",
27
24
  backgroundColor: color,
28
25
  userSelect: "none",
29
- font: "inherit",
30
- fontSize: "inherit",
31
26
  ...sizeStyles,
32
27
  ...style,
33
28
  }}
34
29
  >
35
- <Text style={{color: textColor}}>{text}</Text>
30
+ <Text style={{color: textColor, font: "inherit"}}>{text}</Text>
36
31
  </div>
37
32
  )
38
33
  }