ywana-core8 0.0.767 → 0.0.769

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": "ywana-core8",
3
- "version": "0.0.767",
3
+ "version": "0.0.769",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -18,18 +18,23 @@ export const CollectionContextProvider = (props) => {
18
18
  const [queries, setQueries] = useState([])
19
19
  const [selected, setSelected] = useState(null)
20
20
 
21
- useEffect(async () => {
22
- console.log("CONTEXT LOAD for Filters START", filters)
23
- await load()
24
- console.log("CONTEXT LOAD for Filters END", filters)
25
- }, [filters])
26
-
27
21
  useEffect(() => {
28
- if (Object.keys(customFilters).length > 0) {
29
- console.log("CONTEXT CustomFilters", customFilters)
30
- filter()
22
+
23
+ console.log("CONTEXT LOAD for Filters", filters, customFilters)
24
+ let mounted = true;
25
+
26
+ const callLoad = async () => {
27
+ const data = await load()
28
+ if (mounted) setAll(data)
29
+ }
30
+ callLoad()
31
+
32
+ return () => {
33
+ console.log("CONTEXT UNMOUNT", filters, customFilters)
34
+ mounted = false;
31
35
  }
32
- }, [customFilters])
36
+
37
+ }, [filters, customFilters])
33
38
 
34
39
  async function load() {
35
40
 
@@ -43,19 +48,12 @@ export const CollectionContextProvider = (props) => {
43
48
  const response = await API.all(filters, likes, page);
44
49
  const next = field ? response[field] : response;
45
50
  const data = runCustomFilters(next)
46
- setAll(data)
51
+ return data
47
52
  } catch (error) {
48
53
  console.log(error)
49
54
  }
50
55
  return
51
56
  }
52
-
53
- function filter() {
54
- console.log("RUN CUSTOM FILTERS", customFilters)
55
- const cfs = Object.values(customFilters)
56
- const data = cfs.length ? cfs.reduce((acc, filter) => filter(acc), all) : all;
57
- return data
58
- }
59
57
 
60
58
  async function select(id) {
61
59
  if (fetching) {