@symbo.ls/fetch 2.6.12 → 2.6.16

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 +31 -13
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  import { client, fetch, set } from '@symbo.ls/based'
4
4
  import { deepMerge, isObject } from '@domql/utils'
5
+ import { setCookie } from '@domql/cookie'
6
+ import { router } from '@domql/router'
5
7
 
6
8
  import TMP_DATA from '@symbo.ls/temp-db'
7
9
  import CONFIG_DEFAULT from '@symbo.ls/config-default'
@@ -42,8 +44,8 @@ export const syncSystem = (data, el, s) => {
42
44
  // set({ $id: s.projectId, state: defObjs.state })
43
45
  }
44
46
 
45
- deepMerge(s.PROJECT_SYSTEM, system)
46
- deepMerge(s.PROJECT_STATE, state)
47
+ // deepMerge(s.PROJECT_SYSTEM, system)
48
+ // deepMerge(s.PROJECT_STATE, state)
47
49
  }
48
50
 
49
51
  export const publishSystem = (data, el, s) => {
@@ -57,15 +59,20 @@ export const publishSystem = (data, el, s) => {
57
59
  export const fetchProject = (el, s, { userName, projectId, ...options }) => {
58
60
  fetch({
59
61
  $id: projectId,
60
- $all: true
61
- }, async data => {
62
+ $all: true,
63
+ icon: {
64
+ src: true
65
+ }
66
+ }, data => {
62
67
  const { key, name, icon } = data
63
68
 
69
+ setCookie('appKey', key)
70
+
64
71
  s.update({
65
72
  appKey: key,
66
73
  projectName: name,
67
- userName,
68
- projectId,
74
+ userName: userName,
75
+ projectId: projectId,
69
76
  icon
70
77
  }, options)
71
78
 
@@ -74,21 +81,32 @@ export const fetchProject = (el, s, { userName, projectId, ...options }) => {
74
81
  }
75
82
 
76
83
  export const fetchUser = (el, s, options) => {
77
- if (!s.projectId) {
78
- fetch({ $id: s.userId, name: true, projects: true }, data => {
84
+ const { userName, projectId } = s
85
+ if (!userName || !projectId) {
86
+ fetch({
87
+ $id: s.userId,
88
+ name: true,
89
+ projects: {
90
+ id: true,
91
+ name: true,
92
+ key: true,
93
+ icon: {
94
+ src: true
95
+ },
96
+ $list: true
97
+ }
98
+ }, data => {
79
99
  const { projects } = data
80
100
  const userName = data.name
81
101
  if (projects) {
82
- s.update({ projects })
83
- const projectId = projects[s.activeProject || 0]
102
+ s.update({ userName, projects })
103
+ const projectId = projects[s.activeProject || 0].id
84
104
  fetchProject(el, s, { userName, projectId, ...options })
85
105
  }
86
106
  })
87
107
  } else {
88
108
  fetchProject(el, s, {
89
- userName: s.userName,
90
- projectId: s.projectId,
91
- ...options
109
+ userName, projectId, ...options
92
110
  })
93
111
  }
94
112
  }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@symbo.ls/fetch",
3
- "version": "2.6.12",
3
+ "version": "2.6.16",
4
4
  "main": "index.js",
5
5
  "dependencies": {
6
6
  "@symbo.ls/based": "latest",
7
7
  "@symbo.ls/config-default": "latest",
8
8
  "@symbo.ls/temp-db": "latest"
9
9
  },
10
- "gitHead": "577fe69bd3f157daa22b27d10600921b8bcd90e1"
10
+ "gitHead": "db978f0f4db5c1e3e23ff2c8bf12f61464769304"
11
11
  }