@rpcbase/client 0.79.0 → 0.81.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.
@@ -2,6 +2,7 @@
2
2
  import assert from "assert"
3
3
  import {useState, useEffect} from "react"
4
4
  import {ActivityIndicator} from "react-native"
5
+ import Alert from "react-bootstrap/Alert"
5
6
  import page from "page"
6
7
 
7
8
  import post from "../../helpers/post"
@@ -23,13 +24,14 @@ const SignOut = ({
23
24
  const [isSignedOut, setIsSignedOut] = useState(false)
24
25
 
25
26
  const [accounts, setAccounts] = useState()
27
+ const [selectedAccounts, setSelectedAccounts] = useState([])
28
+
26
29
 
27
30
  useEffect(() => {
28
31
  const load = async() => {
29
32
  const res = await post("/api/v1/auth/get_accounts")
30
33
  assert(res.status === "ok")
31
34
  setAccounts(res.accounts)
32
- console.log("ACCOUNTS", res.accounts)
33
35
  }
34
36
 
35
37
  load()
@@ -52,18 +54,19 @@ const SignOut = ({
52
54
  }
53
55
 
54
56
 
55
- const onClickAccount = () => {
56
- console.log("clicked account")
57
- }
58
-
59
-
60
57
  const onSubmit = () => {
61
58
  signOut()
59
+ console.log("SEL", selectedAccounts)
62
60
  }
63
61
 
64
62
  return (
65
63
  <div id="sign-out-wrapper">
66
- {isSignedOut && <div>signed out successfully</div>}
64
+
65
+ {isSignedOut && (
66
+ <Alert variant="light" data-bs-theme="dark" style={{maxWidth: 260, position: "absolute"}} onClose={() => setIsSignedOut(false)} dismissible>
67
+ Signed out successfully
68
+ </Alert>
69
+ )}
67
70
 
68
71
  {accounts ? (<div className="form-signout text-center px-4 py-4 shadow-lg">
69
72
 
@@ -78,13 +81,24 @@ const SignOut = ({
78
81
  <ul className="list-group text-start">
79
82
  {accounts.map((acc, index) => {
80
83
  const id = `acc-${acc.user_id}-${index}`
84
+
85
+ const onChange = (e) => {
86
+ if (e.target.checked) {
87
+ setSelectedAccounts((prev) => [...prev, acc.user_id])
88
+ } else {
89
+ setSelectedAccounts((prev) => [...prev.filter((v) => v !== acc.user_id)])
90
+ }
91
+ }
92
+
93
+ const checked = selectedAccounts.includes(acc.user_id)
94
+
81
95
  return (
82
96
  <li key={id} className="list-group-item">
83
- <input className="form-check-input me-3" type="checkbox" value="" id={id} />
97
+ <input className="form-check-input me-3" type="checkbox" value="" checked={checked} onChange={onChange} id={id} />
84
98
  <label className="form-check-label stretched-link" for={id}>
85
99
  <AccountListItem
86
100
  account={acc}
87
- onClick={onClickAccount}
101
+ // onClick={onClickAccount}
88
102
  />
89
103
  </label>
90
104
  </li>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.79.0",
3
+ "version": "0.81.0",
4
4
  "scripts": {
5
5
  "build-firebase": "webpack -c firebase/webpack.config.js",
6
6
  "build": "yarn build-firebase",
@@ -138,7 +138,7 @@ const getUseQuery = (register_query) => (
138
138
 
139
139
  return () => {
140
140
  log && log("useQuery cleanup unsubscribe()")
141
- unsubscribe()
141
+ typeof unsubscribe === "function" && unsubscribe()
142
142
  }
143
143
  }, [JSON.stringify(query), key])
144
144
 
@@ -46,7 +46,7 @@ const run_query = async({model_name, query, query_key, options}, callback) => {
46
46
  // TODO: we should prefix model_name with tenant_prefix + env_id
47
47
  const col = get_collection(model_name)
48
48
 
49
- console.time(`query-${model_name}`)
49
+ // console.time(`query-${model_name}`)
50
50
  // https://github.com/pouchdb/pouchdb/tree/master/packages/node_modules/pouchdb-find#dbcreateindexindex--callback
51
51
  const {docs} = await col.find({
52
52
  // TODO: we should check if the selectors are compatible here
@@ -55,7 +55,7 @@ const run_query = async({model_name, query, query_key, options}, callback) => {
55
55
  // https://github.com/pouchdb/pouchdb/blob/master/packages/node_modules/pouchdb-find/src/adapters/local/find/index.js
56
56
  // fields: [""]
57
57
  })
58
- console.timeEnd(`query-${model_name}`)
58
+ // console.timeEnd(`query-${model_name}`)
59
59
 
60
60
  let mapped_docs = docs
61
61
  .map(({_rev, ...doc}) => {