@symbo.ls/fetch 2.6.24 → 2.7.6

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.
Files changed (2) hide show
  1. package/index.js +16 -13
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -49,19 +49,20 @@ export const syncSystem = (data, el, s) => {
49
49
  // deepMerge(s.PROJECT_STATE, state)
50
50
  s.update({
51
51
  PROJECT_SYSTEM: system,
52
- PROJECT_STATE: state
52
+ PROJECT_STATE: state,
53
+ loading: false
53
54
  })
54
55
  }
55
56
 
56
- export const publishSystem = (data, el, s) => {
57
- set({
58
- $id: s.projectId,
59
- system: s.PROJECT_SYSTEM,
60
- state: s.PROJECT_STATE
61
- })
57
+ export const publishSystem = (el, s, changes) => {
58
+ if (changes.PROJECT_SYSTEM) {
59
+ set({ $id: s.projectId, system: changes.PROJECT_SYSTEM })
60
+ } if (changes.PROJECT_STATE) {
61
+ set({ $id: s.projectId, state: changes.PROJECT_STATE })
62
+ }
62
63
  }
63
64
 
64
- export const fetchProject = (el, s, { userName, projectId, ...options }) => {
65
+ export const fetchProject = (el, s, { userName, projectId, activeProject, ...options }) => {
65
66
  fetch({
66
67
  $id: projectId,
67
68
  $all: true,
@@ -72,21 +73,23 @@ export const fetchProject = (el, s, { userName, projectId, ...options }) => {
72
73
  const { key, name, icon } = data
73
74
 
74
75
  setCookie('appKey', key)
76
+ setCookie('activeProject', activeProject)
75
77
 
76
78
  s.update({
77
79
  appKey: key,
78
80
  projectName: name,
79
- userName: userName,
80
81
  projectId: projectId,
81
- icon
82
+ icon,
83
+ activeProject
82
84
  }, options)
83
85
 
86
+ console.log('FETCHED', projectId, data)
84
87
  syncSystem(data, el, s)
85
88
  })
86
89
  }
87
90
 
88
91
  export const fetchUser = (el, s, options) => {
89
- const { userName, projectId } = s
92
+ const { userName, projectId, activeProject } = s
90
93
  if (!userName || !projectId) {
91
94
  fetch({
92
95
  $id: s.userId,
@@ -106,12 +109,12 @@ export const fetchUser = (el, s, options) => {
106
109
  if (projects) {
107
110
  s.update({ userName, projects })
108
111
  const projectId = projects[s.activeProject || 0].id
109
- fetchProject(el, s, { userName, projectId, ...options })
112
+ fetchProject(el, s, { userName, projectId, activeProject, ...options })
110
113
  }
111
114
  })
112
115
  } else {
113
116
  fetchProject(el, s, {
114
- userName, projectId, ...options
117
+ userName, projectId, activeProject, ...options
115
118
  })
116
119
  }
117
120
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/fetch",
3
- "version": "2.6.24",
3
+ "version": "2.7.6",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "@domql/cookie": "latest",
@@ -9,5 +9,5 @@
9
9
  "@symbo.ls/config-default": "latest",
10
10
  "@symbo.ls/temp-db": "latest"
11
11
  },
12
- "gitHead": "b88d0a1e6dee83bd1063d6fbefc7abef4553395c"
12
+ "gitHead": "54d90eecb8bde751b2ba53caae30778aa7f3069c"
13
13
  }